1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s
4 declare void @Personality()
7 define void @test1() personality i8* bitcast (void ()* @Personality to i8*) {
10 ; CHECK-NEXT: call void @f()
11 ; CHECK-NEXT: ret void
15 to label %exit unwind label %unreachable.unwind
19 cleanuppad within none []
23 define void @test2() personality i8* bitcast (void ()* @Personality to i8*) {
24 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: invoke void @f()
27 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
29 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
31 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] []
32 ; CHECK-NEXT: call void @f()
33 ; CHECK-NEXT: catchret from [[CATCH]] to label [[UNREACHABLE:%.*]]
35 ; CHECK-NEXT: ret void
37 ; CHECK-NEXT: unreachable
41 to label %exit unwind label %catch.pad
43 %cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind
45 %catch = catchpad within %cs1 []
47 catchret from %catch to label %unreachable
51 cleanuppad within none []
57 define void @test3() personality i8* bitcast (void ()* @Personality to i8*) {
58 ; CHECK-LABEL: @test3(
60 ; CHECK-NEXT: invoke void @f()
61 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CLEANUP_PAD:%.*]]
63 ; CHECK-NEXT: [[CLEANUP:%.*]] = cleanuppad within none []
64 ; CHECK-NEXT: call void @f()
65 ; CHECK-NEXT: unreachable
67 ; CHECK-NEXT: ret void
71 to label %exit unwind label %cleanup.pad
73 %cleanup = cleanuppad within none []
75 to label %cleanup.ret unwind label %unreachable.unwind
77 ; This cleanupret should be rewritten to unreachable,
78 ; and merged into the pred block.
79 cleanupret from %cleanup unwind label %unreachable.unwind
83 cleanuppad within none []
87 define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
88 ; CHECK-LABEL: @test5(
90 ; CHECK-NEXT: invoke void @f()
91 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
93 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
95 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] []
96 ; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
98 ; CHECK-NEXT: unreachable
102 to label %exit unwind label %catch.pad
105 %cs1 = catchswitch within none [label %catch.body] unwind to caller
108 %catch = catchpad within %cs1 []
109 catchret from %catch to label %exit
115 define void @test6() personality i8* bitcast (void ()* @Personality to i8*) {
116 ; CHECK-LABEL: @test6(
118 ; CHECK-NEXT: invoke void @f()
119 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
121 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
123 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
124 ; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
126 ; CHECK-NEXT: ret void
130 to label %exit unwind label %catch.pad
133 %cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller
136 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
137 catchret from %catch to label %exit
143 define void @test7() personality i8* bitcast (void ()* @Personality to i8*) {
144 ; CHECK-LABEL: @test7(
146 ; CHECK-NEXT: invoke void @f()
147 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
149 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
151 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
152 ; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
154 ; CHECK-NEXT: ret void
158 to label %exit unwind label %catch.pad
161 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
164 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
165 catchret from %catch to label %exit
168 %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
169 catchret from %catch2 to label %exit
175 define void @test8() personality i8* bitcast (void ()* @Personality to i8*) {
176 ; CHECK-LABEL: @test8(
178 ; CHECK-NEXT: invoke void @f()
179 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
181 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label %catch.body] unwind to caller
183 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
184 ; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
186 ; CHECK-NEXT: ret void
190 to label %exit unwind label %catch.pad
193 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
196 %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
197 catchret from %catch2 to label %exit
200 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
201 catchret from %catch to label %exit
207 define void @test9() personality i8* bitcast (void ()* @Personality to i8*) {
208 ; CHECK-LABEL: @test9(
210 ; CHECK-NEXT: invoke void @f()
211 ; CHECK-NEXT: to label [[EXIT:%.*]] unwind label [[CATCH_PAD:%.*]]
213 ; CHECK-NEXT: [[CS1:%.*]] = catchswitch within none [label [[CATCH_BODY:%.*]], label %catch.body2] unwind to caller
215 ; CHECK-NEXT: [[CATCH:%.*]] = catchpad within [[CS1]] [i8* null, i32 0, i8* null]
216 ; CHECK-NEXT: catchret from [[CATCH]] to label [[EXIT]]
217 ; CHECK: catch.body2:
218 ; CHECK-NEXT: [[CATCH2:%.*]] = catchpad within [[CS1]] [i8* null, i32 64, i8* null]
219 ; CHECK-NEXT: catchret from [[CATCH2]] to label [[EXIT]]
221 ; CHECK-NEXT: ret void
225 to label %exit unwind label %catch.pad
228 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
231 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
232 catchret from %catch to label %exit
235 %catch2 = catchpad within %cs1 [i8* null, i32 64, i8* null]
236 catchret from %catch2 to label %exit