1 ; RUN: opt -print-mustexecute -analyze 2>&1 < %s | FileCheck %s --check-prefix=ME
2 ; RUN: opt -print-must-be-executed-contexts -analyze 2>&1 < %s | FileCheck %s --check-prefix=MBEC
4 ; void simple_conditional(int c) {
17 ; Start Instruction | Visit Set
20 ; C | A, B, C, D, E, F
21 ; D | A, B, C, D, E, F
26 ; FIXME: We miss the B -> E and backward exploration.
28 ; There are no loops so print-mustexec will not do anything.
31 define void @simple_conditional(i32 %arg) {
34 ; MBEC: -- Explore context of: call void @A()
35 ; MBEC-NEXT: [F: simple_conditional] call void @A()
36 ; MBEC-NEXT: [F: simple_conditional] call void @B()
37 ; MBEC-NEXT: [F: simple_conditional] %tmp = icmp eq i32 %arg, 0
38 ; MBEC-NEXT: [F: simple_conditional] br i1 %tmp, label %bb2, label %bb1
42 ; MBEC: -- Explore context of: call void @B()
43 ; MBEC-NEXT: [F: simple_conditional] call void @B()
44 ; MBEC-NEXT: [F: simple_conditional] %tmp = icmp eq i32 %arg, 0
45 ; MBEC-NEXT: [F: simple_conditional] br i1 %tmp, label %bb2, label %bb1
47 ; MBEC: -- Explore context of: %tmp
49 %tmp = icmp eq i32 %arg, 0
50 br i1 %tmp, label %bb2, label %bb1
54 ; MBEC: -- Explore context of: call void @C()
55 ; MBEC-NEXT: [F: simple_conditional] call void @C()
56 ; MBEC-NEXT: [F: simple_conditional] call void @D()
57 ; MBEC-NEXT: [F: simple_conditional] br label %bb2
58 ; MBEC-NEXT: [F: simple_conditional] call void @E()
59 ; MBEC-NEXT: [F: simple_conditional] call void @F()
63 ; MBEC: -- Explore context of: call void @D()
64 ; MBEC-NEXT: [F: simple_conditional] call void @D()
65 ; MBEC-NEXT: [F: simple_conditional] br label %bb2
66 ; MBEC-NEXT: [F: simple_conditional] call void @E()
67 ; MBEC-NEXT: [F: simple_conditional] call void @F()
69 ; MBEC: -- Explore context of: br
73 bb2: ; preds = %bb, %bb1
75 ; MBEC: -- Explore context of: call void @E()
76 ; MBEC-NEXT: [F: simple_conditional] call void @E()
77 ; MBEC-NEXT: [F: simple_conditional] call void @F()
80 call void @F() ; might not return!
81 ; MBEC: -- Explore context of: call void @F()
82 ; MBEC-NEXT: [F: simple_conditional] call void @F()
86 ; MBEC: -- Explore context of: call void @G()
87 ; MBEC-NEXT: [F: simple_conditional] call void @G()
88 ; MBEC-NEXT: [F: simple_conditional] ret void
90 ; MBEC: -- Explore context of: ret
96 ; void complex_loops_and_control(int c, int d) {
111 ; } while (++c == d);
118 ; Start Instruction | Visit Set
128 ; ME: define void @complex_loops_and_control
129 define void @complex_loops_and_control(i32 %arg, i32 %arg1) {
135 ; MBEC: -- Explore context of: call void @A()
136 ; MBEC-NEXT: [F: complex_loops_and_control] call void @A()
137 ; MBEC-NEXT: [F: complex_loops_and_control] br label %bb2
138 ; MBEC-NEXT: [F: complex_loops_and_control] %.0 = phi i32 [ %arg, %bb ], [ %.0.be, %.backedge ]
139 ; MBEC-NEXT: [F: complex_loops_and_control] call void @B()
140 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp = add nsw i32 %.0, 1
141 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp3 = icmp eq i32 %tmp, %arg1
142 ; MBEC-NEXT: [F: complex_loops_and_control] br i1 %tmp3, label %bb4, label %bb5
144 ; MBEC: -- Explore context of: br
147 bb2: ; preds = %.backedge, %bb
148 %.0 = phi i32 [ %arg, %bb ], [ %.0.be, %.backedge ]
150 ; ME: call void @B() ; (mustexec in: bb2)
151 ; MBEC: -- Explore context of: call void @B()
152 ; MBEC-NEXT: [F: complex_loops_and_control] call void @B()
153 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp = add nsw i32 %.0, 1
154 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp3 = icmp eq i32 %tmp, %arg1
155 ; MBEC-NEXT: [F: complex_loops_and_control] br i1 %tmp3, label %bb4, label %bb5
157 ; MBEC: -- Explore context of: %tmp
158 %tmp = add nsw i32 %.0, 1
159 %tmp3 = icmp eq i32 %tmp, %arg1
160 br i1 %tmp3, label %bb4, label %bb5
167 ; FIXME: Missing A and B (backward)
168 ; MBEC: -- Explore context of: call void @C()
169 ; MBEC-NEXT: [F: complex_loops_and_control] call void @C()
170 ; MBEC-NEXT: [F: complex_loops_and_control] br label %bb5
171 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp6 = add nsw i32 %.0, 2
172 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp7 = icmp eq i32 %tmp6, %arg1
173 ; MBEC-NEXT: [F: complex_loops_and_control] br i1 %tmp7, label %bb8, label %bb9
175 ; MBEC: -- Explore context of: br
178 bb5: ; preds = %bb4, %bb2
179 %tmp6 = add nsw i32 %.0, 2
180 %tmp7 = icmp eq i32 %tmp6, %arg1
181 br i1 %tmp7, label %bb8, label %bb9
186 .backedge: ; preds = %bb8, %bb22
187 %.0.be = phi i32 [ %tmp6, %bb8 ], [ %.lcssa, %bb22 ]
195 ; FIXME: Missing A and B (backward)
196 ; MBEC: -- Explore context of: call void @D()
197 ; MBEC-NEXT: [F: complex_loops_and_control] call void @D()
198 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp10 = add nsw i32 %.0, 3
199 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp11 = icmp eq i32 %tmp10, %arg1
200 ; MBEC-NEXT: [F: complex_loops_and_control] br i1 %tmp11, label %bb12, label %bb13
202 ; MBEC: -- Explore context of: %tmp10
203 %tmp10 = add nsw i32 %.0, 3
204 %tmp11 = icmp eq i32 %tmp10, %arg1
205 br i1 %tmp11, label %bb12, label %bb13
213 bb14: ; preds = %bb19, %bb13
214 %.1 = phi i32 [ %tmp10, %bb13 ], [ %tmp20, %bb19 ]
215 %tmp15 = add nsw i32 %.1, 1
216 %tmp16 = icmp eq i32 %tmp15, %arg1
217 br i1 %tmp16, label %bb17, label %bb18
219 bb17: ; preds = %bb14
222 bb18: ; preds = %bb14
227 ; FIXME: Missing A, B, and D (backward), as well as F
228 ; MBEC: -- Explore context of: call void @E()
229 ; MBEC-NEXT: [F: complex_loops_and_control] call void @E()
230 ; MBEC-NEXT: [F: complex_loops_and_control] br label %bb19
231 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp20 = add nsw i32 %.1, 2
232 ; MBEC-NEXT: [F: complex_loops_and_control] %tmp21 = icmp eq i32 %tmp20, %arg1
233 ; MBEC-NEXT: [F: complex_loops_and_control] br i1 %tmp21, label %bb14, label %bb22
235 ; MBEC: -- Explore context of: br
238 bb19: ; preds = %bb18, %bb17
239 %tmp20 = add nsw i32 %.1, 2
240 %tmp21 = icmp eq i32 %tmp20, %arg1
241 br i1 %tmp21, label %bb14, label %bb22
243 bb22: ; preds = %bb19
244 %.lcssa = phi i32 [ %tmp20, %bb19 ]
249 ; FIXME: Missing A, B, and D (backward)
250 ; MBEC: -- Explore context of: call void @F()
251 ; MBEC-NEXT: [F: complex_loops_and_control] call void @F()
253 ; MBEC: -- Explore context of: br
256 bb23: ; preds = %bb12
261 ; FIXME: Missing A, B, and D (backward)
262 ; MBEC: -- Explore context of: call void @G()
263 ; MBEC-NEXT: [F: complex_loops_and_control] call void @G()
264 ; MBEC-NEXT: [F: complex_loops_and_control] ret void
266 ; MBEC: -- Explore context of: ret
270 declare void @A() nounwind willreturn
272 declare void @B() nounwind willreturn
274 declare void @C() nounwind willreturn
276 declare void @D() nounwind willreturn
278 declare void @E() nounwind willreturn
280 declare void @F() nounwind
282 declare void @G() nounwind willreturn