From c787184012dc0cbadbe7ccdc12ad318daa0f168e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 9 Sep 2014 14:52:27 +0000 Subject: [PATCH] Fix a use of an undefined value (the linkage). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217445 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 3 +++ test/Linker/Inputs/linkage2.ll | 2 ++ test/Linker/linkage2.ll | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) 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