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 3 functions:
260 ; CHECK-NEXT: test3_ca3
261 ; CHECK-NEXT: test3_ca1
262 ; CHECK-NEXT: test3_ca2
264 ; CHECK-LABEL: RefSCC with 2 call SCCs:
265 ; CHECK-NEXT: SCC with 1 functions:
266 ; CHECK-NEXT: test3_bb1
267 ; CHECK-NEXT: SCC with 1 functions:
268 ; CHECK-NEXT: test3_ba1
270 ; CHECK-LABEL: RefSCC with 3 call SCCs:
271 ; CHECK-NEXT: SCC with 2 functions:
272 ; CHECK-NEXT: test3_ac2
273 ; CHECK-NEXT: test3_ac1
274 ; CHECK-NEXT: SCC with 2 functions:
275 ; CHECK-NEXT: test3_ab2
276 ; CHECK-NEXT: test3_ab1
277 ; CHECK-NEXT: SCC with 2 functions:
278 ; CHECK-NEXT: test3_aa2
279 ; CHECK-NEXT: test3_aa1
281 ; CHECK-LABEL: RefSCC with 1 call SCCs:
282 ; CHECK-NEXT: SCC with 1 functions:
285 ; CHECK-LABEL: RefSCC with 1 call SCCs:
286 ; CHECK-NEXT: SCC with 1 functions:
289 ; CHECK-LABEL: RefSCC with 1 call SCCs:
290 ; CHECK-NEXT: SCC with 1 functions:
293 ; CHECK-LABEL: RefSCC with 1 call SCCs:
294 ; CHECK-NEXT: SCC with 1 functions:
297 ; CHECK-LABEL: RefSCC with 1 call SCCs:
298 ; CHECK-NEXT: SCC with 1 functions:
301 ; CHECK-LABEL: RefSCC with 1 call SCCs:
302 ; CHECK-NEXT: SCC with 1 functions:
305 ; CHECK-LABEL: RefSCC with 1 call SCCs:
306 ; CHECK-NEXT: SCC with 1 functions:
309 ; CHECK-LABEL: RefSCC with 1 call SCCs:
310 ; CHECK-NEXT: SCC with 1 functions:
313 ; CHECK-LABEL: RefSCC with 1 call SCCs:
314 ; CHECK-NEXT: SCC with 1 functions:
317 ; CHECK-LABEL: RefSCC with 1 call SCCs:
318 ; CHECK-NEXT: SCC with 1 functions:
321 ; CHECK-LABEL: RefSCC with 1 call SCCs:
322 ; CHECK-NEXT: SCC with 1 functions:
325 ; CHECK-LABEL: RefSCC with 1 call SCCs:
326 ; CHECK-NEXT: SCC with 1 functions:
329 ; CHECK-LABEL: RefSCC with 1 call SCCs:
330 ; CHECK-NEXT: SCC with 1 functions:
333 ; CHECK-LABEL: RefSCC with 1 call SCCs:
334 ; CHECK-NEXT: SCC with 1 functions:
337 ; CHECK-LABEL: RefSCC with 1 call SCCs:
338 ; CHECK-NEXT: SCC with 1 functions:
341 ; CHECK-LABEL: RefSCC with 1 call SCCs:
342 ; CHECK-NEXT: SCC with 1 functions: