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
# RUN: llc -o /dev/null %s -mtriple=aarch64-apple-ios -run-pass=aarch64-collect-loh -debug-only=aarch64-collect-loh 2>&1 | FileCheck %s
# REQUIRES: asserts
--- |
  define void @func0() { ret void }

  declare void @extfunc()

  @g0 = external global i32
  @g1 = external global i32
  @g2 = external global i32
  @g3 = external global i32
  @g4 = external global i32
  @g5 = external global i32
...
---
# Check various LOH variants. Remember that the algorithms walks the basic
# blocks backwards.
# CHECK-LABEL: ********** AArch64 Collect LOH **********
# CHECK-LABEL: Looking in function func0
name: func0
tracksRegLiveness: true
body: |
  bb.0:
    ; CHECK: Adding MCLOH_AdrpAdrp:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g4
    ; CHECK-NEXT: Adding MCLOH_AdrpAdrp:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g2
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: Adding MCLOH_AdrpAdrp:
    ; CHECK-NEXT: $x0 = ADRP target-flags(aarch64-page) @g0
    ; CHECK-NEXT: $x0 = ADRP target-flags(aarch64-page) @g1
    $x0 = ADRP target-flags(aarch64-page) @g0
    $x0 = ADRP target-flags(aarch64-page) @g1
    $x1 = ADRP target-flags(aarch64-page) @g2
    $x1 = ADRP target-flags(aarch64-page) @g3
    $x1 = ADRP target-flags(aarch64-page) @g4

  bb.1:
    ; CHECK-NEXT: Adding MCLOH_AdrpAdd:
    ; CHECK-NEXT: $x20 = ADRP target-flags(aarch64-page) @g0
    ; CHECK-NEXT: $x3 = ADDXri $x20, target-flags(aarch64-pageoff) @g0
    ; CHECK-NEXT: Adding MCLOH_AdrpAdd:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g0
    ; CHECK-NEXT: $x1 = ADDXri $x1, target-flags(aarch64-pageoff) @g0
    $x1 = ADRP target-flags(aarch64-page) @g0
    $x9 = SUBXri undef $x11, 5, 0 ; should not affect MCLOH formation
    $x1 = ADDXri $x1, target-flags(aarch64-pageoff) @g0, 0
    $x20 = ADRP target-flags(aarch64-page) @g0
    BL @extfunc, csr_aarch64_aapcs ; should not clobber X20
    $x3 = ADDXri $x20, target-flags(aarch64-pageoff) @g0, 0

  bb.2:
    ; CHECK-NOT: MCLOH_AdrpAdd
    $x9 = ADRP target-flags(aarch64-page) @g0
    BL @extfunc, csr_aarch64_aapcs ; clobbers x9
    ; Verification requires the use of 'undef' in front of the clobbered $x9
    $x9 = ADDXri undef $x9, target-flags(aarch64-pageoff) @g0, 0

  bb.3:
    ; CHECK-NOT: MCLOH_AdrpAdd
    $x10 = ADRP target-flags(aarch64-page) @g0
    HINT 0, implicit def $x10 ; clobbers x10
    $x10 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0

  bb.4:
    ; Cannot produce a LOH for multiple users
    ; CHECK-NOT: MCLOH_AdrpAdd
    $x10 = ADRP target-flags(aarch64-page) @g0
    HINT 0, implicit def $x10 ; clobbers x10
    $x11 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
    $x12 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0

  bb.5:
    ; CHECK-NEXT: Adding MCLOH_AdrpLdr:
    ; CHECK-NEXT: $x5 = ADRP target-flags(aarch64-page) @g2
    ; CHECK-NEXT: $s6 = LDRSui $x5, target-flags(aarch64-pageoff) @g2
    ; CHECK-NEXT: Adding MCLOH_AdrpLdr:
    ; CHECK-NEXT: $x4 = ADRP target-flags(aarch64-page) @g2
    ; CHECK-NEXT: $x4 = LDRXui $x4, target-flags(aarch64-pageoff) @g2
    $x4 = ADRP target-flags(aarch64-page) @g2
    $x4 = LDRXui $x4, target-flags(aarch64-pageoff) @g2
    $x5 = ADRP target-flags(aarch64-page) @g2
    $s6 = LDRSui $x5, target-flags(aarch64-pageoff) @g2

  bb.6:
    ; CHECK-NEXT: Adding MCLOH_AdrpLdrGot:
    ; CHECK-NEXT: $x5 = ADRP target-flags(aarch64-page, aarch64-got) @g2
    ; CHECK-NEXT: $x6 = LDRXui $x5, target-flags(aarch64-pageoff, aarch64-got) @g2
    ; CHECK-NEXT: Adding MCLOH_AdrpLdrGot:
    ; CHECK-NEXT: $x4 = ADRP target-flags(aarch64-page, aarch64-got) @g2
    ; CHECK-NEXT: $x4 = LDRXui $x4, target-flags(aarch64-pageoff, aarch64-got) @g2
    $x4 = ADRP target-flags(aarch64-page, aarch64-got) @g2
    $x4 = LDRXui $x4, target-flags(aarch64-pageoff, aarch64-got) @g2
    $x5 = ADRP target-flags(aarch64-page, aarch64-got) @g2
    $x6 = LDRXui $x5, target-flags(aarch64-pageoff, aarch64-got) @g2

  bb.7:
    ; CHECK-NOT: Adding MCLOH_AdrpLdrGot:
    ; Loading a float value from a GOT table makes no sense so this should not
    ; produce an LOH.
    $x11 = ADRP target-flags(aarch64-page, aarch64-got) @g5
    $s11 = LDRSui $x11, target-flags(aarch64-pageoff, aarch64-got) @g5

  bb.8:
    ; CHECK-NEXT: Adding MCLOH_AdrpAddLdr:
    ; CHECK-NEXT: $x7 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x8 = ADDXri $x7, target-flags(aarch64-pageoff) @g3
    ; CHECK-NEXT: $d1 = LDRDui $x8, 8
    $x7 = ADRP target-flags(aarch64-page) @g3
    $x8 = ADDXri $x7, target-flags(aarch64-pageoff) @g3, 0
    $d1 = LDRDui $x8, 8

  bb.9:
    ; CHECK-NEXT: Adding MCLOH_AdrpAdd:
    ; CHECK-NEXT: $x3 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x3 = ADDXri $x3, target-flags(aarch64-pageoff) @g3
    ; CHECK-NEXT: Adding MCLOH_AdrpAdd:
    ; CHECK-NEXT: $x5 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x2 = ADDXri $x5, target-flags(aarch64-pageoff) @g3
    ; CHECK-NEXT: Adding MCLOH_AdrpAddStr:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x1 = ADDXri $x1, target-flags(aarch64-pageoff) @g3
    ; CHECK-NEXT: STRXui $xzr, $x1, 16
    $x1 = ADRP target-flags(aarch64-page) @g3
    $x1 = ADDXri $x1, target-flags(aarch64-pageoff) @g3, 0
    STRXui $xzr, $x1, 16

    ; This sequence should just produce an AdrpAdd (not AdrpAddStr)
    $x5 = ADRP target-flags(aarch64-page) @g3
    $x2 = ADDXri $x5, target-flags(aarch64-pageoff) @g3, 0
    STRXui $x2, undef $x11, 16

    ; This sequence should just produce an AdrpAdd (not AdrpAddStr)
    $x3 = ADRP target-flags(aarch64-page) @g3
    $x3 = ADDXri $x3, target-flags(aarch64-pageoff) @g3, 0
    STRXui $x3, $x3, 16

  bb.10:
    ; CHECK-NEXT: Adding MCLOH_AdrpLdr:
    ; CHECK-NEXT: $x2 = ADRP target-flags(aarch64-page) @g3
    ; CHECK-NEXT: $x2 = LDRXui $x2, target-flags(aarch64-pageoff) @g3
    ; CHECK-NEXT: Adding MCLOH_AdrpLdrGotLdr:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page, aarch64-got) @g4
    ; CHECK-NEXT: $x1 = LDRXui $x1, target-flags(aarch64-pageoff, aarch64-got) @g4
    ; CHECK-NEXT: $x1 = LDRXui $x1, 24
    $x1 = ADRP target-flags(aarch64-page, aarch64-got) @g4
    $x1 = LDRXui $x1, target-flags(aarch64-pageoff, aarch64-got) @g4
    $x1 = LDRXui $x1, 24
    ; Should just produce a MCLOH_AdrpLdr (not MCLOH_AdrpLdrGotLdr)
    $x2 = ADRP target-flags(aarch64-page) @g3
    $x2 = LDRXui $x2, target-flags(aarch64-pageoff) @g3
    $x2 = LDRXui $x2, 24

  bb.11:
    ; CHECK-NEXT: Adding MCLOH_AdrpLdr
    ; CHECK-NEXT: $x5 = ADRP target-flags(aarch64-page) @g1
    ; CHECK-NEXT: $x5 = LDRXui $x5, target-flags(aarch64-pageoff) @g1
    ; CHECK-NEXT: Adding MCLOH_AdrpLdrGotStr:
    ; CHECK-NEXT: $x1 = ADRP target-flags(aarch64-page, aarch64-got) @g4
    ; CHECK-NEXT: $x1 = LDRXui $x1, target-flags(aarch64-pageoff, aarch64-got) @g4
    ; CHECK-NEXT: STRXui $xzr, $x1, 32
    $x1 = ADRP target-flags(aarch64-page, aarch64-got) @g4
    $x1 = LDRXui $x1, target-flags(aarch64-pageoff, aarch64-got) @g4
    STRXui $xzr, $x1, 32
    ; Should just produce a MCLOH_AdrpLdr (not MCLOH_AdrpLdrGotStr)
    $x5 = ADRP target-flags(aarch64-page) @g1
    $x5 = LDRXui $x5, target-flags(aarch64-pageoff) @g1
    STRXui undef $x11, $x5, 32

  bb.12:
    ; CHECK-NOT: MCLOH_AdrpAdrp
    ; CHECK: Adding MCLOH_AdrpAddLdr
    ; $x9 = ADRP @g4
    ; $x9 = ADDXri $x9, @g4
    ; $x5 = LDRXui $x9, 0
    $x9 = ADRP target-flags(aarch64-page, aarch64-got) @g4
    $x9 = ADDXri $x9, target-flags(aarch64-pageoff, aarch64-got) @g4, 0
    $x5 = LDRXui $x9, 0
    $x9 = ADRP target-flags(aarch64-page, aarch64-got) @g5

  bb.13:
    ; Cannot produce a LOH for multiple users
    ; CHECK-NOT: MCLOH_AdrpAdd
    $x10 = ADRP target-flags(aarch64-page) @g0
    $x11 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
    B %bb.14

  bb.14:
    liveins: $x10
    $x12 = ADDXri $x10, target-flags(aarch64-pageoff) @g0, 0
...