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 | edd66ab9dc2345e989b59578c8f4d41fe36d8272 (patch) | |
tree | 3681be8abedb4ed8c354c041edddf24cf4781489 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | dad7cf62de5e8b0b03f8fdd6b6e2da887bfb4892 (diff) | |
download | bcm5719-llvm-edd66ab9dc2345e989b59578c8f4d41fe36d8272.tar.gz bcm5719-llvm-edd66ab9dc2345e989b59578c8f4d41fe36d8272.zip |
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
llvm-svn: 311898
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5feb6b4d768..c726d90f2e3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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 = |