[PATCH] D16330: Fix PR26152

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 19 14:17:05 PST 2016


eugenis created this revision.
eugenis added a reviewer: rafael.
eugenis added a subscriber: llvm-commits.
eugenis set the repository for this revision to rL LLVM.

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.

Repository:
  rL LLVM

http://reviews.llvm.org/D16330

Files:
  lib/Linker/IRMover.cpp
  test/Linker/Inputs/alias-2.ll
  test/Linker/alias-2.ll

Index: test/Linker/alias-2.ll
===================================================================
--- /dev/null
+++ 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
+
+ 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()
Index: test/Linker/Inputs/alias-2.ll
===================================================================
--- /dev/null
+++ test/Linker/Inputs/alias-2.ll
@@ -0,0 +1,7 @@
+define void @B() {
+  call void @A()
+  ret void
+}
+
+declare void @A()
+
Index: lib/Linker/IRMover.cpp
===================================================================
--- lib/Linker/IRMover.cpp
+++ lib/Linker/IRMover.cpp
@@ -1087,7 +1087,7 @@
       return nullptr;
 
     NewGV = copyGlobalValueProto(SGV, ShouldLink);
-    if (!ForAlias)
+    if (ShouldLink || !ForAlias)
       forceRenaming(NewGV, SGV->getName());
   }
   if (ShouldLink || ForAlias) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16330.45303.patch
Type: text/x-patch
Size: 1403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160119/317edf16/attachment.bin>


More information about the llvm-commits mailing list