summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2016-03-24 14:58:44 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2016-03-24 14:58:44 +0000
commit42e032376898ce867355515a2af51748bc9d7668 (patch)
treebfc74b6797c1301cc2e3d94d4c6243eb9bd186d2 /llvm
parent15f8fb6f83c01606acecaad4c8a3341c29e712e0 (diff)
downloadbcm5719-llvm-42e032376898ce867355515a2af51748bc9d7668.tar.gz
bcm5719-llvm-42e032376898ce867355515a2af51748bc9d7668.zip
Fix resolution of linkonce symbols in comdats.
After comdat processing, the symbols still go through regular symbol resolution. We were not doing it for linkonce symbols since they are lazy linked. This fixes pr27044. llvm-svn: 264288
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Linker/LinkModules.cpp10
-rw-r--r--llvm/test/Linker/Inputs/pr27044.ll7
-rw-r--r--llvm/test/Linker/pr27044.ll8
3 files changed, 23 insertions, 2 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index 9ee3fb32e21..f6e0f060cc0 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -566,8 +566,14 @@ bool ModuleLinker::run() {
const Comdat *SC = GV->getComdat();
if (!SC)
continue;
- for (GlobalValue *GV2 : LazyComdatMembers[SC])
- ValuesToLink.insert(GV2);
+ for (GlobalValue *GV2 : LazyComdatMembers[SC]) {
+ GlobalValue *DGV = getLinkedToGlobal(GV2);
+ bool LinkFromSrc = true;
+ if (DGV && shouldLinkFromSource(LinkFromSrc, *DGV, *GV2))
+ return true;
+ if (LinkFromSrc)
+ ValuesToLink.insert(GV2);
+ }
}
if (shouldInternalizeLinkedSymbols()) {
diff --git a/llvm/test/Linker/Inputs/pr27044.ll b/llvm/test/Linker/Inputs/pr27044.ll
new file mode 100644
index 00000000000..907643c115d
--- /dev/null
+++ b/llvm/test/Linker/Inputs/pr27044.ll
@@ -0,0 +1,7 @@
+$foo = comdat any
+define linkonce_odr i32 @f1() comdat($foo) {
+ ret i32 1
+}
+define void @f2() comdat($foo) {
+ ret void
+}
diff --git a/llvm/test/Linker/pr27044.ll b/llvm/test/Linker/pr27044.ll
new file mode 100644
index 00000000000..58d21656f58
--- /dev/null
+++ b/llvm/test/Linker/pr27044.ll
@@ -0,0 +1,8 @@
+; RUN: llvm-link -S %s %p/Inputs/pr27044.ll -o - | FileCheck %s
+
+; CHECK: define i32 @f1() {
+; CHECK: define void @f2() comdat($foo) {
+
+define i32 @f1() {
+ ret i32 0
+}
OpenPOWER on IntegriCloud