Skip to content

Commit 7307736

Browse files
authored
llvm-reduce: Avoid using constantdata uselistorder in thinlto test (#136288)
This also demonstrates a bug that's a consequence of the two different paths for the single and multithreaded cases. The parallel path goes through bitcode serialization and does preserve the uselistorder. It therefore survives and we can observe a reduced uselistorder with deleted instructions. In the CloneModule case, nothing is reduced.
1 parent 63b8f1c commit 7307736

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,48 @@
1-
; RUN: opt --thinlto-bc --thinlto-split-lto-unit %s -o %t.0
2-
; RUN: llvm-reduce -write-tmp-files-as-bitcode --delta-passes=instructions %t.0 -o %t.1 \
1+
; RUN: opt --preserve-bc-uselistorder --thinlto-bc --thinlto-split-lto-unit %s -o %t.0
2+
3+
; RUN: llvm-reduce -j=2 --delta-passes=instructions %t.0 -o %t.1 \
34
; RUN: --test %python --test-arg %p/Inputs/llvm-dis-and-filecheck.py --test-arg llvm-dis --test-arg FileCheck --test-arg --check-prefix=INTERESTING --test-arg %s
45
; RUN: llvm-dis --preserve-ll-uselistorder %t.1 -o %t.2
5-
; RUN: FileCheck --check-prefix=RESULT %s < %t.2
6-
7-
define i32 @func(i32 %arg0, i32 %arg1) {
8-
entry:
9-
%add0 = add i32 %arg0, 0
10-
%add1 = add i32 %add0, 0
11-
%add2 = add i32 %add1, 0
12-
%add3 = add i32 %arg1, 0
13-
%add4 = add i32 %add2, %add3
14-
ret i32 %add4
6+
; RUN: FileCheck --check-prefixes=RESULT,RESULT-PARALLEL %s < %t.2
7+
8+
; FIXME: The single thread path uses CloneModule, which does not
9+
; preserve uselistorder. Consequently it is incapable of reducing
10+
; anything a case that depends on uselistorder.
11+
12+
; RUN: llvm-reduce -j=1 --delta-passes=instructions %t.0 -o %t.3 \
13+
; RUN: --test %python --test-arg %p/Inputs/llvm-dis-and-filecheck.py --test-arg llvm-dis --test-arg FileCheck --test-arg --check-prefix=INTERESTING --test-arg %s
14+
; RUN: llvm-dis --preserve-ll-uselistorder %t.3 -o %t.4
15+
; RUN: FileCheck --check-prefixes=RESULT,RESULT-SINGLE %s < %t.4
16+
17+
@gv0 = external global [0 x i8]
18+
19+
; RESULT-LABEL: @func(
20+
; RESULT-PARALLEL-NEXT: %gep0 = getelementptr i8, ptr @gv0, i32 %arg0
21+
; RESULT-PARALLEL-NEXT: %gep1 = getelementptr i8, ptr @gv0, i32 %arg1
22+
; RESULT-PARALLEL-NEXT: ret void
23+
24+
; RESULT-SINGLE: ptr @gv0
25+
; RESULT-SINGLE: ptr @gv0
26+
; RESULT-SINGLE: ptr @gv0
27+
; RESULT-SINGLE: ptr @gv0
28+
; RESULT-SINGLE: ptr @gv0
29+
define void @func(i32 %arg0, i32 %arg1, i32 %arg2, i32 %arg3) {
30+
%gep0 = getelementptr i8, ptr @gv0, i32 %arg0
31+
%gep1 = getelementptr i8, ptr @gv0, i32 %arg1
32+
%gep2 = getelementptr i8, ptr @gv0, i32 %arg2
33+
%gep3 = getelementptr i8, ptr @gv0, i32 %arg3
34+
store i32 0, ptr %gep0
35+
store i32 0, ptr %gep1
36+
store i32 0, ptr %gep2
37+
store i32 0, ptr %gep3
38+
store i32 0, ptr @gv0
39+
ret void
1540
}
1641

17-
; INTERESTING: uselistorder i32 0
18-
; RESULT: uselistorder i32 0, { 0, 2, 1 }
19-
uselistorder i32 0, { 3, 2, 1, 0 }
42+
; INTERESTING: uselistorder ptr
43+
44+
; RESULT: uselistorder directives
45+
; RESULT-PARALLEL: uselistorder ptr @gv0, { 1, 0 }
46+
; RESULT-SINGLE: uselistorder ptr @gv0, { 3, 4, 2, 1, 0 }
47+
48+
uselistorder ptr @gv0, { 3, 4, 2, 1, 0 }

0 commit comments

Comments
 (0)