1 ; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(function-attrs,function(simplify-cfg))' -S < %s | FileCheck %s
3 declare void @readnone() readnone
4 declare void @unknown()
5 declare void @reference_function_pointer(void()*) readnone
7 ; The @test1_* set of functions checks that when we mutate functions with
8 ; simplify-cfg to delete call edges and this ends up splitting both the SCCs
9 ; and the RefSCCs that those functions are in, we re-run the CGSCC passes to
10 ; observe the refined call graph structure.
12 ; CHECK: define void @test1_a() {
13 define void @test1_a() {
21 ; CHECK: define void @test1_b1() #0 {
22 define void @test1_b1() {
27 ; CHECK: define void @test1_b2() #0 {
28 define void @test1_b2() {
30 br i1 false, label %dead, label %exit
40 ; CHECK: define void @test1_b3() {
41 define void @test1_b3() {
43 br i1 false, label %dead, label %exit
53 ; CHECK: define void @test1_b4() #0 {
54 define void @test1_b4() {
56 br i1 false, label %dead, label %exit
67 ; The @test2_* set of functions provide similar checks to @test1_* but only
68 ; splitting the SCCs while leaving the RefSCC intact. This is accomplished by
69 ; having dummy ref edges to the root function.
71 ; CHECK: define void @test2_a() {
72 define void @test2_a() {
80 ; CHECK: define void @test2_b1() #0 {
81 define void @test2_b1() {
86 ; CHECK: define void @test2_b2() #0 {
87 define void @test2_b2() {
88 call void @reference_function_pointer(void()* @test2_a)
89 br i1 false, label %dead, label %exit
99 ; CHECK: define void @test2_b3() {
100 define void @test2_b3() {
101 call void @reference_function_pointer(void()* @test2_a)
103 br i1 false, label %dead, label %exit
113 ; CHECK: define void @test2_b4() #0 {
114 define void @test2_b4() {
115 call void @reference_function_pointer(void()* @test2_a)
116 br i1 false, label %dead, label %exit
127 ; The @test3_* set of functions are the same challenge as @test1_* but with
128 ; multiple layers that have to be traversed in the correct order instead of
131 ; CHECK: define void @test3_a() {
132 define void @test3_a() {
133 call void @test3_b11()
134 call void @test3_b21()
135 call void @test3_b31()
136 call void @test3_b41()
140 ; CHECK: define void @test3_b11() #0 {
141 define void @test3_b11() {
142 call void @test3_b12()
146 ; CHECK: define void @test3_b12() #0 {
147 define void @test3_b12() {
148 call void @test3_b13()
152 ; CHECK: define void @test3_b13() #0 {
153 define void @test3_b13() {
154 call void @readnone()
158 ; CHECK: define void @test3_b21() #0 {
159 define void @test3_b21() {
160 call void @test3_b22()
164 ; CHECK: define void @test3_b22() #0 {
165 define void @test3_b22() {
166 call void @test3_b23()
170 ; CHECK: define void @test3_b23() #0 {
171 define void @test3_b23() {
172 call void @readnone()
173 br i1 false, label %dead, label %exit
183 ; CHECK: define void @test3_b31() {
184 define void @test3_b31() {
185 call void @test3_b32()
189 ; CHECK: define void @test3_b32() {
190 define void @test3_b32() {
191 call void @test3_b33()
195 ; CHECK: define void @test3_b33() {
196 define void @test3_b33() {
198 br i1 false, label %dead, label %exit
208 ; CHECK: define void @test3_b41() #0 {
209 define void @test3_b41() {
210 call void @test3_b42()
214 ; CHECK: define void @test3_b42() #0 {
215 define void @test3_b42() {
216 call void @test3_b43()
220 ; CHECK: define void @test3_b43() #0 {
221 define void @test3_b43() {
222 call void @readnone()
223 br i1 false, label %dead, label %exit
234 ; The @test4_* functions exercise the same core challenge as the @test2_*
235 ; functions, but again include long chains instead of single nodes and ensure
236 ; we traverse the chains in the correct order.
238 ; CHECK: define void @test4_a() {
239 define void @test4_a() {
240 call void @test4_b11()
241 call void @test4_b21()
242 call void @test4_b31()
243 call void @test4_b41()
247 ; CHECK: define void @test4_b11() #0 {
248 define void @test4_b11() {
249 call void @test4_b12()
253 ; CHECK: define void @test4_b12() #0 {
254 define void @test4_b12() {
255 call void @test4_b13()
259 ; CHECK: define void @test4_b13() #0 {
260 define void @test4_b13() {
261 call void @readnone()
265 ; CHECK: define void @test4_b21() #0 {
266 define void @test4_b21() {
267 call void @test4_b22()
271 ; CHECK: define void @test4_b22() #0 {
272 define void @test4_b22() {
273 call void @test4_b23()
277 ; CHECK: define void @test4_b23() #0 {
278 define void @test4_b23() {
279 call void @reference_function_pointer(void()* @test4_a)
280 br i1 false, label %dead, label %exit
290 ; CHECK: define void @test4_b31() {
291 define void @test4_b31() {
292 call void @test4_b32()
296 ; CHECK: define void @test4_b32() {
297 define void @test4_b32() {
298 call void @test4_b33()
302 ; CHECK: define void @test4_b33() {
303 define void @test4_b33() {
304 call void @reference_function_pointer(void()* @test4_a)
306 br i1 false, label %dead, label %exit
316 ; CHECK: define void @test4_b41() #0 {
317 define void @test4_b41() {
318 call void @test4_b42()
322 ; CHECK: define void @test4_b42() #0 {
323 define void @test4_b42() {
324 call void @test4_b43()
328 ; CHECK: define void @test4_b43() #0 {
329 define void @test4_b43() {
330 call void @reference_function_pointer(void()* @test4_a)
331 br i1 false, label %dead, label %exit
341 ; CHECK: attributes #0 = { readnone }