1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 @T1 = external constant i32
4 @T2 = external constant i32
5 @T3 = external constant i32
7 declare i32 @generic_personality(i32, i64, i8*, i8*)
8 declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*)
9 declare i32 @__objc_personality_v0(i32, i64, i8*, i8*)
10 declare i32 @__C_specific_handler(...)
14 define void @foo_generic() personality i32 (i32, i64, i8*, i8*)* @generic_personality {
15 ; CHECK-LABEL: @foo_generic(
17 to label %cont.a unwind label %lpad.a
20 to label %cont.b unwind label %lpad.b
23 to label %cont.c unwind label %lpad.c
26 to label %cont.d unwind label %lpad.d
29 to label %cont.e unwind label %lpad.e
32 to label %cont.f unwind label %lpad.f
35 to label %cont.g unwind label %lpad.g
38 to label %cont.h unwind label %lpad.h
41 to label %cont.i unwind label %lpad.i
46 %a = landingpad { i8*, i32 }
52 ; CHECK: %a = landingpad
55 ; CHECK-NEXT: unreachable
58 %b = landingpad { i8*, i32 }
59 filter [0 x i32*] zeroinitializer
62 ; CHECK: %b = landingpad
64 ; CHECK-NEXT: unreachable
67 %c = landingpad { i8*, i32 }
69 filter [1 x i32*] [i32* @T1]
72 ; Caught types should not be removed from filters
73 ; CHECK: %c = landingpad
74 ; CHECK-NEXT: catch i32* @T1
75 ; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
76 ; CHECK-NEXT: catch i32* @T2
77 ; CHECK-NEXT: unreachable
80 %d = landingpad { i8*, i32 }
81 filter [3 x i32*] zeroinitializer
83 ; CHECK: %d = landingpad
84 ; CHECK-NEXT: filter [1 x i32*] zeroinitializer
85 ; CHECK-NEXT: unreachable
88 %e = landingpad { i8*, i32 }
90 filter [3 x i32*] [i32* @T1, i32* @T2, i32* @T2]
92 ; Caught types should not be removed from filters
93 ; CHECK: %e = landingpad
94 ; CHECK-NEXT: catch i32* @T1
95 ; CHECK-NEXT: filter [2 x i32*] [i32* @T1, i32* @T2]
96 ; CHECK-NEXT: unreachable
99 %f = landingpad { i8*, i32 }
100 filter [2 x i32*] [i32* @T2, i32* @T1]
101 filter [1 x i32*] [i32* @T1]
103 ; CHECK: %f = landingpad
104 ; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
105 ; CHECK-NEXT: unreachable
108 %g = landingpad { i8*, i32 }
109 filter [1 x i32*] [i32* @T1]
111 filter [2 x i32*] [i32* @T2, i32* @T1]
113 ; CHECK: %g = landingpad
114 ; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
115 ; CHECK-NEXT: catch i32* @T3
116 ; CHECK-NEXT: unreachable
119 %h = landingpad { i8*, i32 }
120 filter [2 x i32*] [i32* @T1, i32* null]
121 filter [1 x i32*] zeroinitializer
123 ; CHECK: %h = landingpad
124 ; CHECK-NEXT: filter [1 x i32*] zeroinitializer
125 ; CHECK-NEXT: unreachable
128 %i = landingpad { i8*, i32 }
130 filter [0 x i32*] zeroinitializer
132 ; CHECK: %i = landingpad
134 ; CHECK-NEXT: unreachable
137 define void @foo_cxx() personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 {
138 ; CHECK-LABEL: @foo_cxx(
140 to label %cont.a unwind label %lpad.a
143 to label %cont.b unwind label %lpad.b
146 to label %cont.c unwind label %lpad.c
149 to label %cont.d unwind label %lpad.d
154 %a = landingpad { i8*, i32 }
158 ; CHECK: %a = landingpad
160 ; CHECK-NEXT: unreachable
163 %b = landingpad { i8*, i32 }
164 filter [1 x i32*] zeroinitializer
166 ; CHECK: %b = landingpad
167 ; CHECK-NEXT: cleanup
168 ; CHECK-NEXT: unreachable
171 %c = landingpad { i8*, i32 }
172 filter [2 x i32*] [i32* @T1, i32* null]
174 ; CHECK: %c = landingpad
175 ; CHECK-NEXT: cleanup
176 ; CHECK-NEXT: unreachable
179 %d = landingpad { i8*, i32 }
183 ; CHECK: %d = landingpad
185 ; CHECK-NEXT: unreachable
188 define void @foo_objc() personality i32 (i32, i64, i8*, i8*)* @__objc_personality_v0 {
189 ; CHECK-LABEL: @foo_objc(
191 to label %cont.a unwind label %lpad.a
194 to label %cont.b unwind label %lpad.b
197 to label %cont.c unwind label %lpad.c
200 to label %cont.d unwind label %lpad.d
205 %a = landingpad { i8*, i32 }
209 ; CHECK: %a = landingpad
211 ; CHECK-NEXT: unreachable
214 %b = landingpad { i8*, i32 }
215 filter [1 x i32*] zeroinitializer
217 ; CHECK: %b = landingpad
218 ; CHECK-NEXT: cleanup
219 ; CHECK-NEXT: unreachable
222 %c = landingpad { i8*, i32 }
223 filter [2 x i32*] [i32* @T1, i32* null]
225 ; CHECK: %c = landingpad
226 ; CHECK-NEXT: cleanup
227 ; CHECK-NEXT: unreachable
230 %d = landingpad { i8*, i32 }
234 ; CHECK: %d = landingpad
236 ; CHECK-NEXT: unreachable
239 define void @foo_seh() personality i32 (...)* @__C_specific_handler {
240 ; CHECK-LABEL: @foo_seh(
242 to label %cont.a unwind label %lpad.a
245 to label %cont.b unwind label %lpad.b
248 to label %cont.c unwind label %lpad.c
251 to label %cont.d unwind label %lpad.d
256 %a = landingpad { i8*, i32 }
260 ; CHECK: %a = landingpad
262 ; CHECK-NEXT: unreachable
265 %b = landingpad { i8*, i32 }
266 filter [1 x i32*] zeroinitializer
268 ; CHECK: %b = landingpad
269 ; CHECK-NEXT: cleanup
270 ; CHECK-NEXT: unreachable
273 %c = landingpad { i8*, i32 }
274 filter [2 x i32*] [i32* @T1, i32* null]
276 ; CHECK: %c = landingpad
277 ; CHECK-NEXT: cleanup
278 ; CHECK-NEXT: unreachable
281 %d = landingpad { i8*, i32 }
285 ; CHECK: %d = landingpad
287 ; CHECK-NEXT: unreachable