blob: e43a676495da0eee00621975434e81419c619b5f [file] [log] [blame]
David Majnemer8a1c45d2015-12-12 05:38:55 +00001; 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
Joseph Tremoulet06125e52016-01-02 15:24:24 +00005; 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
Joseph Tremoulet131a4622016-01-02 15:25:25 +00008; RUN: sed -e s/.T8:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK8 %s
Joseph Tremoulete28885e2016-01-10 04:28:38 +00009; 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
Joseph Tremoulet06125e52016-01-02 15:24:24 +000014
15declare void @g()
David Majnemer8a1c45d2015-12-12 05:38:55 +000016
17;T1: define void @f() {
18;T1: entry:
19;T1: catchret from undef to label %next
20;T1: ; CHECK1: CatchReturnInst needs to be provided a CatchPad
21;T1: next:
22;T1: unreachable
23;T1: }
24
25;T2: define void @f() {
26;T2: entry:
27;T2: %x = cleanuppad within none []
28;T2: ; catchret's first operand's operator must be catchpad
29;T2: catchret from %x to label %entry
30;T2: ; CHECK2: CatchReturnInst needs to be provided a CatchPad
31;T2: }
32
33;T3: define void @f() {
34;T3: entry:
35;T3: cleanupret from undef unwind label %next
36;T3: ; CHECK3: CleanupReturnInst needs to be provided a CleanupPad
37;T3: next:
38;T3: unreachable
39;T3: }
40
41;T4: define void @f() {
42;T4: entry:
43;T4: %cs = catchswitch within none [label %next] unwind to caller
44;T4: next:
45;T4: %x = catchpad within %cs []
46;T4: ; cleanupret first operand's operator must be cleanuppad
47;T4: cleanupret from %x unwind to caller
48;T4: ; CHECK4: CleanupReturnInst needs to be provided a CleanupPad
49;T4: }
Joseph Tremoulet06125e52016-01-02 15:24:24 +000050
51;T5: define void @f() personality void ()* @g {
52;T5: entry:
53;T5: ret void
54;T5: switch:
55;T5: %cs = catchswitch within none [label %catch] unwind to caller
56;T5: catch:
57;T5: catchpad within %cs []
58;T5: unreachable
59;T5: bogus:
60;T5: cleanuppad within %cs []
61;T5: ; CHECK5: CleanupPadInst has an invalid parent
62;T5: unreachable
63;T5: }
64
65;T6: define void @f() personality void ()* @g {
66;T6: entry:
67;T6: ret void
68;T6: switch1:
69;T6: %cs1 = catchswitch within none [label %catch1] unwind label %catch2
70;T6: ; CHECK6: Block containg CatchPadInst must be jumped to only by its catchswitch
71;T6: catch1:
72;T6: catchpad within %cs1 []
73;T6: unreachable
74;T6: switch2:
75;T6: %cs2 = catchswitch within none [label %catch2] unwind to caller
76;T6: catch2:
77;T6: catchpad within %cs2 []
78;T6: unreachable
79;T6: }
80
81;T7: define void @f() personality void ()* @g {
82;T7: entry:
83;T7: ret void
84;T7: switch1:
85;T7: %cs1 = catchswitch within none [label %catch1] unwind to caller
86;T7: catch1:
87;T7: catchpad within %cs1 []
88;T7: unreachable
89;T7: switch2:
90;T7: %cs2 = catchswitch within %cs1 [label %catch2] unwind to caller
91;T7: ; CHECK7: CatchSwitchInst has an invalid parent
92;T7: catch2:
93;T7: catchpad within %cs2 []
94;T7: unreachable
95;T7: }
Joseph Tremoulet131a4622016-01-02 15:25:25 +000096
97;T8: define void @f() personality void ()* @g {
98;T8: entry:
99;T8: ret void
100;T8: switch1:
101;T8: %cs1 = catchswitch within none [ label %switch1 ] unwind to caller
102;T8: ; CHECK8: CatchSwitchInst handlers must be catchpads
103;T8: }
Joseph Tremoulete28885e2016-01-10 04:28:38 +0000104
105;T9: define void @f() personality void ()* @g {
106;T9: entry:
107;T9: ret void
108;T9: cleanup:
109;T9: %cp = cleanuppad within none []
110;T9: invoke void @g() [ "funclet"(token %cp) ]
111;T9: to label %exit unwind label %cleanup
112;T9: ; CHECK9: EH pad cannot handle exceptions raised within it
113;T9: ; CHECK9-NEXT: %cp = cleanuppad within none []
114;T9: ; CHECK9-NEXT: invoke void @g() [ "funclet"(token %cp) ]
115;T9: exit:
116;T9: ret void
117;T9: }
118
119;T10: define void @f() personality void ()* @g {
120;T10: entry:
121;T10: ret void
122;T10: cleanup1:
123;T10: %cp1 = cleanuppad within none []
124;T10: unreachable
125;T10: switch:
126;T10: %cs = catchswitch within %cp1 [label %catch] unwind to caller
127;T10: catch:
128;T10: %catchp1 = catchpad within %cs [i32 1]
129;T10: unreachable
130;T10: cleanup2:
131;T10: %cp2 = cleanuppad within %catchp1 []
132;T10: unreachable
133;T10: cleanup3:
134;T10: %cp3 = cleanuppad within %cp2 []
135;T10: cleanupret from %cp3 unwind label %switch
136;T10: ; CHECK10: EH pad cannot handle exceptions raised within it
137;T10: ; CHECK10-NEXT: %cs = catchswitch within %cp1 [label %catch] unwind to caller
138;T10: ; CHECK10-NEXT: cleanupret from %cp3 unwind label %switch
139;T10: }
140
141;T11: define void @f() personality void ()* @g {
142;T11: entry:
143;T11: ret void
144;T11: cleanup1:
145;T11: %cp1 = cleanuppad within none []
146;T11: unreachable
147;T11: cleanup2:
148;T11: %cp2 = cleanuppad within %cp1 []
149;T11: unreachable
150;T11: switch:
151;T11: %cs = catchswitch within none [label %catch] unwind label %cleanup2
152;T11: ; CHECK11: A single unwind edge may only enter one EH pad
153;T11: ; CHECK11-NEXT: %cs = catchswitch within none [label %catch] unwind label %cleanup2
154;T11: catch:
155;T11: catchpad within %cs [i32 1]
156;T11: unreachable
157;T11: }
158
159;T12: define void @f() personality void ()* @g {
160;T12: entry:
161;T12: ret void
162;T12: cleanup:
163;T12: %cp = cleanuppad within none []
164;T12: cleanupret from %cp unwind label %switch
165;T12: ; CHECK12: A cleanupret must exit its cleanup
166;T12: ; CHECK12-NEXT: cleanupret from %cp unwind label %switch
167;T12: switch:
168;T12: %cs = catchswitch within %cp [label %catch] unwind to caller
169;T12: catch:
170;T12: catchpad within %cs [i32 1]
171;T12: unreachable
172;T12: }
173
174;T13: define void @f() personality void ()* @g {
175;T13: entry:
176;T13: ret void
177;T13: switch:
178;T13: %cs = catchswitch within none [label %catch] unwind label %switch
179;T13: ; CHECK13: EH pad cannot handle exceptions raised within it
180;T13: ; CHECK13-NEXT: %cs = catchswitch within none [label %catch] unwind label %switch
181;T13: catch:
182;T13: catchpad within %cs [i32 0]
183;T13: unreachable
184;T13: }
185