Synchronize the logic for deciding to link a gv.

We were deciding to not link an available_externally gv over a
declaration, but then copying over the body anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255169 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-12-09 22:44:00 +00:00
parent 49c4c7b2a7
commit fad81ab170
3 changed files with 20 additions and 1 deletions

View File

@ -1050,7 +1050,12 @@ bool ModuleLinker::shouldLinkFromSource(bool &LinkFromSrc,
return false;
}
// If the Dest is weak, use the source linkage.
LinkFromSrc = Dest.hasExternalWeakLinkage();
if (Dest.hasExternalWeakLinkage()) {
LinkFromSrc = true;
return false;
}
// Link an available_externally over a declaration.
LinkFromSrc = !Src.isDeclaration() && Dest.isDeclaration();
return false;
}

View File

@ -0,0 +1,5 @@
@h = global void ()* @f
define available_externally void @f() {
ret void
}

View File

@ -0,0 +1,9 @@
; RUN: llvm-link -S %s %p/Inputs/available_externally_over_decl.ll | FileCheck %s
declare void @f()
define void ()* @main() {
ret void ()* @f
}
; CHECK: define available_externally void @f() {