[llvm] r264292 - Fix another case where we were unconditionally linking linkonce GVs.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 24 08:23:02 PDT 2016
Author: rafael
Date: Thu Mar 24 10:23:01 2016
New Revision: 264292
URL: http://llvm.org/viewvc/llvm-project?rev=264292&view=rev
Log:
Fix another case where we were unconditionally linking linkonce GVs.
With this I think that now llvm-link, lld and the gold plugin should
agree on which symbol is kept.
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/test/Linker/Inputs/pr27044.ll
llvm/trunk/test/Linker/pr27044.ll
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=264292&r1=264291&r2=264292&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Thu Mar 24 10:23:01 2016
@@ -447,6 +447,12 @@ void ModuleLinker::addLazyFor(GlobalValu
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);
Modified: llvm/trunk/test/Linker/Inputs/pr27044.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/pr27044.ll?rev=264292&r1=264291&r2=264292&view=diff
==============================================================================
--- llvm/trunk/test/Linker/Inputs/pr27044.ll (original)
+++ llvm/trunk/test/Linker/Inputs/pr27044.ll Thu Mar 24 10:23:01 2016
@@ -1,7 +1,19 @@
$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
+}
Modified: llvm/trunk/test/Linker/pr27044.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/pr27044.ll?rev=264292&r1=264291&r2=264292&view=diff
==============================================================================
--- llvm/trunk/test/Linker/pr27044.ll (original)
+++ llvm/trunk/test/Linker/pr27044.ll Thu Mar 24 10:23:01 2016
@@ -1,8 +1,14 @@
; 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
+}
More information about the llvm-commits
mailing list