r209484 - Don't set unnamed_addr in CreateRuntimeVariable.
Rafael Espindola
rafael.espindola at gmail.com
Thu May 22 16:33:28 PDT 2014
Author: rafael
Date: Thu May 22 18:33:27 2014
New Revision: 209484
URL: http://llvm.org/viewvc/llvm-project?rev=209484&view=rev
Log:
Don't set unnamed_addr in CreateRuntimeVariable.
This was fairly broken. For example,
@__dso_handle would or would not get an unnamed_addr depending on how many
global destructors were used in a translation unit.
The consensus was that not every runtime variable is unnamed_addr and that
__dso_handle handle should not be, so just don't add unnamed_addr in
CreateRuntimeVariable.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/test/CodeGenCXX/global-init.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=209484&r1=209483&r2=209484&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu May 22 18:33:27 2014
@@ -1533,8 +1533,7 @@ static bool isVarDeclInlineInitializedSt
llvm::Constant *
CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
llvm::PointerType *Ty,
- const VarDecl *D,
- bool UnnamedAddr) {
+ const VarDecl *D) {
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
@@ -1543,9 +1542,6 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
Entry->setLinkage(llvm::Function::ExternalLinkage);
}
- if (UnnamedAddr)
- Entry->setUnnamedAddr(true);
-
if (Entry->getType() == Ty)
return Entry;
@@ -1671,8 +1667,7 @@ llvm::Constant *CodeGenModule::GetAddrOf
llvm::Constant *
CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
StringRef Name) {
- return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr,
- true);
+ return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
}
void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=209484&r1=209483&r2=209484&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Thu May 22 18:33:27 2014
@@ -1013,8 +1013,7 @@ private:
llvm::Constant *GetOrCreateLLVMGlobal(StringRef MangledName,
llvm::PointerType *PTy,
- const VarDecl *D,
- bool UnnamedAddr = false);
+ const VarDecl *D);
/// Set attributes which are common to any form of a global definition (alias,
/// Objective-C method, function, global variable).
Modified: cfe/trunk/test/CodeGenCXX/global-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/global-init.cpp?rev=209484&r1=209483&r2=209484&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/global-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp Thu May 22 18:33:27 2014
@@ -12,7 +12,7 @@ struct C { void *field; };
struct D { ~D(); };
-// CHECK: @__dso_handle = external unnamed_addr global i8
+// CHECK: @__dso_handle = external global i8
// CHECK: @c = global %struct.C zeroinitializer, align 8
// It's okay if we ever implement the IR-generation optimization to remove this.
More information about the cfe-commits
mailing list