]> granicus.if.org Git - clang/commitdiff
fix codegen on static variables which have multiple decl nodes. These
authorChris Lattner <sabre@nondot.org>
Sat, 2 Feb 2008 04:43:11 +0000 (04:43 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 2 Feb 2008 04:43:11 +0000 (04:43 +0000)
should be merged just like normal globals.  This fixes this testcase
that Anders provided:

static struct s a;
static struct s *ap1 = &a;
static struct s a =  { 10 };

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

CodeGen/CodeGenModule.cpp

index ee84f954c5632322d08790c981861d28667ca490..edf3dc42831eb576e8e8a1eafb9fc08b7f9d912c 100644 (file)
@@ -134,7 +134,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
   const llvm::Type *Ty = getTypes().ConvertTypeForMem(D->getType());
 
   // Check to see if the global already exists.
-  llvm::GlobalVariable *GV = getModule().getGlobalVariable(D->getName());
+  llvm::GlobalVariable *GV = getModule().getGlobalVariable(D->getName(), true);
 
   // If it doesn't already exist, just create and return an entry.
   if (GV == 0) {