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
  342
  343
; RUN: opt -disable-output -passes=print-lcg %s 2>&1 | FileCheck %s
;
; Basic validation of the call graph analysis used in the new pass manager.

define void @f() {
; CHECK-LABEL: Edges in function: f
; CHECK-NOT: ->

entry:
  ret void
}

; A bunch more functions just to make it easier to test several call edges at once.
define void @f1() {
  ret void
}
define void @f2() {
  ret void
}
define void @f3() {
  ret void
}
define void @f4() {
  ret void
}
define void @f5() {
  ret void
}
define void @f6() {
  ret void
}
define void @f7() {
  ret void
}
define void @f8() {
  ret void
}
define void @f9() {
  ret void
}
define void @f10() {
  ret void
}
define void @f11() {
  ret void
}
define void @f12() {
  ret void
}

declare i32 @__gxx_personality_v0(...)

define void @test0() {
; CHECK-LABEL: Edges in function: test0
; CHECK-NEXT: call -> f
; CHECK-NOT: ->

entry:
  call void @f()
  call void @f()
  call void @f()
  call void @f()
  ret void
}

define void ()* @test1(void ()** %x) personality i32 (...)* @__gxx_personality_v0 {
; CHECK-LABEL: Edges in function: test1
; CHECK-NEXT: call -> f6
; CHECK-NEXT: call -> f10
; CHECK-NEXT: ref -> f12
; CHECK-NEXT: ref -> f11
; CHECK-NEXT: ref -> f7
; CHECK-NEXT: ref -> f9
; CHECK-NEXT: ref -> f8
; CHECK-NEXT: ref -> f5
; CHECK-NEXT: ref -> f4
; CHECK-NEXT: ref -> f3
; CHECK-NEXT: ref -> f2
; CHECK-NEXT: ref -> f1
; CHECK-NOT: ->

entry:
  br label %next

dead:
  br label %next

next:
  phi void ()* [ @f1, %entry ], [ @f2, %dead ]
  select i1 true, void ()* @f3, void ()* @f4
  store void ()* @f5, void ()** %x
  call void @f6()
  call void (void ()*, void ()*) bitcast (void ()* @f7 to void (void ()*, void ()*)*)(void ()* @f8, void ()* @f9)
  invoke void @f10() to label %exit unwind label %unwind

exit:
  ret void ()* @f11

unwind:
  %res = landingpad { i8*, i32 }
          cleanup
  resume { i8*, i32 } { i8* bitcast (void ()* @f12 to i8*), i32 42 }
}

@g = global void ()* @f1
@g1 = global [4 x void ()*] [void ()* @f2, void ()* @f3, void ()* @f4, void ()* @f5]
@g2 = global {i8, void ()*, i8} {i8 1, void ()* @f6, i8 2}
@h = constant void ()* @f7

define void @test2() {
; CHECK-LABEL: Edges in function: test2
; CHECK-NEXT: ref -> f7
; CHECK-NEXT: ref -> f6
; CHECK-NEXT: ref -> f5
; CHECK-NEXT: ref -> f4
; CHECK-NEXT: ref -> f3
; CHECK-NEXT: ref -> f2
; CHECK-NEXT: ref -> f1
; CHECK-NOT: ->

  load i8*, i8** bitcast (void ()** @g to i8**)
  load i8*, i8** bitcast (void ()** getelementptr ([4 x void ()*], [4 x void ()*]* @g1, i32 0, i32 2) to i8**)
  load i8*, i8** bitcast (void ()** getelementptr ({i8, void ()*, i8}, {i8, void ()*, i8}* @g2, i32 0, i32 1) to i8**)
  load i8*, i8** bitcast (void ()** @h to i8**)
  ret void
}

@test3_ptr = external global void ()*

define void @test3_aa1() {
; CHECK-LABEL: Edges in function: test3_aa1
; CHECK-NEXT: call -> test3_aa2
; CHECK-NEXT: ref -> test3_ab1
; CHECK-NOT: ->

entry:
  call void @test3_aa2()
  store void ()* @test3_ab1, void ()** @test3_ptr
  ret void
}

