• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -instcombine -S | FileCheck %s
2
3@T1 = external constant i32
4@T2 = external constant i32
5@T3 = external constant i32
6
7declare i32 @generic_personality(i32, i64, i8*, i8*)
8declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*)
9
10declare void @bar()
11
12define void @foo_generic() {
13; CHECK: @foo_generic
14  invoke void @bar()
15    to label %cont.a unwind label %lpad.a
16cont.a:
17  invoke void @bar()
18    to label %cont.b unwind label %lpad.b
19cont.b:
20  invoke void @bar()
21    to label %cont.c unwind label %lpad.c
22cont.c:
23  invoke void @bar()
24    to label %cont.d unwind label %lpad.d
25cont.d:
26  invoke void @bar()
27    to label %cont.e unwind label %lpad.e
28cont.e:
29  invoke void @bar()
30    to label %cont.f unwind label %lpad.f
31cont.f:
32  invoke void @bar()
33    to label %cont.g unwind label %lpad.g
34cont.g:
35  invoke void @bar()
36    to label %cont.h unwind label %lpad.h
37cont.h:
38  invoke void @bar()
39    to label %cont.i unwind label %lpad.i
40cont.i:
41  ret void
42
43lpad.a:
44  %a = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
45          catch i32* @T1
46          catch i32* @T2
47          catch i32* @T1
48          catch i32* @T2
49  unreachable
50; CHECK: %a = landingpad
51; CHECK-NEXT: @T1
52; CHECK-NEXT: @T2
53; CHECK-NEXT: unreachable
54
55lpad.b:
56  %b = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
57          filter [0 x i32*] zeroinitializer
58          catch i32* @T1
59  unreachable
60; CHECK: %b = landingpad
61; CHECK-NEXT: filter
62; CHECK-NEXT: unreachable
63
64lpad.c:
65  %c = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
66          catch i32* @T1
67          filter [1 x i32*] [i32* @T1]
68          catch i32* @T2
69  unreachable
70; CHECK: %c = landingpad
71; CHECK-NEXT: @T1
72; CHECK-NEXT: filter [0 x i32*]
73; CHECK-NEXT: unreachable
74
75lpad.d:
76  %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
77          filter [3 x i32*] zeroinitializer
78  unreachable
79; CHECK: %d = landingpad
80; CHECK-NEXT: filter [1 x i32*] zeroinitializer
81; CHECK-NEXT: unreachable
82
83lpad.e:
84  %e = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
85          catch i32* @T1
86          filter [3 x i32*] [i32* @T1, i32* @T2, i32* @T2]
87  unreachable
88; CHECK: %e = landingpad
89; CHECK-NEXT: @T1
90; CHECK-NEXT: filter [1 x i32*] [i32* @T2]
91; CHECK-NEXT: unreachable
92
93lpad.f:
94  %f = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
95          filter [2 x i32*] [i32* @T2, i32* @T1]
96          filter [1 x i32*] [i32* @T1]
97  unreachable
98; CHECK: %f = landingpad
99; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
100; CHECK-NEXT: unreachable
101
102lpad.g:
103  %g = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
104          filter [1 x i32*] [i32* @T1]
105          catch i32* @T3
106          filter [2 x i32*] [i32* @T2, i32* @T1]
107  unreachable
108; CHECK: %g = landingpad
109; CHECK-NEXT: filter [1 x i32*] [i32* @T1]
110; CHECK-NEXT: catch i32* @T3
111; CHECK-NEXT: unreachable
112
113lpad.h:
114  %h = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
115          filter [2 x i32*] [i32* @T1, i32* null]
116          filter [1 x i32*] zeroinitializer
117  unreachable
118; CHECK: %h = landingpad
119; CHECK-NEXT: filter [1 x i32*] zeroinitializer
120; CHECK-NEXT: unreachable
121
122lpad.i:
123  %i = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality
124          cleanup
125          filter [0 x i32*] zeroinitializer
126  unreachable
127; CHECK: %i = landingpad
128; CHECK-NEXT: filter
129; CHECK-NEXT: unreachable
130}
131
132define void @foo_cxx() {
133; CHECK: @foo_cxx
134  invoke void @bar()
135    to label %cont.a unwind label %lpad.a
136cont.a:
137  invoke void @bar()
138    to label %cont.b unwind label %lpad.b
139cont.b:
140  invoke void @bar()
141    to label %cont.c unwind label %lpad.c
142cont.c:
143  invoke void @bar()
144    to label %cont.d unwind label %lpad.d
145cont.d:
146  ret void
147
148lpad.a:
149  %a = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
150          catch i32* null
151          catch i32* @T1
152  unreachable
153; CHECK: %a = landingpad
154; CHECK-NEXT: null
155; CHECK-NEXT: unreachable
156
157lpad.b:
158  %b = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
159          filter [1 x i32*] zeroinitializer
160  unreachable
161; CHECK: %b = landingpad
162; CHECK-NEXT: cleanup
163; CHECK-NEXT: unreachable
164
165lpad.c:
166  %c = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
167          filter [2 x i32*] [i32* @T1, i32* null]
168  unreachable
169; CHECK: %c = landingpad
170; CHECK-NEXT: cleanup
171; CHECK-NEXT: unreachable
172
173lpad.d:
174  %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0
175          cleanup
176          catch i32* null
177  unreachable
178; CHECK: %d = landingpad
179; CHECK-NEXT: null
180; CHECK-NEXT: unreachable
181}
182