[llvm] r258355 - Fix PR26152.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 20 14:05:50 PST 2016


Author: eugenis
Date: Wed Jan 20 16:05:50 2016
New Revision: 258355

URL: http://llvm.org/viewvc/llvm-project?rev=258355&view=rev
Log:
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.

Added:
    llvm/trunk/test/Linker/Inputs/alias-2.ll
    llvm/trunk/test/Linker/alias-2.ll
Modified:
    llvm/trunk/lib/Linker/IRMover.cpp

Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=258355&r1=258354&r2=258355&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Wed Jan 20 16:05:50 2016
@@ -1087,7 +1087,7 @@ Constant *IRLinker::linkGlobalValueProto
       return nullptr;
 
     NewGV = copyGlobalValueProto(SGV, ShouldLink);
-    if (!ForAlias)
+    if (ShouldLink || !ForAlias)
       forceRenaming(NewGV, SGV->getName());
   }
   if (ShouldLink || ForAlias) {

Added: llvm/trunk/test/Linker/Inputs/alias-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/Inputs/alias-2.ll?rev=258355&view=auto
==============================================================================
--- llvm/trunk/test/Linker/Inputs/alias-2.ll (added)
+++ llvm/trunk/test/Linker/Inputs/alias-2.ll Wed Jan 20 16:05:50 2016
@@ -0,0 +1,7 @@
+define void @B() {
+  call void @A()
+  ret void
+}
+
+declare void @A()
+

Added: llvm/trunk/test/Linker/alias-2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/alias-2.ll?rev=258355&view=auto
==============================================================================
--- llvm/trunk/test/Linker/alias-2.ll (added)
+++ llvm/trunk/test/Linker/alias-2.ll Wed Jan 20 16:05:50 2016
@@ -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
+
+ at 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()




More information about the llvm-commits mailing list