File: fake-use-remove-loads.mir

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (171 lines) | stat: -rw-r--r-- 8,900 bytes parent folder | download | duplicates (2)
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
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# Ensure that loads into FAKE_USEs are correctly removed by the
# remove-loads-into-fake-uses pass, and that if the function does not use
# instruction referencing then no changes are made.
# RUN: llc %s -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - | FileCheck %s
# REQUIRES: asserts
#
## We verify that:
##   - The load into the FAKE_USE is removed, along with the FAKE_USE itself,
##     even when the FAKE_USE is for a subregister of the move.
##   - We correctly handle situations where FAKE_USE has additional `killed`
##     operands added by other passes.
##   - The store to the stack slot still exists.
##   - When the register has a use between the restore and the FAKE_USE, we do
##     not delete the load or fake use.


---
name:            enabled
alignment:       16
tracksRegLiveness: true
noPhis:          true
noVRegs:         true
hasFakeUses:     true
tracksDebugUserValues: true
debugInstrRef: true
liveins:
  - { reg: '$rdi', virtual-reg: '' }
  - { reg: '$esi', virtual-reg: '' }
  - { reg: '$rdx', virtual-reg: '' }
frameInfo:
  isCalleeSavedInfoValid: true
stack:
  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
  - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
body:             |
  bb.0:
    liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx

    ; CHECK-LABEL: name: enabled
    ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: $rbx = MOV64rr $rdx
    ; CHECK-NEXT: $r14d = MOV32rr $esi
    ; CHECK-NEXT: $r15 = MOV64rr $rdi
    ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
    ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax

    ;; The store to the stack slot is still present.
    ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)

    ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
    ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
    ; CHECK-NEXT: $r13d = MOV32rr killed $eax
    ; CHECK-NEXT: $rdi = MOV64rr $r15
    ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
    ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
    ; CHECK-NEXT: renamable $eax = MOV32ri 1
    ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
    
    ;; First FAKE_USE and its corresponding load are removed; second FAKE_USE of
    ;; a restored value that is also used is preserved.
    ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
    ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
    ; CHECK-NEXT: FAKE_USE killed renamable $r11d

    ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
    ; CHECK-NEXT: RET64

    $rbx = MOV64rr $rdx
    $r14d = MOV32rr $esi
    $r15 = MOV64rr $rdi
    renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
    renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
    MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
    MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
    renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
    $r13d = MOV32rr killed $eax
    $rdi = MOV64rr $r15
    CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
    dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
    renamable $eax = MOV32ri 1
    TEST8ri renamable $r14b, 1, implicit-def $eflags
    renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
    FAKE_USE renamable $eax, implicit killed $rax
    renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
    renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
    FAKE_USE killed renamable $r11d
    TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
    RET64

...
---
name:            disabled
alignment:       16
tracksRegLiveness: true
noPhis:          true
noVRegs:         true
hasFakeUses:     true
tracksDebugUserValues: true
debugInstrRef: false
liveins:
  - { reg: '$rdi', virtual-reg: '' }
  - { reg: '$esi', virtual-reg: '' }
  - { reg: '$rdx', virtual-reg: '' }
frameInfo:
  isCalleeSavedInfoValid: true
stack:
  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
  - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
      stack-id: default, callee-saved-register: '', callee-saved-restored: true,
      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
body:             |
  bb.0:
    liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx

    ; CHECK-LABEL: name: disabled
    ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
    ; CHECK-NEXT: {{  $}}
    ; CHECK-NEXT: $rbx = MOV64rr $rdx
    ; CHECK-NEXT: $r14d = MOV32rr $esi
    ; CHECK-NEXT: $r15 = MOV64rr $rdi
    ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
    ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
    ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
    ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
    ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
    ; CHECK-NEXT: $r13d = MOV32rr killed $eax
    ; CHECK-NEXT: $rdi = MOV64rr $r15
    ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
    ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
    ; CHECK-NEXT: renamable $eax = MOV32ri 1
    ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags

    ;; Verify that when instr-ref is disabled, we do not remove fake uses.
    ; CHECK-NEXT: renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
    ; CHECK-NEXT: FAKE_USE renamable $eax, implicit killed $rax
    ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
    ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
    ; CHECK-NEXT: FAKE_USE killed renamable $r11d
    ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
    ; CHECK-NEXT: RET64
    $rbx = MOV64rr $rdx
    $r14d = MOV32rr $esi
    $r15 = MOV64rr $rdi
    renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
    renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
    MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
    MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
    renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
    $r13d = MOV32rr killed $eax
    $rdi = MOV64rr $r15
    CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
    dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
    renamable $eax = MOV32ri 1
    TEST8ri renamable $r14b, 1, implicit-def $eflags
    renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
    FAKE_USE renamable $eax, implicit killed $rax
    renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
    renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
    FAKE_USE killed renamable $r11d
    TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
    RET64

...