define void @test3_aa2() {
; CHECK-LABEL: Edges in function: test3_aa2
; CHECK-NEXT: call -> test3_aa1
; CHECK-NEXT: call -> test3_ab2
; CHECK-NOT: ->

entry:
  call void @test3_aa1()
  call void @test3_ab2()
  ret void
}

define void @test3_ab1() {
; CHECK-LABEL: Edges in function: test3_ab1
; CHECK-NEXT: call -> test3_ab2
; CHECK-NEXT: call -> test3_ac1
; CHECK-NOT: ->

entry:
  call void @test3_ab2()
  call void @test3_ac1()
  ret void
}

define void @test3_ab2() {
; CHECK-LABEL: Edges in function: test3_ab2
; CHECK-NEXT: call -> test3_ab1
; CHECK-NEXT: call -> test3_ba1
; CHECK-NOT: ->

entry:
  call void @test3_ab1()
  call void @test3_ba1()
  ret void
}

define void @test3_ac1() {
; CHECK-LABEL: Edges in function: test3_ac1
; CHECK-NEXT: call -> test3_ac2
; CHECK-NEXT: ref -> test3_aa2
; CHECK-NOT: ->

entry:
  call void @test3_ac2()
  store void ()* @test3_aa2, void ()** @test3_ptr
  ret void
}

define void @test3_ac2() {
; CHECK-LABEL: Edges in function: test3_ac2
; CHECK-NEXT: call -> test3_ac1
; CHECK-NEXT: ref -> test3_ba1
; CHECK-NOT: ->

entry:
  call void @test3_ac1()
  store void ()* @test3_ba1, void ()** @test3_ptr
  ret void
}

define void @test3_ba1() {
; CHECK-LABEL: Edges in function: test3_ba1
; CHECK-NEXT: call -> test3_bb1
; CHECK-NEXT: ref -> test3_ca1
; CHECK-NOT: ->

entry:
  call void @test3_bb1()
  store void ()* @test3_ca1, void ()** @test3_ptr
  ret void
}

define void @test3_bb1() {
; CHECK-LABEL: Edges in function: test3_bb1
; CHECK-NEXT: call -> test3_ca2
; CHECK-NEXT: ref -> test3_ba1
; CHECK-NOT: ->

entry:
  call void @test3_ca2()
  store void ()* @test3_ba1, void ()** @test3_ptr
  ret void
}

define void @test3_ca1() {
; CHECK-LABEL: Edges in function: test3_ca1
; CHECK-NEXT: call -> test3_ca2
; CHECK-NOT: ->

entry:
  call void @test3_ca2()
  ret void
}

define void @test3_ca2() {
; CHECK-LABEL: Edges in function: test3_ca2
; CHECK-NEXT: call -> test3_ca3
; CHECK-NOT: ->

entry:
  call void @test3_ca3()
  ret void
}

define void @test3_ca3() {
; CHECK-LABEL: Edges in function: test3_ca3
; CHECK-NEXT: call -> test3_ca1
; CHECK-NOT: ->

entry:
  call void @test3_ca1()
  ret void
}

; Verify the SCCs formed.
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 3 functions:
; CHECK-NEXT:      test3_ca3
; CHECK-NEXT:      test3_ca1
; CHECK-NEXT:      test3_ca2
;
; CHECK-LABEL: RefSCC with 2 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      test3_bb1
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      test3_ba1
;
; CHECK-LABEL: RefSCC with 3 call SCCs:
; CHECK-NEXT:    SCC with 2 functions:
; CHECK-NEXT:      test3_ac2
; CHECK-NEXT:      test3_ac1
; CHECK-NEXT:    SCC with 2 functions:
; CHECK-NEXT:      test3_ab2
; CHECK-NEXT:      test3_ab1
; CHECK-NEXT:    SCC with 2 functions:
; CHECK-NEXT:      test3_aa2
; CHECK-NEXT:      test3_aa1
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f7
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f6
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f5
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f4
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f3
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f2
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f1
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      test2
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f10
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f12
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f11
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f9
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f8
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      test1
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      f
;
; CHECK-LABEL: RefSCC with 1 call SCCs:
; CHECK-NEXT:    SCC with 1 functions:
; CHECK-NEXT:      test0