Set comdats when lazily linking functions.

We were setting the comdat when functions were copied in the initial pass, but
not when they were linked only when we found out that they are needed.

llvm-svn: 215765
This commit is contained in:
Rafael Espindola 2014-08-15 20:17:08 +00:00
parent 64fa12372c
commit 3931c28b03
3 changed files with 17 additions and 0 deletions

View File

@ -546,6 +546,11 @@ Value *ValueMaterializerTy::materializeValueFor(Value *V) {
SF->getLinkage(), SF->getName(), DstM);
copyGVAttributes(DF, SF);
if (Comdat *SC = SF->getComdat()) {
Comdat *DC = DstM->getOrInsertComdat(SC->getName());
DF->setComdat(DC);
}
LazilyLinkFunctions.push_back(SF);
return DF;
}

View File

@ -0,0 +1,5 @@
$c = comdat any
@a = alias void ()* @f
define internal void @f() comdat $c {
ret void
}

View File

@ -0,0 +1,7 @@
; RUN: llvm-link %s %p/Inputs/comdat9.ll -S -o - | FileCheck %s
; CHECK: $c = comdat any
; CHECK: @a = alias void ()* @f
; CHECK: define internal void @f() comdat $c {
; CHECK: ret void
; CHECK: }