diff options
| author | John McCall <rjmccall@apple.com> | 2010-05-27 01:45:30 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-05-27 01:45:30 +0000 |
| commit | c2af939ab4f5f1439ab155e0177a4ce3a0796b6a (patch) | |
| tree | 23e7b9842dc91480c51e20fe8b17bc2b432be272 /clang/lib/CodeGen | |
| parent | 401304462ac053f28c60b962f60a0b0a33ad7388 (diff) | |
| download | bcm5719-llvm-c2af939ab4f5f1439ab155e0177a4ce3a0796b6a.tar.gz bcm5719-llvm-c2af939ab4f5f1439ab155e0177a4ce3a0796b6a.zip | |
When deciding whether a deferred declaration has already been emitted,
aliases count as definitions regardless of whether their target has been
emitted yet. Fixes PR 7142.
llvm-svn: 104796
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 1b89d622420..103024c3239 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -513,9 +513,14 @@ void CodeGenModule::EmitDeferred() { GlobalDecl D = DeferredDeclsToEmit.back(); DeferredDeclsToEmit.pop_back(); - // Look it up to see if it was defined with a stronger definition (e.g. an - // extern inline function with a strong function redefinition). If so, - // just ignore the deferred decl. + // Check to see if we've already emitted this. This is necessary + // for a couple of reasons: first, decls can end up in the + // deferred-decls queue multiple times, and second, decls can end + // up with definitions in unusual ways (e.g. by an extern inline + // function acquiring a strong function redefinition). Just + // ignore these cases. + // + // TODO: That said, looking this up multiple times is very wasteful. MangleBuffer Name; getMangledName(Name, D); llvm::GlobalValue *CGRef = GetGlobalValue(Name); @@ -524,6 +529,11 @@ void CodeGenModule::EmitDeferred() { if (!CGRef->isDeclaration()) continue; + // GlobalAlias::isDeclaration() defers to the aliasee, but for our + // purposes an alias counts as a definition. + if (isa<llvm::GlobalAlias>(CGRef)) + continue; + // Otherwise, emit the definition and move on to the next one. EmitGlobalDefinition(D); } |

