xref: /aosp_15_r20/external/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -simplifycfg < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdeclare void @Personality()
4*9880d681SAndroid Build Coastguard Workerdeclare void @f()
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test1()
7*9880d681SAndroid Build Coastguard Workerdefine void @test1() personality i8* bitcast (void ()* @Personality to i8*) {
8*9880d681SAndroid Build Coastguard Workerentry:
9*9880d681SAndroid Build Coastguard Worker  ; CHECK: call void @f()
10*9880d681SAndroid Build Coastguard Worker  invoke void @f()
11*9880d681SAndroid Build Coastguard Worker    to label %exit unwind label %unreachable.unwind
12*9880d681SAndroid Build Coastguard Workerexit:
13*9880d681SAndroid Build Coastguard Worker  ret void
14*9880d681SAndroid Build Coastguard Workerunreachable.unwind:
15*9880d681SAndroid Build Coastguard Worker  cleanuppad within none []
16*9880d681SAndroid Build Coastguard Worker  unreachable
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test2()
20*9880d681SAndroid Build Coastguard Workerdefine void @test2() personality i8* bitcast (void ()* @Personality to i8*) {
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker  invoke void @f()
23*9880d681SAndroid Build Coastguard Worker    to label %exit unwind label %catch.pad
24*9880d681SAndroid Build Coastguard Workercatch.pad:
25*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body] unwind label %unreachable.unwind
26*9880d681SAndroid Build Coastguard Worker  ; CHECK: catch.pad:
27*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT: catchswitch within none [label %catch.body] unwind to caller
28*9880d681SAndroid Build Coastguard Workercatch.body:
29*9880d681SAndroid Build Coastguard Worker  ; CHECK:      catch.body:
30*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT:   catchpad within %cs1
31*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT:   call void @f()
32*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT:   unreachable
33*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 []
34*9880d681SAndroid Build Coastguard Worker  call void @f()
35*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %unreachable
36*9880d681SAndroid Build Coastguard Workerexit:
37*9880d681SAndroid Build Coastguard Worker  ret void
38*9880d681SAndroid Build Coastguard Workerunreachable.unwind:
39*9880d681SAndroid Build Coastguard Worker  cleanuppad within none []
40*9880d681SAndroid Build Coastguard Worker  unreachable
41*9880d681SAndroid Build Coastguard Workerunreachable:
42*9880d681SAndroid Build Coastguard Worker  unreachable
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test3()
46*9880d681SAndroid Build Coastguard Workerdefine void @test3() personality i8* bitcast (void ()* @Personality to i8*) {
47*9880d681SAndroid Build Coastguard Workerentry:
48*9880d681SAndroid Build Coastguard Worker  invoke void @f()
49*9880d681SAndroid Build Coastguard Worker    to label %exit unwind label %cleanup.pad
50*9880d681SAndroid Build Coastguard Workercleanup.pad:
51*9880d681SAndroid Build Coastguard Worker  ; CHECK: %cleanup = cleanuppad within none []
52*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT: call void @f()
53*9880d681SAndroid Build Coastguard Worker  ; CHECK-NEXT: unreachable
54*9880d681SAndroid Build Coastguard Worker  %cleanup = cleanuppad within none []
55*9880d681SAndroid Build Coastguard Worker  invoke void @f()
56*9880d681SAndroid Build Coastguard Worker    to label %cleanup.ret unwind label %unreachable.unwind
57*9880d681SAndroid Build Coastguard Workercleanup.ret:
58*9880d681SAndroid Build Coastguard Worker  ; This cleanupret should be rewritten to unreachable,
59*9880d681SAndroid Build Coastguard Worker  ; and merged into the pred block.
60*9880d681SAndroid Build Coastguard Worker  cleanupret from %cleanup unwind label %unreachable.unwind
61*9880d681SAndroid Build Coastguard Workerexit:
62*9880d681SAndroid Build Coastguard Worker  ret void
63*9880d681SAndroid Build Coastguard Workerunreachable.unwind:
64*9880d681SAndroid Build Coastguard Worker  cleanuppad within none []
65*9880d681SAndroid Build Coastguard Worker  unreachable
66*9880d681SAndroid Build Coastguard Worker}
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test5()
69*9880d681SAndroid Build Coastguard Workerdefine void @test5() personality i8* bitcast (void ()* @Personality to i8*) {
70*9880d681SAndroid Build Coastguard Workerentry:
71*9880d681SAndroid Build Coastguard Worker  invoke void @f()
72*9880d681SAndroid Build Coastguard Worker          to label %exit unwind label %catch.pad
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workercatch.pad:
75*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body] unwind to caller
76*9880d681SAndroid Build Coastguard Worker
77*9880d681SAndroid Build Coastguard Workercatch.body:
78*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 []
79*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Workerexit:
82*9880d681SAndroid Build Coastguard Worker  unreachable
83*9880d681SAndroid Build Coastguard Worker}
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test6()
86*9880d681SAndroid Build Coastguard Workerdefine void @test6() personality i8* bitcast (void ()* @Personality to i8*) {
87*9880d681SAndroid Build Coastguard Workerentry:
88*9880d681SAndroid Build Coastguard Worker  invoke void @f()
89*9880d681SAndroid Build Coastguard Worker          to label %exit unwind label %catch.pad
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Workercatch.pad:
92*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body, label %catch.body] unwind to caller
93*9880d681SAndroid Build Coastguard Worker  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
94*9880d681SAndroid Build Coastguard Worker
95*9880d681SAndroid Build Coastguard Workercatch.body:
96*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
97*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
98*9880d681SAndroid Build Coastguard Worker
99*9880d681SAndroid Build Coastguard Workerexit:
100*9880d681SAndroid Build Coastguard Worker  ret void
101*9880d681SAndroid Build Coastguard Worker}
102*9880d681SAndroid Build Coastguard Worker
103*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test7()
104*9880d681SAndroid Build Coastguard Workerdefine void @test7() personality i8* bitcast (void ()* @Personality to i8*) {
105*9880d681SAndroid Build Coastguard Workerentry:
106*9880d681SAndroid Build Coastguard Worker  invoke void @f()
107*9880d681SAndroid Build Coastguard Worker          to label %exit unwind label %catch.pad
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Workercatch.pad:
110*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
111*9880d681SAndroid Build Coastguard Worker  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
112*9880d681SAndroid Build Coastguard Worker
113*9880d681SAndroid Build Coastguard Workercatch.body:
114*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
115*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
116*9880d681SAndroid Build Coastguard Worker
117*9880d681SAndroid Build Coastguard Workercatch.body2:
118*9880d681SAndroid Build Coastguard Worker  %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
119*9880d681SAndroid Build Coastguard Worker  catchret from %catch2 to label %exit
120*9880d681SAndroid Build Coastguard Worker
121*9880d681SAndroid Build Coastguard Workerexit:
122*9880d681SAndroid Build Coastguard Worker  ret void
123*9880d681SAndroid Build Coastguard Worker}
124*9880d681SAndroid Build Coastguard Worker
125*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test8()
126*9880d681SAndroid Build Coastguard Workerdefine void @test8() personality i8* bitcast (void ()* @Personality to i8*) {
127*9880d681SAndroid Build Coastguard Workerentry:
128*9880d681SAndroid Build Coastguard Worker  invoke void @f()
129*9880d681SAndroid Build Coastguard Worker          to label %exit unwind label %catch.pad
130*9880d681SAndroid Build Coastguard Worker
131*9880d681SAndroid Build Coastguard Workercatch.pad:
132*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
133*9880d681SAndroid Build Coastguard Worker  ; CHECK: catchswitch within none [label %catch.body] unwind to caller
134*9880d681SAndroid Build Coastguard Worker
135*9880d681SAndroid Build Coastguard Workercatch.body2:
136*9880d681SAndroid Build Coastguard Worker  %catch2 = catchpad within %cs1 [i8* null, i32 0, i8* null]
137*9880d681SAndroid Build Coastguard Worker  catchret from %catch2 to label %exit
138*9880d681SAndroid Build Coastguard Worker
139*9880d681SAndroid Build Coastguard Workercatch.body:
140*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
141*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
142*9880d681SAndroid Build Coastguard Worker
143*9880d681SAndroid Build Coastguard Workerexit:
144*9880d681SAndroid Build Coastguard Worker  ret void
145*9880d681SAndroid Build Coastguard Worker}
146*9880d681SAndroid Build Coastguard Worker
147*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @test9()
148*9880d681SAndroid Build Coastguard Workerdefine void @test9() personality i8* bitcast (void ()* @Personality to i8*) {
149*9880d681SAndroid Build Coastguard Workerentry:
150*9880d681SAndroid Build Coastguard Worker  invoke void @f()
151*9880d681SAndroid Build Coastguard Worker          to label %exit unwind label %catch.pad
152*9880d681SAndroid Build Coastguard Worker
153*9880d681SAndroid Build Coastguard Workercatch.pad:
154*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
155*9880d681SAndroid Build Coastguard Worker  ; CHECK: catchswitch within none [label %catch.body, label %catch.body2] unwind to caller
156*9880d681SAndroid Build Coastguard Worker
157*9880d681SAndroid Build Coastguard Workercatch.body:
158*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i8* null, i32 0, i8* null]
159*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
160*9880d681SAndroid Build Coastguard Worker
161*9880d681SAndroid Build Coastguard Workercatch.body2:
162*9880d681SAndroid Build Coastguard Worker  %catch2 = catchpad within %cs1 [i8* null, i32 64, i8* null]
163*9880d681SAndroid Build Coastguard Worker  catchret from %catch2 to label %exit
164*9880d681SAndroid Build Coastguard Worker
165*9880d681SAndroid Build Coastguard Workerexit:
166*9880d681SAndroid Build Coastguard Worker  ret void
167*9880d681SAndroid Build Coastguard Worker}
168