1 ; RUN: opt -disable-output -passes=print-lcg %s 2>&1 | FileCheck %s
3 ; Basic validation of the call graph analysis used in the new pass manager.
6 ; CHECK-LABEL: Edges in function: f
13 ; A bunch more functions just to make it easier to test several call edges at once.
51 declare i32 @__gxx_personality_v0(...)
53 define void @test0() {
54 ; CHECK-LABEL: Edges in function: test0
55 ; CHECK-NEXT: call -> f
66 define void ()* @test1(void ()** %x) personality i32 (...)* @__gxx_personality_v0 {
67 ; CHECK-LABEL: Edges in function: test1
68 ; CHECK-NEXT: call -> f6
69 ; CHECK-NEXT: call -> f10
70 ; CHECK-NEXT: ref -> f12
71 ; CHECK-NEXT: ref -> f11
72 ; CHECK-NEXT: ref -> f7
73 ; CHECK-NEXT: ref -> f9
74 ; CHECK-NEXT: ref -> f8
75 ; CHECK-NEXT: ref -> f5
76 ; CHECK-NEXT: ref -> f4
77 ; CHECK-NEXT: ref -> f3
78 ; CHECK-NEXT: ref -> f2
79 ; CHECK-NEXT: ref -> f1
89 phi void ()* [ @f1, %entry ], [ @f2, %dead ]
90 select i1 true, void ()* @f3, void ()* @f4
91 store void ()* @f5, void ()** %x
93 call void (void ()*, void ()*) bitcast (void ()* @f7 to void (void ()*, void ()*)*)(void ()* @f8, void ()* @f9)
94 invoke void @f10() to label %exit unwind label %unwind
100 %res = landingpad { i8*, i32 }
102 resume { i8*, i32 } { i8* bitcast (void ()* @f12 to i8*), i32 42 }
105 @g = global void ()* @f1
106 @g1 = global [4 x void ()*] [void ()* @f2, void ()* @f3, void ()* @f4, void ()* @f5]
107 @g2 = global {i8, void ()*, i8} {i8 1, void ()* @f6, i8 2}
108 @h = constant void ()* @f7
110 define void @test2() {
111 ; CHECK-LABEL: Edges in function: test2
112 ; CHECK-NEXT: ref -> f7
113 ; CHECK-NEXT: ref -> f6
114 ; CHECK-NEXT: ref -> f5
115 ; CHECK-NEXT: ref -> f4
116 ; CHECK-NEXT: ref -> f3
117 ; CHECK-NEXT: ref -> f2
118 ; CHECK-NEXT: ref -> f1
121 load i8*, i8** bitcast (void ()** @g to i8**)
122 load i8*, i8** bitcast (void ()** getelementptr ([4 x void ()*], [4 x void ()*]* @g1, i32 0, i32 2) to i8**)
123 load i8*, i8** bitcast (void ()** getelementptr ({i8, void ()*, i8}, {i8, void ()*, i8}* @g2, i32 0, i32 1) to i8**)
124 load i8*, i8** bitcast (void ()** @h to i8**)
128 @test3_ptr = external global void ()*
130 define void @test3_aa1() {
131 ; CHECK-LABEL: Edges in function: test3_aa1
132 ; CHECK-NEXT: call -> test3_aa2
133 ; CHECK-NEXT: ref -> test3_ab1
137 call void @test3_aa2()
138 store void ()* @test3_ab1, void ()** @test3_ptr
142 define void @test3_aa2() {
143 ; CHECK-LABEL: Edges in function: test3_aa2
144 ; CHECK-NEXT: call -> test3_aa1
145 ; CHECK-NEXT: call -> test3_ab2
149 call void @test3_aa1()
150 call void @test3_ab2()
154 define void @test3_ab1() {
155 ; CHECK-LABEL: Edges in function: test3_ab1
156 ; CHECK-NEXT: call -> test3_ab2
157 ; CHECK-NEXT: call -> test3_ac1
161 call void @test3_ab2()
162 call void @test3_ac1()
166 define void @test3_ab2() {
167 ; CHECK-LABEL: Edges in function: test3_ab2
168 ; CHECK-NEXT: call -> test3_ab1
169 ; CHECK-NEXT: call -> test3_ba1
173 call void @test3_ab1()
174 call void @test3_ba1()
178 define void @test3_ac1() {
179 ; CHECK-LABEL: Edges in function: test3_ac1
180 ; CHECK-NEXT: call -> test3_ac2
181 ; CHECK-NEXT: ref -> test3_aa2
185 call void @test3_ac2()
186 store void ()* @test3_aa2, void ()** @test3_ptr
190 define void @test3_ac2() {
191 ; CHECK-LABEL: Edges in function: test3_ac2
192 ; CHECK-NEXT: call -> test3_ac1
193 ; CHECK-NEXT: ref -> test3_ba1
197 call void @test3_ac1()
198 store void ()* @test3_ba1, void ()** @test3_ptr
202 define void @test3_ba1() {
203 ; CHECK-LABEL: Edges in function: test3_ba1
204 ; CHECK-NEXT: call -> test3_bb1
205 ; CHECK-NEXT: ref -> test3_ca1
209 call void @test3_bb1()
210 store void ()* @test3_ca1, void ()** @test3_ptr
214 define void @test3_bb1() {
215 ; CHECK-LABEL: Edges in function: test3_bb1
216 ; CHECK-NEXT: call -> test3_ca2
217 ; CHECK-NEXT: ref -> test3_ba1
221 call void @test3_ca2()
222 store void ()* @test3_ba1, void ()** @test3_ptr
226 define void @test3_ca1() {
227 ; CHECK-LABEL: Edges in function: test3_ca1
228 ; CHECK-NEXT: call -> test3_ca2
232 call void @test3_ca2()
236 define void @test3_ca2() {
237 ; CHECK-LABEL: Edges in function: test3_ca2
238 ; CHECK-NEXT: call -> test3_ca3
242 call void @test3_ca3()
246 define void @test3_ca3() {
247 ; CHECK-LABEL: Edges in function: test3_ca3
248 ; CHECK-NEXT: call -> test3_ca1
252 call void @test3_ca1()
256 ; Verify the SCCs formed.
258 ; CHECK-LABEL: RefSCC with 1 call SCCs:
259 ; CHECK-NEXT: SCC with 1 functions:
262 ; CHECK-LABEL: RefSCC with 1 call SCCs:
263 ; CHECK-NEXT: SCC with 1 functions:
266 ; CHECK-LABEL: RefSCC with 1 call SCCs:
267 ; CHECK-NEXT: SCC with 1 functions:
270 ; CHECK-LABEL: RefSCC with 1 call SCCs:
271 ; CHECK-NEXT: SCC with 1 functions:
274 ; CHECK-LABEL: RefSCC with 1 call SCCs:
275 ; CHECK-NEXT: SCC with 1 functions:
278 ; CHECK-LABEL: RefSCC with 1 call SCCs:
279 ; CHECK-NEXT: SCC with 1 functions:
282 ; CHECK-LABEL: RefSCC with 1 call SCCs:
283 ; CHECK-NEXT: SCC with 1 functions:
286 ; CHECK-LABEL: RefSCC with 1 call SCCs:
287 ; CHECK-NEXT: SCC with 1 functions:
290 ; CHECK-LABEL: RefSCC with 1 call SCCs:
291 ; CHECK-NEXT: SCC with 1 functions:
294 ; CHECK-LABEL: RefSCC with 1 call SCCs:
295 ; CHECK-NEXT: SCC with 1 functions:
298 ; CHECK-LABEL: RefSCC with 1 call SCCs:
299 ; CHECK-NEXT: SCC with 1 functions:
302 ; CHECK-LABEL: RefSCC with 1 call SCCs:
303 ; CHECK-NEXT: SCC with 1 functions:
306 ; CHECK-LABEL: RefSCC with 1 call SCCs:
307 ; CHECK-NEXT: SCC with 1 functions:
310 ; CHECK-LABEL: RefSCC with 1 call SCCs:
311 ; CHECK-NEXT: SCC with 1 functions:
314 ; CHECK-LABEL: RefSCC with 1 call SCCs:
315 ; CHECK-NEXT: SCC with 1 functions:
318 ; CHECK-LABEL: RefSCC with 1 call SCCs:
319 ; CHECK-NEXT: SCC with 1 functions:
322 ; CHECK-LABEL: RefSCC with 1 call SCCs:
323 ; CHECK-NEXT: SCC with 3 functions:
324 ; CHECK-NEXT: test3_ca2
325 ; CHECK-NEXT: test3_ca3
326 ; CHECK-NEXT: test3_ca1
328 ; CHECK-LABEL: RefSCC with 2 call SCCs:
329 ; CHECK-NEXT: SCC with 1 functions:
330 ; CHECK-NEXT: test3_bb1
331 ; CHECK-NEXT: SCC with 1 functions:
332 ; CHECK-NEXT: test3_ba1
334 ; CHECK-LABEL: RefSCC with 3 call SCCs:
335 ; CHECK-NEXT: SCC with 2 functions:
336 ; CHECK-NEXT: test3_ac1
337 ; CHECK-NEXT: test3_ac2
338 ; CHECK-NEXT: SCC with 2 functions:
339 ; CHECK-NEXT: test3_ab2
340 ; CHECK-NEXT: test3_ab1
341 ; CHECK-NEXT: SCC with 2 functions:
342 ; CHECK-NEXT: test3_aa1
343 ; CHECK-NEXT: test3_aa2