diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-08-28 17:53:00 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-08-28 17:53:00 +0000 |
commit | 72ee108137acea74ea7d3c05362bb06d25637cc2 (patch) | |
tree | 4f28e166a7bbf52816c9efa8ea40b12e44c02a1b /lib/CodeGen/CodeGenModule.cpp | |
parent | ff991a88d39e5135f1616176c9738fdc53aba458 (diff) |
Revert r311857 "Emit static constexpr member as available_externally definition"
It caused PR759744.
> Emit static constexpr member as available_externally definition
>
> By exposing the constant initializer, the optimizer can fold many
> of these constructs.
>
> Differential Revision: https://reviews.llvm.org/D34992
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311898 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 5feb6b4d76..c726d90f2e 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -2437,28 +2437,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, D->getType().isConstant(Context) && isExternallyVisible(D->getLinkageAndVisibility().getLinkage())) GV->setSection(".cp.rodata"); - - // Check if we a have a const declaration with an initializer, we may be - // able to emit it as available_externally to expose it's value to the - // optimizer. - if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() && - D->getType().isConstQualified() && !GV->hasInitializer() && - !D->hasDefinition() && D->hasInit() && !D->hasAttr<DLLImportAttr>()) { - const auto *Record = - Context.getBaseElementType(D->getType())->getAsCXXRecordDecl(); - bool HasMutableFields = Record && Record->hasMutableFields(); - if (!HasMutableFields) { - const VarDecl *InitDecl; - const Expr *InitExpr = D->getAnyInitializer(InitDecl); - if (InitExpr) { - GV->setConstant(true); - GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage); - ConstantEmitter emitter(*this); - GV->setInitializer(emitter.tryEmitForInitializer(*InitDecl)); - emitter.finalize(GV); - } - } - } } auto ExpectedAS = |