diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 14c6a10c339..6e425992393 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -705,6 +705,9 @@ bool ModuleLinker::getLinkageResult(GlobalValue *Dest, const GlobalValue *Src, if (DestIsDeclaration) { LinkFromSrc = true; LT = Src->getLinkage(); + } else { + LinkFromSrc = false; + LT = Dest->getLinkage(); } } else if (Dest->hasExternalWeakLinkage()) { // If the Dest is weak, use the source linkage. diff --git a/test/Linker/Inputs/linkage2.ll b/test/Linker/Inputs/linkage2.ll index 3f6963ec4c7..6ecaeb55a0f 100644 --- a/test/Linker/Inputs/linkage2.ll +++ b/test/Linker/Inputs/linkage2.ll @@ -1 +1,3 @@ @test1_a = weak global i8 1 + +@test2_a = external dllimport global i8 diff --git a/test/Linker/linkage2.ll b/test/Linker/linkage2.ll index 2ecdc1ff30a..99cb22c05c2 100644 --- a/test/Linker/linkage2.ll +++ b/test/Linker/linkage2.ll @@ -2,5 +2,7 @@ ; RUN: llvm-link %p/Inputs/linkage2.ll %s -S | FileCheck %s @test1_a = common global i8 0 - ; CHECK: @test1_a = common global i8 0 + +@test2_a = global i8 0 +; CHECK: @test2_a = global i8 0