aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-21 19:28:58 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-21 19:28:58 +0000
commit7520bd1de12af10ea08c662440565adbdf589317 (patch)
tree95a1259e7d1a541322ace1f6ecee8f9d250bcaa7 /lib/CodeGen/CodeGenModule.cpp
parenta37221e2e8fd3f8e6b86d9974ea59b6fd11ca6e8 (diff)
Fix emission of static tentative definitions referenced from other static functions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69699 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 9ae93599df..80e4bd9f9b 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -716,16 +716,18 @@ CodeGenModule::CreateRuntimeVariable(const llvm::Type *Ty,
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);
}