diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-21 19:28:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-21 19:28:58 +0000 |
commit | fa9ab53d95e56b60ad44d279c558aa1e902a6d77 (patch) | |
tree | 999b6aeb005514db2f042f7b8b2f2d99c0a27eeb /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 2655f85975d20aad16183ca6ec0d738934128c0a (diff) | |
download | bcm5719-llvm-fa9ab53d95e56b60ad44d279c558aa1e902a6d77.tar.gz bcm5719-llvm-fa9ab53d95e56b60ad44d279c558aa1e902a6d77.zip |
Fix emission of static tentative definitions referenced from other static functions
llvm-svn: 69699
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9ae93599df1..80e4bd9f9bb 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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); } |