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.

llvm-svn: 254543
This commit is contained in:
Rafael Espindola 2015-12-02 20:57:33 +00:00
parent 60b8a45ea6
commit 371e07845e
3 changed files with 16 additions and 1 deletions

View File

@ -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))

View File

@ -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
}

9
test/Linker/comdat15.ll Normal file
View File

@ -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