From e39a7a693345e4633edf72e1251ddd5982658724 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 2 Dec 2015 20:57:33 +0000 Subject: [PATCH] Also copy private linkage globals when needed. This was an omission when handling COFF style comdats with local keys. Should fix the sanitizer-windows bot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254543 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Linker/LinkModules.cpp | 2 +- test/Linker/Inputs/comdat15.ll | 6 ++++++ test/Linker/comdat15.ll | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/Linker/Inputs/comdat15.ll create mode 100644 test/Linker/comdat15.ll diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 3e54e279573..e90ce166962 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1426,7 +1426,7 @@ bool ModuleLinker::linkGlobalValueProto(GlobalValue *SGV) { std::tie(SK, LinkFromSrc) = ComdatsChosen[SC]; C = DstM.getOrInsertComdat(SC->getName()); C->setSelectionKind(SK); - if (SGV->hasInternalLinkage()) + if (SGV->hasLocalLinkage()) LinkFromSrc = true; } else if (DGV) { if (shouldLinkFromSource(LinkFromSrc, *DGV, *SGV)) diff --git a/test/Linker/Inputs/comdat15.ll b/test/Linker/Inputs/comdat15.ll new file mode 100644 index 00000000000..5d2d41bba6a --- /dev/null +++ b/test/Linker/Inputs/comdat15.ll @@ -0,0 +1,6 @@ +$a1 = comdat any +@baz = private global i32 42, comdat($a1) +@a1 = internal alias i32, i32* @baz +define i32* @abc() { + ret i32* @a1 +} diff --git a/test/Linker/comdat15.ll b/test/Linker/comdat15.ll new file mode 100644 index 00000000000..cf900263105 --- /dev/null +++ b/test/Linker/comdat15.ll @@ -0,0 +1,9 @@ +; RUN: llvm-link -S %s %p/Inputs/comdat15.ll -o - | FileCheck %s + +$a1 = comdat any +@bar = global i32 0, comdat($a1) + +; CHECK: @bar = global i32 0, comdat($a1) +; CHECK: @baz = private global i32 42, comdat($a1) +; CHECK: @a1 = internal alias i32, i32* @baz + -- 2.34.1