]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Other/opt-bisect-legacy-pass-manager.ll
Vendor import of llvm trunk r338150:
[FreeBSD/FreeBSD.git] / test / Other / opt-bisect-legacy-pass-manager.ll
1 ; This file verifies the behavior of the OptBisect class, which is used to
2 ; diagnose optimization related failures.  The tests check various
3 ; invocations that result in different sets of optimization passes that
4 ; are run in different ways.
5 ;
6 ; This set of tests exercises the legacy pass manager interface to the OptBisect
7 ; class.  Because the exact set of optimizations that will be run may
8 ; change over time, these tests are written in a more general manner than the
9 ; corresponding tests for the new pass manager.
10 ;
11 ; Don't use NEXT checks or hard-code pass numbering so that this won't fail if
12 ; new passes are inserted.
13
14
15 ; Verify that the file can be compiled to an object file at -O3 with all
16 ; skippable passes skipped.
17
18 ; REQUIRES: default_triple
19 ; RUN: opt -O3 -opt-bisect-limit=0 < %s | llc -O3 -opt-bisect-limit=0
20
21
22 ; Verify that no skippable passes are run with -opt-bisect-limit=0.
23
24 ; RUN: opt -disable-output -disable-verify -O3 -opt-bisect-limit=0 %s 2>&1 \
25 ; RUN:     | FileCheck %s --check-prefix=CHECK-SKIP-ALL
26 ; CHECK-SKIP-ALL: BISECT: NOT running pass ({{[0-9]+}})
27 ; CHECK-SKIP-ALL-NOT: BISECT: running pass ({{[0-9]+}})
28
29
30 ; Verify that no passes run at -O0 are skipped
31 ; RUN: opt -opt-bisect-limit=0 < %s 2>&1 | FileCheck %s --check-prefix=OPTBISECT-O0
32 ; OPTBISECT-O0-NOT: BISECT: NOT running
33
34 ; FIXME: There are still some AMDGPU passes being skipped that run at -O0.
35 ; XFAIL: r600, amdgcn
36
37 ; Verify that we can use the opt-bisect-helper.py script (derived from
38 ; utils/bisect) to locate the optimization that inlines the call to
39 ; f2() in f3().
40
41 ; RUN: '%python' %S/opt-bisect-helper.py --start=0 --end=256 --optcmd=opt \
42 ; RUN:         --filecheckcmd=FileCheck --test=%s \
43 ; RUN:         --prefix=CHECK-BISECT-INLINE-HELPER \
44 ; RUN:         | FileCheck %s --check-prefix=CHECK-BISECT-INLINE-RESULT
45 ; The helper script uses this to find the optimization that inlines the call.
46 ; CHECK-BISECT-INLINE-HELPER: call i32 @f2()
47 ; These checks verifies that the optimization was found.
48 ; CHECK-BISECT-INLINE-RESULT-NOT: Last good count: 0
49 ; CHECK-BISECT-INLINE-RESULT: Last good count: {{[0-9]+}}
50
51
52 ; Test a module pass.
53
54 ; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=-1 %s \
55 ; RUN:     2>&1 | FileCheck %s --check-prefix=CHECK-DEADARG
56 ; CHECK-DEADARG: BISECT: running pass ({{[0-9]+}}) Dead Argument Elimination on module
57
58 ; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=0 %s \
59 ; RUN:     2>&1 | FileCheck %s --check-prefix=CHECK-NOT-DEADARG
60 ; CHECK-NOT-DEADARG: BISECT: NOT running pass ({{[0-9]+}}) Dead Argument Elimination on module
61
62
63 ; Test an SCC pass.
64
65 ; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=-1 %s \
66 ; RUN:     2>&1 | FileCheck %s --check-prefix=CHECK-INLINE
67 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>)
68 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g)
69 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1)
70 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2)
71 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3)
72 ; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>)
73
74 ; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=0 %s \
75 ; RUN:     2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE
76 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>)
77 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g)
78 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1)
79 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2)
80 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3)
81 ; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>)
82
83
84 ; Test a function pass.
85
86 ; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=-1 \
87 ; RUN:     %s 2>&1 | FileCheck %s --check-prefix=CHECK-EARLY-CSE
88 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f1)
89 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f2)
90 ; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f3)
91
92 ; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=0 %s \
93 ; RUN:     2>&1 | FileCheck %s --check-prefix=CHECK-NOT-EARLY-CSE
94 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f1)
95 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f2)
96 ; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f3)
97
98
99 ; Test a loop pass.
100
101 ; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=-1 \
102 ; RUN:      %s 2>&1 | FileCheck %s --check-prefix=CHECK-LOOP-REDUCE
103 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
104 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
105 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
106 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
107 ; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop
108
109 ; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=0 \
110 ; RUN:     %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-LOOP-REDUCE
111 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
112 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
113 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
114 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
115 ; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop
116
117
118 declare i32 @g()
119
120 define void @f1() {
121 entry:
122   br label %loop.0
123 loop.0:
124   br i1 undef, label %loop.0.0, label %loop.1
125 loop.0.0:
126   br i1 undef, label %loop.0.0, label %loop.0.1
127 loop.0.1:
128   br i1 undef, label %loop.0.1, label %loop.0
129 loop.1:
130   br i1 undef, label %loop.1, label %loop.1.bb1
131 loop.1.bb1:
132   br i1 undef, label %loop.1, label %loop.1.bb2
133 loop.1.bb2:
134   br i1 undef, label %end, label %loop.1.0
135 loop.1.0:
136   br i1 undef, label %loop.1.0, label %loop.1
137 end:
138   ret void
139 }
140
141 define i32 @f2() {
142 entry:
143   ret i32 0
144 }
145
146 define i32 @f3() {
147 entry:
148   %temp = call i32 @g()
149   %icmp = icmp ugt i32 %temp, 2
150   br i1 %icmp, label %bb.true, label %bb.false
151 bb.true:
152   %temp2 = call i32 @f2()
153   ret i32 %temp2
154 bb.false:
155   ret i32 0
156 }
157
158 ; This function is here to verify that opt-bisect can skip all passes for
159 ; functions that contain lifetime intrinsics.
160 define void @f4() {
161 entry:
162   %i = alloca i32, align 4
163   %tmp = bitcast i32* %i to i8*
164   call void @llvm.lifetime.start(i64 4, i8* %tmp)
165   br label %for.cond
166
167 for.cond:
168   br i1 undef, label %for.body, label %for.end
169
170 for.body:
171   br label %for.cond
172
173 for.end:
174   ret void
175 }
176
177 declare void @llvm.lifetime.start(i64, i8* nocapture)
178