From: Rafael Espindola Date: Fri, 15 Aug 2014 20:17:08 +0000 (+0000) Subject: Set comdats when lazily linking functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0549fc2448a47515237319a2078e7bcda1c19bbe;p=llvm 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215765 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 1970e7fa069..5c26b2610b1 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -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; } diff --git a/test/Linker/Inputs/comdat9.ll b/test/Linker/Inputs/comdat9.ll new file mode 100644 index 00000000000..679dbde98c3 --- /dev/null +++ b/test/Linker/Inputs/comdat9.ll @@ -0,0 +1,5 @@ +$c = comdat any +@a = alias void ()* @f +define internal void @f() comdat $c { + ret void +} diff --git a/test/Linker/comdat9.ll b/test/Linker/comdat9.ll new file mode 100644 index 00000000000..eada8c62bef --- /dev/null +++ b/test/Linker/comdat9.ll @@ -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: }