aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-05-27 01:45:30 +0000
committerJohn McCall <rjmccall@apple.com>2010-05-27 01:45:30 +0000
commitc76702cc80c1ef8a94d82b62ddcb4ed4f67d5b8c (patch)
tree8357bdfafd6d6bc42500301042dde5173e622972 /lib/CodeGen/CodeGenModule.cpp
parent8a2c92cab213bd7e28ff669577e815cd70bafbe3 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104796 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--lib/CodeGen/CodeGenModule.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index 1b89d62242..103024c323 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/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);
}