[PATCH] D31443: [LTO] Do not reorder global variables unnecessarily during merging
Tobias Edler von Koch via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 14:49:13 PDT 2017
tobiasvk updated this revision to Diff 93952.
tobiasvk added a comment.
Add Rafael's suggested disclaimer to the test case.
https://reviews.llvm.org/D31443
Files:
include/llvm/IR/Module.h
test/LTO/Resolution/X86/globalorder.ll
test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
Index: include/llvm/IR/Module.h
===================================================================
--- include/llvm/IR/Module.h
+++ include/llvm/IR/Module.h
@@ -617,19 +617,19 @@
return global_objects().end();
}
- typedef concat_iterator<GlobalValue, iterator, global_iterator,
+ typedef concat_iterator<GlobalValue, global_iterator, iterator,
alias_iterator, ifunc_iterator>
global_value_iterator;
- typedef concat_iterator<const GlobalValue, const_iterator,
- const_global_iterator, const_alias_iterator,
+ typedef concat_iterator<const GlobalValue, const_global_iterator,
+ const_iterator, const_alias_iterator,
const_ifunc_iterator>
const_global_value_iterator;
iterator_range<global_value_iterator> global_values() {
- return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
+ return concat<GlobalValue>(globals(), functions(), aliases(), ifuncs());
}
iterator_range<const_global_value_iterator> global_values() const {
- return concat<const GlobalValue>(functions(), globals(), aliases(),
+ return concat<const GlobalValue>(globals(), functions(), aliases(),
ifuncs());
}
Index: test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
===================================================================
--- test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
+++ test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
@@ -19,22 +19,22 @@
; M0: define void @f()
; M1-NOT: @f()
define void @f() {
- ; M0: llvm.type.test{{.*}}metadata !"1$f50b51a12bb012bebbeff978335e34cf"
+ ; M0: llvm.type.test{{.*}}metadata !"1$761a10bdafb4c4efc0f254ab1655930a"
%p = call i1 @llvm.type.test(i8* null, metadata !0)
- ; M0: llvm.type.checked.load{{.*}}metadata !"2$f50b51a12bb012bebbeff978335e34cf"
+ ; M0: llvm.type.checked.load{{.*}}metadata !"2$761a10bdafb4c4efc0f254ab1655930a"
%q = call {i8*, i1} @llvm.type.checked.load(i8* null, i32 0, metadata !3)
ret void
}
declare i1 @llvm.type.test(i8*, metadata)
declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
!0 = distinct !{}
-; M1: !0 = !{i32 0, !"1$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !0 = !{i32 0, !"1$761a10bdafb4c4efc0f254ab1655930a"}
!1 = !{i32 0, !0}
-; M1: !1 = !{i32 1, !"1$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !1 = !{i32 1, !"1$761a10bdafb4c4efc0f254ab1655930a"}
!2 = !{i32 1, !0}
!3 = distinct !{}
-; M1: !2 = !{i32 0, !"2$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !2 = !{i32 0, !"2$761a10bdafb4c4efc0f254ab1655930a"}
!4 = !{i32 0, !3}
Index: test/LTO/Resolution/X86/globalorder.ll
===================================================================
--- /dev/null
+++ test/LTO/Resolution/X86/globalorder.ll
@@ -0,0 +1,31 @@
+; Test the order of global variables during LTO merging. Note that
+; this can change at any time, for any reason, or no reason whatsoever.
+; If you are depending on this order for correctness, your code has a
+; bug and should be fixed.
+;
+; RUN: llvm-as %s -o %t.bc
+; RUN: llvm-lto2 %t.bc -O0 -save-temps -o %t.o -r %t.bc,var1,px -r %t.bc,var2,px -r %t.bc,var3,px -r %t.bc,var4,px -r %t.bc,foo,px
+; RUN: llvm-dis -o - %t.o.0.0.preopt.bc | FileCheck %s
+;
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: @var1 =
+ at var1 = global i32 0, align 4
+; CHECK: @var2 =
+ at var2 = global i32 0, align 4
+; CHECK: @var3 =
+ at var3 = global i32* @var1, align 4
+; CHECK: @var4 =
+ at var4 = global i32* @var2, align 4
+
+define i32 @foo() {
+entry:
+ %0 = load i32*, i32** @var3, align 4
+ %1 = load i32, i32* %0, align 4
+ %2 = load i32*, i32** @var4, align 4
+ %3 = load i32, i32* %2, align 4
+ %add = add nsw i32 %3, %1
+ ret i32 %add
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31443.93952.patch
Type: text/x-patch
Size: 3871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170403/de4164cb/attachment.bin>
More information about the llvm-commits
mailing list