With this I think that now llvm-link, lld and the gold plugin should
agree on which symbol is kept.
llvm-svn: 264292
if (!SC)
return;
for (GlobalValue *GV2 : LazyComdatMembers[SC]) {
+ GlobalValue *DGV = getLinkedToGlobal(GV2);
+ bool LinkFromSrc = true;
+ if (DGV && shouldLinkFromSource(LinkFromSrc, *DGV, *GV2))
+ return;
+ if (!LinkFromSrc)
+ continue;
if (shouldInternalizeLinkedSymbols())
Internalize.insert(GV2->getName());
Add(*GV2);
$foo = comdat any
+$bar = comdat any
+
define linkonce_odr i32 @f1() comdat($foo) {
ret i32 1
}
+
define void @f2() comdat($foo) {
+ call i32 @g2()
ret void
}
+
+define linkonce_odr i32 @g1() comdat($bar) {
+ ret i32 1
+}
+
+define linkonce_odr i32 @g2() comdat($bar) {
+ ret i32 1
+}
; RUN: llvm-link -S %s %p/Inputs/pr27044.ll -o - | FileCheck %s
; CHECK: define i32 @f1() {
+; CHECK: define i32 @g1() {
; CHECK: define void @f2() comdat($foo) {
+; CHECK: define linkonce_odr i32 @g2() comdat($bar) {
define i32 @f1() {
ret i32 0
}
+
+define i32 @g1() {
+ ret i32 0
+}