summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-20 22:05:50 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-20 22:05:50 +0000
commit9fb70f53cee45cf1cfb74070d2aaadcb8434b94b (patch)
tree2e7493791f7c0a37854aa5ee8ad5c4c668b22db4
parentb640415f9bcc3f6c824855199126c53f3488f032 (diff)
downloadbcm5719-llvm-9fb70f53cee45cf1cfb74070d2aaadcb8434b94b.tar.gz
bcm5719-llvm-9fb70f53cee45cf1cfb74070d2aaadcb8434b94b.zip
Fix PR26152.
Fix the condition for when the new global takes over the name of the existing one to be the negation of the condition for the new global to get internal linkage. llvm-svn: 258355
-rw-r--r--llvm/lib/Linker/IRMover.cpp2
-rw-r--r--llvm/test/Linker/Inputs/alias-2.ll7
-rw-r--r--llvm/test/Linker/alias-2.ll24
3 files changed, 32 insertions, 1 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index de368498ef2..9fdf8ca6b24 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1087,7 +1087,7 @@ Constant *IRLinker::linkGlobalValueProto(GlobalValue *SGV, bool ForAlias) {
return nullptr;
NewGV = copyGlobalValueProto(SGV, ShouldLink);
- if (!ForAlias)
+ if (ShouldLink || !ForAlias)
forceRenaming(NewGV, SGV->getName());
}
if (ShouldLink || ForAlias) {
diff --git a/llvm/test/Linker/Inputs/alias-2.ll b/llvm/test/Linker/Inputs/alias-2.ll
new file mode 100644
index 00000000000..03c1d91fe6b
--- /dev/null
+++ b/llvm/test/Linker/Inputs/alias-2.ll
@@ -0,0 +1,7 @@
+define void @B() {
+ call void @A()
+ ret void
+}
+
+declare void @A()
+
diff --git a/llvm/test/Linker/alias-2.ll b/llvm/test/Linker/alias-2.ll
new file mode 100644
index 00000000000..8875aa76455
--- /dev/null
+++ b/llvm/test/Linker/alias-2.ll
@@ -0,0 +1,24 @@
+; RUN: llvm-link %s %S/Inputs/alias-2.ll -S -o - | FileCheck %s
+; RUN: llvm-link %S/Inputs/alias-2.ll %s -S -o - | FileCheck %s
+
+; Test the fix for PR26152, where A from the second module is
+; erroneously renamed to A.1 and not linked to the declaration from
+; the first module
+
+@C = alias void (), void ()* @A
+
+define void @D() {
+ call void @C()
+ ret void
+}
+
+define void @A() {
+ ret void
+}
+
+; CHECK-DAG: @C = alias void (), void ()* @A
+; CHECK-DAG: define void @B()
+; CHECK-DAG: call void @A()
+; CHECK-DAG: define void @D()
+; CHECK-DAG: call void @C()
+; CHECK-DAG: define void @A()
OpenPOWER on IntegriCloud