reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
  283
  284
  285
  286
  287
  288
  289
  290
  291
  292
  293
  294
  295
  296
  297
  298
  299
  300
  301
  302
  303
  304
  305
  306
  307
  308
  309
  310
  311
  312
  313
  314
  315
  316
  317
  318
  319
  320
  321
  322
  323
  324
  325
  326
  327
  328
  329
  330
  331
  332
  333
  334
  335
  336
  337
  338
  339
  340
  341
; RUN: opt -aa-pipeline=basic-aa -passes='cgscc(function-attrs,function(simplify-cfg))' -S < %s | FileCheck %s

declare void @readnone() readnone
declare void @unknown()
declare void @reference_function_pointer(void()*) readnone

; The @test1_* set of functions checks that when we mutate functions with
; simplify-cfg to delete call edges and this ends up splitting both the SCCs
; and the RefSCCs that those functions are in, we re-run the CGSCC passes to
; observe the refined call graph structure.

; CHECK: define void @test1_a() {
define void @test1_a() {
  call void @test1_b1()
  call void @test1_b2()
  call void @test1_b3()
  call void @test1_b4()
  ret void
}

; CHECK: define void @test1_b1() #0 {
define void @test1_b1() {
  call void @readnone()
  ret void
}

; CHECK: define void @test1_b2() #0 {
define void @test1_b2() {
  call void @readnone()
  br i1 false, label %dead, label %exit

dead:
  call void @test1_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test1_b3() {
define void @test1_b3() {
  call void @unknown()
  br i1 false, label %dead, label %exit

dead:
  call void @test1_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test1_b4() #0 {
define void @test1_b4() {
  call void @readnone()
  br i1 false, label %dead, label %exit

dead:
  call void @test1_a()
  br label %exit

exit:
  ret void
}


; The @test2_* set of functions provide similar checks to @test1_* but only
; splitting the SCCs while leaving the RefSCC intact. This is accomplished by
; having dummy ref edges to the root function.

; CHECK: define void @test2_a() {
define void @test2_a() {
  call void @test2_b1()
  call void @test2_b2()
  call void @test2_b3()
  call void @test2_b4()
  ret void
}

; CHECK: define void @test2_b1() #0 {
define void @test2_b1() {
  call void @readnone()
  ret void
}

; CHECK: define void @test2_b2() #0 {
define void @test2_b2() {
  call void @reference_function_pointer(void()* @test2_a)
  br i1 false, label %dead, label %exit

dead:
  call void @test2_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test2_b3() {
define void @test2_b3() {
  call void @reference_function_pointer(void()* @test2_a)
  call void @unknown()
  br i1 false, label %dead, label %exit

dead:
  call void @test2_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test2_b4() #0 {
define void @test2_b4() {
  call void @reference_function_pointer(void()* @test2_a)
  br i1 false, label %dead, label %exit

dead:
  call void @test2_a()
  br label %exit

exit:
  ret void
}


; The @test3_* set of functions are the same challenge as @test1_* but with
; multiple layers that have to be traversed in the correct order instead of
; a single node.

; CHECK: define void @test3_a() {
define void @test3_a() {
  call void @test3_b11()
  call void @test3_b21()
  call void @test3_b31()
  call void @test3_b41()
  ret void
}

; CHECK: define void @test3_b11() #0 {
define void @test3_b11() {
  call void @test3_b12()
  ret void
}

; CHECK: define void @test3_b12() #0 {
define void @test3_b12() {
  call void @test3_b13()
  ret void
}

; CHECK: define void @test3_b13() #0 {
define void @test3_b13() {
  call void @readnone()
  ret void
}

; CHECK: define void @test3_b21() #0 {
define void @test3_b21() {
  call void @test3_b22()
  ret void
}

; CHECK: define void @test3_b22() #0 {
define void @test3_b22() {
  call void @test3_b23()
  ret void
}

; CHECK: define void @test3_b23() #0 {
define void @test3_b23() {
  call void @readnone()
  br i1 false, label %dead, label %exit

dead:
  call void @test3_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test3_b31() {
define void @test3_b31() {
  call void @test3_b32()
  ret void
}

; CHECK: define void @test3_b32() {
define void @test3_b32() {
  call void @test3_b33()
  ret void
}

; CHECK: define void @test3_b33() {
define void @test3_b33() {
  call void @unknown()
  br i1 false, label %dead, label %exit

dead:
  call void @test3_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test3_b41() #0 {
define void @test3_b41() {
  call void @test3_b42()
  ret void
}

; CHECK: define void @test3_b42() #0 {
define void @test3_b42() {
  call void @test3_b43()
  ret void
}

; CHECK: define void @test3_b43() #0 {
define void @test3_b43() {
  call void @readnone()
  br i1 false, label %dead, label %exit

dead:
  call void @test3_a()
  br label %exit

exit:
  ret void
}


; The @test4_* functions exercise the same core challenge as the @test2_*
; functions, but again include long chains instead of single nodes and ensure
; we traverse the chains in the correct order.

; CHECK: define void @test4_a() {
define void @test4_a() {
  call void @test4_b11()
  call void @test4_b21()
  call void @test4_b31()
  call void @test4_b41()
  ret void
}

; CHECK: define void @test4_b11() #0 {
define void @test4_b11() {
  call void @test4_b12()
  ret void
}

; CHECK: define void @test4_b12() #0 {
define void @test4_b12() {
  call void @test4_b13()
  ret void
}

; CHECK: define void @test4_b13() #0 {
define void @test4_b13() {
  call void @readnone()
  ret void
}

; CHECK: define void @test4_b21() #0 {
define void @test4_b21() {
  call void @test4_b22()
  ret void
}

; CHECK: define void @test4_b22() #0 {
define void @test4_b22() {
  call void @test4_b23()
  ret void
}

; CHECK: define void @test4_b23() #0 {
define void @test4_b23() {
  call void @reference_function_pointer(void()* @test4_a)
  br i1 false, label %dead, label %exit

dead:
  call void @test4_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test4_b31() {
define void @test4_b31() {
  call void @test4_b32()
  ret void
}

; CHECK: define void @test4_b32() {
define void @test4_b32() {
  call void @test4_b33()
  ret void
}

; CHECK: define void @test4_b33() {
define void @test4_b33() {
  call void @reference_function_pointer(void()* @test4_a)
  call void @unknown()
  br i1 false, label %dead, label %exit

dead:
  call void @test4_a()
  br label %exit

exit:
  ret void
}

; CHECK: define void @test4_b41() #0 {
define void @test4_b41() {
  call void @test4_b42()
  ret void
}

; CHECK: define void @test4_b42() #0 {
define void @test4_b42() {
  call void @test4_b43()
  ret void
}

; CHECK: define void @test4_b43() #0 {
define void @test4_b43() {
  call void @reference_function_pointer(void()* @test4_a)
  br i1 false, label %dead, label %exit

dead:
  call void @test4_a()
  br label %exit

exit:
  ret void
}

; CHECK: attributes #0 = { readnone }