[cfe-commits] r69699 - /cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Douglas Gregor dgregor at apple.com
Tue Apr 21 12:28:58 PDT 2009


Author: dgregor
Date: Tue Apr 21 14:28:58 2009
New Revision: 69699

URL: http://llvm.org/viewvc/llvm-project?rev=69699&view=rev
Log:
Fix emission of static tentative definitions referenced from other static functions

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=69699&r1=69698&r2=69699&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Apr 21 14:28:58 2009
@@ -716,16 +716,18 @@
 void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
   assert(!D->getInit() && "Cannot emit definite definitions here!");
 
-  // See if we have already defined this (as a variable), if so we do
-  // not need to do anything.
-  llvm::GlobalValue *GV = GlobalDeclMap[getMangledName(D)];
-  if (!GV && MayDeferGeneration(D)) // this variable was never referenced
-    return;
-
-  if (llvm::GlobalVariable *Var = dyn_cast_or_null<llvm::GlobalVariable>(GV))
-    if (Var->hasInitializer())
+  if (MayDeferGeneration(D)) {
+    // If we have not seen a reference to this variable yet, place it
+    // into the deferred declarations table to be emitted if needed
+    // later.
+    const char *MangledName = getMangledName(D);
+    if (GlobalDeclMap.count(MangledName) == 0) {
+      DeferredDecls[MangledName] = D;
       return;
-  
+    }
+  }
+
+  // The tentative definition is the only definition.
   EmitGlobalVarDefinition(D);
 }
 





More information about the cfe-commits mailing list