1 ; RUN: sed -e s/.T1:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK1 %s
2 ; RUN: sed -e s/.T2:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK2 %s
3 ; RUN: sed -e s/.T3:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK3 %s
4 ; RUN: sed -e s/.T4:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK4 %s
5 ; RUN: sed -e s/.T5:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s
6 ; RUN: sed -e s/.T6:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s
7 ; RUN: sed -e s/.T7:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK7 %s
8 ; RUN: sed -e s/.T8:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK8 %s
9 ; RUN: sed -e s/.T9:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK9 %s
10 ; RUN: sed -e s/.T10:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK10 %s
11 ; RUN: sed -e s/.T11:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK11 %s
12 ; RUN: sed -e s/.T12:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK12 %s
13 ; RUN: sed -e s/.T13:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK13 %s
14 ; RUN: sed -e s/.T14:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK14 %s
15 ; RUN: sed -e s/.T15:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK15 %s
16 ; RUN: sed -e s/.T16:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK16 %s
17 ; RUN: sed -e s/.T17:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK17 %s
18 ; RUN: sed -e s/.T18:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK18 %s
19 ; RUN: sed -e s/.T19:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK19 %s
20 ; RUN: sed -e s/.T20:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK20 %s
21 ; RUN: sed -e s/.T21:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK21 %s
25 ;T1: define void @f() {
27 ;T1: catchret from undef to label %next
28 ;T1: ; CHECK1: CatchReturnInst needs to be provided a CatchPad
33 ;T2: define void @f() {
35 ;T2: %x = cleanuppad within none []
36 ;T2: ; catchret's first operand's operator must be catchpad
37 ;T2: catchret from %x to label %entry
38 ;T2: ; CHECK2: CatchReturnInst needs to be provided a CatchPad
41 ;T3: define void @f() {
43 ;T3: cleanupret from undef unwind label %next
44 ;T3: ; CHECK3: CleanupReturnInst needs to be provided a CleanupPad
49 ;T4: define void @f() {
51 ;T4: %cs = catchswitch within none [label %next] unwind to caller
53 ;T4: %x = catchpad within %cs []
54 ;T4: ; cleanupret first operand's operator must be cleanuppad
55 ;T4: cleanupret from %x unwind to caller
56 ;T4: ; CHECK4: CleanupReturnInst needs to be provided a CleanupPad
59 ;T5: define void @f() personality void ()* @g {
63 ;T5: %cs = catchswitch within none [label %catch] unwind to caller
65 ;T5: catchpad within %cs []
68 ;T5: cleanuppad within %cs []
69 ;T5: ; CHECK5: CleanupPadInst has an invalid parent
73 ;T6: define void @f() personality void ()* @g {
77 ;T6: %cs1 = catchswitch within none [label %catch1] unwind label %catch2
78 ;T6: ; CHECK6: Block containg CatchPadInst must be jumped to only by its catchswitch
80 ;T6: catchpad within %cs1 []
83 ;T6: %cs2 = catchswitch within none [label %catch2] unwind to caller
85 ;T6: catchpad within %cs2 []
89 ;T7: define void @f() personality void ()* @g {
93 ;T7: %cs1 = catchswitch within none [label %catch1] unwind to caller
95 ;T7: catchpad within %cs1 []
98 ;T7: %cs2 = catchswitch within %cs1 [label %catch2] unwind to caller
99 ;T7: ; CHECK7: CatchSwitchInst has an invalid parent
101 ;T7: catchpad within %cs2 []
105 ;T8: define void @f() personality void ()* @g {
109 ;T8: %cs1 = catchswitch within none [ label %switch1 ] unwind to caller
110 ;T8: ; CHECK8: CatchSwitchInst handlers must be catchpads
113 ;T9: define void @f() personality void ()* @g {
117 ;T9: %cp = cleanuppad within none []
118 ;T9: invoke void @g() [ "funclet"(token %cp) ]
119 ;T9: to label %exit unwind label %cleanup
120 ;T9: ; CHECK9: EH pad cannot handle exceptions raised within it
121 ;T9: ; CHECK9-NEXT: %cp = cleanuppad within none []
122 ;T9: ; CHECK9-NEXT: invoke void @g() [ "funclet"(token %cp) ]
127 ;T10: define void @f() personality void ()* @g {
131 ;T10: %cp1 = cleanuppad within none []
134 ;T10: %cs = catchswitch within %cp1 [label %catch] unwind to caller
136 ;T10: %catchp1 = catchpad within %cs [i32 1]
139 ;T10: %cp2 = cleanuppad within %catchp1 []
142 ;T10: %cp3 = cleanuppad within %cp2 []
143 ;T10: cleanupret from %cp3 unwind label %switch
144 ;T10: ; CHECK10: EH pad cannot handle exceptions raised within it
145 ;T10: ; CHECK10-NEXT: %cs = catchswitch within %cp1 [label %catch] unwind to caller
146 ;T10: ; CHECK10-NEXT: cleanupret from %cp3 unwind label %switch
149 ;T11: define void @f() personality void ()* @g {
153 ;T11: %cp1 = cleanuppad within none []
156 ;T11: %cp2 = cleanuppad within %cp1 []
159 ;T11: %cs = catchswitch within none [label %catch] unwind label %cleanup2
160 ;T11: ; CHECK11: A single unwind edge may only enter one EH pad
161 ;T11: ; CHECK11-NEXT: %cs = catchswitch within none [label %catch] unwind label %cleanup2
163 ;T11: catchpad within %cs [i32 1]
167 ;T12: define void @f() personality void ()* @g {
171 ;T12: %cp = cleanuppad within none []
172 ;T12: cleanupret from %cp unwind label %switch
173 ;T12: ; CHECK12: A cleanupret must exit its cleanup
174 ;T12: ; CHECK12-NEXT: cleanupret from %cp unwind label %switch
176 ;T12: %cs = catchswitch within %cp [label %catch] unwind to caller
178 ;T12: catchpad within %cs [i32 1]
182 ;T13: define void @f() personality void ()* @g {
186 ;T13: %cs = catchswitch within none [label %catch] unwind label %switch
187 ;T13: ; CHECK13: EH pad cannot handle exceptions raised within it
188 ;T13: ; CHECK13-NEXT: %cs = catchswitch within none [label %catch] unwind label %switch
190 ;T13: catchpad within %cs [i32 0]
194 ;T14: define void @f() personality void ()* @g {
198 ;T14: %cp = cleanuppad within none []
201 ;T14: cleanupret from %cp unwind label %switch
203 ;T14: cleanupret from %cp unwind to caller
204 ;T14: ; CHECK14: Unwind edges out of a funclet pad must have the same unwind dest
205 ;T14: ; CHECK14-NEXT: %cp = cleanuppad within none []
206 ;T14: ; CHECK14-NEXT: cleanupret from %cp unwind label %switch
207 ;T14: ; CHECK14-NEXT: cleanupret from %cp unwind to caller
209 ;T14: %cs = catchswitch within none [label %catch] unwind to caller
211 ;T14: catchpad within %cs [i32 1]
215 ;T15: define void @f() personality void ()* @g {
219 ;T15: %cs = catchswitch within none [label %catch] unwind to caller
221 ;T15: %catch.pad = catchpad within %cs [i32 1]
222 ;T15: invoke void @g() [ "funclet"(token %catch.pad) ]
223 ;T15: to label %unreachable unwind label %target1
227 ;T15: cleanuppad within none []
230 ;T15: cleanuppad within none []
233 ;T15: %nested.pad.1 = cleanuppad within %catch.pad []
236 ;T15: %nested.pad.2 = cleanuppad within %nested.pad.1 []
237 ;T15: cleanupret from %nested.pad.2 unwind label %target2
238 ;T15: ; CHECK15: Unwind edges out of a funclet pad must have the same unwind dest
239 ;T15: ; CHECK15-NEXT: %catch.pad = catchpad within %cs [i32 1]
240 ;T15: ; CHECK15-NEXT: cleanupret from %nested.pad.2 unwind label %target2
241 ;T15: ; CHECK15-NEXT: invoke void @g() [ "funclet"(token %catch.pad) ]
242 ;T15: ; CHECK15-NEXT: to label %unreachable unwind label %target1
245 ;T16: define void @f() personality void ()* @g {
249 ;T16: %cs = catchswitch within none [label %catch] unwind to caller
251 ;T16: %catch.pad = catchpad within %cs [i32 1]
252 ;T16: invoke void @g() [ "funclet"(token %catch.pad) ]
253 ;T16: to label %unreachable unwind label %target1
254 ;T16: ; CHECK16: Unwind edges out of a catch must have the same unwind dest as the parent catchswitch
255 ;T16: ; CHECK16-NEXT: %catch.pad = catchpad within %cs [i32 1]
256 ;T16: ; CHECK16-NEXT: invoke void @g() [ "funclet"(token %catch.pad) ]
257 ;T16: ; CHECK16-NEXT: to label %unreachable unwind label %target1
258 ;T16: ; CHECK16-NEXT: %cs = catchswitch within none [label %catch] unwind to caller
262 ;T16: cleanuppad within none []
266 ;T17: define void @f() personality void ()* @g {
270 ;T17: %cs = catchswitch within none [label %catch] unwind label %target1
272 ;T17: %catch.pad = catchpad within %cs [i32 1]
273 ;T17: invoke void @g() [ "funclet"(token %catch.pad) ]
274 ;T17: to label %unreachable unwind label %target2
275 ;T17: ; CHECK17: Unwind edges out of a catch must have the same unwind dest as the parent catchswitch
276 ;T17: ; CHECK17-NEXT: %catch.pad = catchpad within %cs [i32 1]
277 ;T17: ; CHECK17-NEXT: invoke void @g() [ "funclet"(token %catch.pad) ]
278 ;T17: ; CHECK17-NEXT: to label %unreachable unwind label %target2
279 ;T17: ; CHECK17-NEXT: %cs = catchswitch within none [label %catch] unwind label %target1
283 ;T17: cleanuppad within none []
286 ;T17: cleanuppad within none []
290 ;T18: define void @f() personality void ()* @g {
292 ;T18: invoke void @g()
293 ;T18: to label %invoke.cont unwind label %left
295 ;T18: invoke void @g()
296 ;T18: to label %unreachable unwind label %right
298 ;T18: %cp.left = cleanuppad within none []
299 ;T18: invoke void @g() [ "funclet"(token %cp.left) ]
300 ;T18: to label %unreachable unwind label %right
302 ;T18: %cp.right = cleanuppad within none []
303 ;T18: invoke void @g() [ "funclet"(token %cp.right) ]
304 ;T18: to label %unreachable unwind label %left
305 ;T18: ; CHECK18: EH pads can't handle each other's exceptions
306 ;T18: ; CHECK18-NEXT: %cp.left = cleanuppad within none []
307 ;T18: ; CHECK18-NEXT: invoke void @g() [ "funclet"(token %cp.left) ]
308 ;T18: ; CHECK18-NEXT: to label %unreachable unwind label %right
309 ;T18: ; CHECK18-NEXT: %cp.right = cleanuppad within none []
310 ;T18: ; CHECK18-NEXT: invoke void @g() [ "funclet"(token %cp.right) ]
311 ;T18: ; CHECK18-NEXT: to label %unreachable unwind label %left
316 ;T19: define void @f() personality void ()* @g {
320 ;T19: %redpad = cleanuppad within none []
323 ;T19: %innerpad = cleanuppad within %redpad []
324 ;T19: invoke void @g() [ "funclet"(token %innerpad) ]
325 ;T19: to label %unreachable unwind label %green
327 ;T19: %greenswitch = catchswitch within none [label %catch] unwind label %blue
329 ;T19: catchpad within %greenswitch [i32 42]
332 ;T19: %bluepad = cleanuppad within none []
333 ;T19: cleanupret from %bluepad unwind label %red
334 ;T19: ; CHECK19: EH pads can't handle each other's exceptions
335 ;T19: ; CHECK19-NEXT: %redpad = cleanuppad within none []
336 ;T19: ; CHECK19-NEXT: invoke void @g() [ "funclet"(token %innerpad) ]
337 ;T19: ; CHECK19-NEXT: to label %unreachable unwind label %green
338 ;T19: ; CHECK19-NEXT: %greenswitch = catchswitch within none [label %catch] unwind label %blue
339 ;T19: ; CHECK19-NEXT: %bluepad = cleanuppad within none []
340 ;T19: ; CHECK19-NEXT: cleanupret from %bluepad unwind label %red
345 ;T20: define void @f() personality void ()* @g {
349 ;T20: %cs = catchswitch within none [label %catch] unwind label %catch
350 ;T20: ; CHECK20: Catchswitch cannot unwind to one of its catchpads
351 ;T20: ; CHECK20-NEXT: %cs = catchswitch within none [label %catch] unwind label %catch
352 ;T20: ; CHECK20-NEXT: %cp = catchpad within %cs [i32 4]
354 ;T20: %cp = catchpad within %cs [i32 4]
358 ;T21: define void @f() personality void ()* @g {
362 ;T21: %cs = catchswitch within none [label %catch1] unwind label %catch2
363 ;T21: ; CHECK21: Catchswitch cannot unwind to one of its catchpads
364 ;T21: ; CHECK21-NEXT: %cs = catchswitch within none [label %catch1] unwind label %catch2
365 ;T21: ; CHECK21-NEXT: %cp2 = catchpad within %cs [i32 2]
367 ;T21: %cp1 = catchpad within %cs [i32 1]
370 ;T21: %cp2 = catchpad within %cs [i32 2]