1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s
3 declare void @Personality()
6 ; CHECK-LABEL: define void @test1()
7 define void @test1() personality i8* bitcast (void ()* @Personality to i8*) {
9 ; CHECK: call void @f()
11 to label %exit unwind label %unreachable.unwind
15 cleanuppad within none []
19 ; CHECK-LABEL: define void @test2()
20 define void @test2() personality i8* bitcast (void ()* @Personality to i8*) {
23 to label %exit unwind label %catch.pad
25 %cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind
27 ; CHECK-NEXT: catchswitch within none [label %catch.body] unwind to caller
30 ; CHECK-NEXT: catchpad within %cs1
31 ; CHECK-NEXT: call void @f()
32 ; CHECK-NEXT: unreachable
33 %catch = catchpad within %cs1 []
35 catchret from %catch to label %unreachable
39 cleanuppad within none []
45 ; CHECK-LABEL: define void @test3()
46 define void @test3() personality i8* bitcast (void ()* @Personality to i8*) {
49 to label %exit unwind label %cleanup.pad
51 ; CHECK: %cleanup = cleanuppad within none []
52 ; CHECK-NEXT: call void @f()
53 ; CHECK-NEXT: unreachable
54 %cleanup = cleanuppad within none []
56 to label %cleanup.ret unwind label %unreachable.unwind
58 ; This cleanupret should be rewritten to unreachable,
59 ; and merged into the pred block.
60 cleanupret from %cleanup unwind label %unreachable.unwind
64 cleanuppad within none []
68 ; CHECK-LABEL: define void @test5()
69 define void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
72 to label %exit unwind label %catch.pad
75 %cs1 = catchswitch within none [label %catch.body] unwind to caller
78 %catch = catchpad within %cs1 []
79 catchret from %catch to label %exit
85 ; CHECK-LABEL: define void @test6()
86 define void @test6() personality i8* bitcast (void ()* @Personality to i8*) {
89 to label %exit unwind label %catch.pad
92 %cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller
93 ; CHECK: catchswitch within none [label %catch.body] unwind to caller
96 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
97 catchret from %catch to label %exit
103 ; CHECK-LABEL: define void @test7()
104 define void @test7() personality i8* bitcast (void ()* @Personality to i8*) {
107 to label %exit unwind label %catch.pad
110 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
111 ; CHECK: catchswitch within none [label %catch.body] unwind to caller
114 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
115 catchret from %catch to label %exit
118 %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
119 catchret from %catch2 to label %exit
125 ; CHECK-LABEL: define void @test8()
126 define void @test8() personality i8* bitcast (void ()* @Personality to i8*) {
129 to label %exit unwind label %catch.pad
132 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
133 ; CHECK: catchswitch within none [label %catch.body] unwind to caller
136 %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
137 catchret from %catch2 to label %exit
140 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
141 catchret from %catch to label %exit
147 ; CHECK-LABEL: define void @test9()
148 define void @test9() personality i8* bitcast (void ()* @Personality to i8*) {
151 to label %exit unwind label %catch.pad
154 %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
155 ; CHECK: catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
158 %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
159 catchret from %catch to label %exit
162 %catch2 = catchpad within %cs1 [i8* null, i32 64, i8* null]
163 catchret from %catch2 to label %exit