[PATCH] D49316: [LTO] Fix linking with an alias defined using another alias.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 13 15:04:09 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337053: [LTO] Fix linking with an alias defined using another alias. (authored by efriedma, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49316?vs=155458&id=155511#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49316

Files:
  llvm/trunk/lib/Linker/IRMover.cpp
  llvm/trunk/test/LTO/Resolution/X86/Inputs/alias-alias-1.ll
  llvm/trunk/test/LTO/Resolution/X86/alias-alias.ll


Index: llvm/trunk/test/LTO/Resolution/X86/alias-alias.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/alias-alias.ll
+++ llvm/trunk/test/LTO/Resolution/X86/alias-alias.ll
@@ -0,0 +1,27 @@
+; RUN: llvm-as %s -o %t1.o
+; RUN: llvm-as %p/Inputs/alias-alias-1.ll -o %t2.o
+; RUN: llvm-lto2 run -o %t3.o %t1.o %t2.o -r %t2.o,a, -r %t2.o,d,px -r %t1.o,a,p -r %t1.o,c,p -r %t1.o,b -save-temps
+; RUN: llvm-dis < %t3.o.0.0.preopt.bc -o - | FileCheck %s
+; RUN: FileCheck --check-prefix=RES %s < %t3.o.resolution.txt
+
+; CHECK-NOT: alias
+; CHECK: @c = global i32 1
+; CHECK-NEXT: @d = global i32* @a
+; CHECK-EMPTY:
+; CHECK-NEXT: @a = weak alias i32, i32* @b
+; CHECK-NEXT: @b = internal alias i32, i32* @c
+
+; RES: 1.o{{$}}
+; RES-NEXT: {{^}}-r={{.*}}1.o,c,p{{$}}
+; RES-NEXT: {{^}}-r={{.*}}1.o,a,p{{$}}
+; RES-NEXT: {{^}}-r={{.*}}1.o,b,{{$}}
+; RES-NEXT: 2.o{{$}}
+; RES-NEXT: {{^}}-r={{.*}}2.o,a,{{$}}
+; RES-NEXT: {{^}}-r={{.*}}2.o,d,px{{$}}
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at a = weak alias i32, i32* @b
+ at b = alias i32, i32* @c
+ at c = global i32 1
Index: llvm/trunk/test/LTO/Resolution/X86/Inputs/alias-alias-1.ll
===================================================================
--- llvm/trunk/test/LTO/Resolution/X86/Inputs/alias-alias-1.ll
+++ llvm/trunk/test/LTO/Resolution/X86/Inputs/alias-alias-1.ll
@@ -0,0 +1,5 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at a = external global i32
+ at d = global i32* @a
Index: llvm/trunk/lib/Linker/IRMover.cpp
===================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp
+++ llvm/trunk/lib/Linker/IRMover.cpp
@@ -948,7 +948,7 @@
     if (DoneLinkingBodies)
       return nullptr;
 
-    NewGV = copyGlobalValueProto(SGV, ShouldLink);
+    NewGV = copyGlobalValueProto(SGV, ShouldLink || ForAlias);
     if (ShouldLink || !ForAlias)
       forceRenaming(NewGV, SGV->getName());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49316.155511.patch
Type: text/x-patch
Size: 2074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180713/dd2351c3/attachment.bin>


More information about the llvm-commits mailing list