]> granicus.if.org Git - clang/commitdiff
Don't set unnamed_addr in CreateRuntimeVariable.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 May 2014 23:33:27 +0000 (23:33 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 May 2014 23:33:27 +0000 (23:33 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209484 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h
test/CodeGenCXX/global-init.cpp

index fe6e75dd419b733ef63fbfa5d371e6ff43f0d088..0d781fd1639c0f9b41ee2e2d7c8b34c968f0841f 100644 (file)
@@ -1533,8 +1533,7 @@ static bool isVarDeclInlineInitializedStaticDataMember(const VarDecl *VD) {
 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(StringRef MangledName,
         Entry->setLinkage(llvm::Function::ExternalLinkage);
     }
 
-    if (UnnamedAddr)
-      Entry->setUnnamedAddr(true);
-
     if (Entry->getType() == Ty)
       return Entry;
 
@@ -1671,8 +1667,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
 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) {
index bb7f1899d59ca4dd301010b6284b5353e2f55b20..7b467291e42266f2b21541fa3e9d37582bcb6bfa 100644 (file)
@@ -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).
index a425923e9fa10e06af5e307e9a8b09b91ab6818c..9c5b03a9284562312a24fd7a3baf5fcc1643d387 100644 (file)
@@ -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.