[PATCH] D20586: IRLinker: fix double scheduling of mapping a global value because of an alias
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 14:07:07 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270757: IRLinker: fix double scheduling of mapping a global value because of an alias (authored by mehdi_amini).
Changed prior to commit:
http://reviews.llvm.org/D20586?vs=58285&id=58505#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20586
Files:
llvm/trunk/lib/Linker/IRMover.cpp
llvm/trunk/test/Linker/alias-3.ll
Index: llvm/trunk/test/Linker/alias-3.ll
===================================================================
--- llvm/trunk/test/Linker/alias-3.ll
+++ llvm/trunk/test/Linker/alias-3.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-link %s -S -o - | FileCheck %s
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.9"
+
+; CHECK-DAG: @A = internal constant i8 1
+; CHECK-DAG: @B = alias i8, i8* @A
+; CHECK-DAG: @C = global [2 x i8*] [i8* @A, i8* @B]
+
+ at A = internal constant i8 1
+ at B = alias i8, i8* @A
+ at C = global [2 x i8*] [i8* @A, i8* @B]
+
+
Index: llvm/trunk/lib/Linker/IRMover.cpp
===================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp
+++ llvm/trunk/lib/Linker/IRMover.cpp
@@ -557,6 +557,17 @@
return;
}
+ // When linking a global for an alias, it will always be linked. However we
+ // need to check if it was not already scheduled to satify a reference from a
+ // regular global value initializer. We know if it has been schedule if the
+ // "New" GlobalValue that is mapped here for the alias is the same as the one
+ // already mapped. If there is an entry in the ValueMap but the value is
+ // different, it means that the value already had a definition in the
+ // destination module (linkonce for instance), but we need a new definition
+ // for the alias ("New" will be different.
+ if (ForAlias && ValueMap.lookup(Old) == New)
+ return;
+
if (ForAlias || shouldLink(New, *Old))
linkGlobalValueBody(*New, *Old);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20586.58505.patch
Type: text/x-patch
Size: 1549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/56a44927/attachment.bin>
More information about the llvm-commits
mailing list