174 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 52# Ensure that loads into FAKE_USEs are correctly removed by the3# remove-loads-into-fake-uses pass, and that if the function does not use4# instruction referencing then no changes are made.5# 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 %s6# RUN: llc %s -passes remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - | FileCheck %s7 8# REQUIRES: asserts9#10## We verify that:11## - The load into the FAKE_USE is removed, along with the FAKE_USE itself,12## even when the FAKE_USE is for a subregister of the move.13## - We correctly handle situations where FAKE_USE has additional `killed`14## operands added by other passes.15## - The store to the stack slot still exists.16## - When the register has a use between the restore and the FAKE_USE, we do17## not delete the load or fake use.18 19 20---21name: enabled22alignment: 1623tracksRegLiveness: true24noPhis: true25noVRegs: true26hasFakeUses: true27tracksDebugUserValues: true28debugInstrRef: true29liveins:30 - { reg: '$rdi', virtual-reg: '' }31 - { reg: '$esi', virtual-reg: '' }32 - { reg: '$rdx', virtual-reg: '' }33frameInfo:34 isCalleeSavedInfoValid: true35stack:36 - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,37 stack-id: default, callee-saved-register: '', callee-saved-restored: true,38 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }39 - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,40 stack-id: default, callee-saved-register: '', callee-saved-restored: true,41 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }42body: |43 bb.0:44 liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx45 46 ; CHECK-LABEL: name: enabled47 ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx48 ; CHECK-NEXT: {{ $}}49 ; CHECK-NEXT: $rbx = MOV64rr $rdx50 ; CHECK-NEXT: $r14d = MOV32rr $esi51 ; CHECK-NEXT: $r15 = MOV64rr $rdi52 ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r1253 ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax54 55 ;; The store to the stack slot is still present.56 ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)57 58 ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)59 ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags60 ; CHECK-NEXT: $r13d = MOV32rr killed $eax61 ; CHECK-NEXT: $rdi = MOV64rr $r1562 ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp63 ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg64 ; CHECK-NEXT: renamable $eax = MOV32ri 165 ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags66 67 ;; First FAKE_USE and its corresponding load are removed; second FAKE_USE of68 ;; a restored value that is also used is preserved.69 ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)70 ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags71 ; CHECK-NEXT: FAKE_USE killed renamable $r11d72 73 ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags74 ; CHECK-NEXT: RET6475 76 $rbx = MOV64rr $rdx77 $r14d = MOV32rr $esi78 $r15 = MOV64rr $rdi79 renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r1280 renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax81 MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)82 MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)83 renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags84 $r13d = MOV32rr killed $eax85 $rdi = MOV64rr $r1586 CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp87 dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg88 renamable $eax = MOV32ri 189 TEST8ri renamable $r14b, 1, implicit-def $eflags90 renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)91 FAKE_USE renamable $eax, implicit killed $rax92 renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)93 renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags94 FAKE_USE killed renamable $r11d95 TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags96 RET6497 98...99---100name: disabled101alignment: 16102tracksRegLiveness: true103noPhis: true104noVRegs: true105hasFakeUses: true106tracksDebugUserValues: true107debugInstrRef: false108liveins:109 - { reg: '$rdi', virtual-reg: '' }110 - { reg: '$esi', virtual-reg: '' }111 - { reg: '$rdx', virtual-reg: '' }112frameInfo:113 isCalleeSavedInfoValid: true114stack:115 - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,116 stack-id: default, callee-saved-register: '', callee-saved-restored: true,117 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }118 - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,119 stack-id: default, callee-saved-register: '', callee-saved-restored: true,120 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }121body: |122 bb.0:123 liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx124 125 ; CHECK-LABEL: name: disabled126 ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx127 ; CHECK-NEXT: {{ $}}128 ; CHECK-NEXT: $rbx = MOV64rr $rdx129 ; CHECK-NEXT: $r14d = MOV32rr $esi130 ; CHECK-NEXT: $r15 = MOV64rr $rdi131 ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12132 ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax133 ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)134 ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)135 ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags136 ; CHECK-NEXT: $r13d = MOV32rr killed $eax137 ; CHECK-NEXT: $rdi = MOV64rr $r15138 ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp139 ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg140 ; CHECK-NEXT: renamable $eax = MOV32ri 1141 ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags142 143 ;; Verify that when instr-ref is disabled, we do not remove fake uses.144 ; CHECK-NEXT: renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)145 ; CHECK-NEXT: FAKE_USE renamable $eax, implicit killed $rax146 ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)147 ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags148 ; CHECK-NEXT: FAKE_USE killed renamable $r11d149 ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags150 ; CHECK-NEXT: RET64151 $rbx = MOV64rr $rdx152 $r14d = MOV32rr $esi153 $r15 = MOV64rr $rdi154 renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12155 renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax156 MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)157 MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)158 renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags159 $r13d = MOV32rr killed $eax160 $rdi = MOV64rr $r15161 CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp162 dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg163 renamable $eax = MOV32ri 1164 TEST8ri renamable $r14b, 1, implicit-def $eflags165 renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)166 FAKE_USE renamable $eax, implicit killed $rax167 renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)168 renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags169 FAKE_USE killed renamable $r11d170 TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags171 RET64172 173...174