Skip to content

Commit 0d4a75b

Browse files
committed
Fix check for instr-ref enabled, update test to check disabled case
1 parent a5fd7ee commit 0d4a75b

File tree

2 files changed

+57
-25
lines changed

2 files changed

+57
-25
lines changed

llvm/lib/CodeGen/RemoveLoadsIntoFakeUses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ INITIALIZE_PASS_END(RemoveLoadsIntoFakeUses, DEBUG_TYPE,
7979
bool RemoveLoadsIntoFakeUses::runOnMachineFunction(MachineFunction &MF) {
8080
// Skip this pass if we would use VarLoc-based LDV, as there may be DBG_VALUE
8181
// instructions of the restored values that would become invalid.
82-
if (debuginfoShouldUseDebugInstrRef(MF.getTarget().getTargetTriple()))
82+
if (!MF.shouldUseDebugInstrRef())
8383
return false;
8484
// Only run this for functions that have fake uses.
8585
if (!MF.hasFakeUses() || skipFunction(MF.getFunction()))

llvm/test/CodeGen/X86/fake-use-remove-loads.mir

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
22
# Ensure that loads into FAKE_USEs are correctly removed by the
33
# remove-loads-into-fake-uses pass.
4-
# RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - %s | FileCheck %s
4+
# RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - %s | FileCheck %s --check-prefix=ENABLED
5+
# RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses -experimental-debug-variable-locations=false 2>&1 -o - %s | FileCheck %s --check-prefixes=DISABLED
56
# REQUIRES: asserts
67
#
78
## We verify that:
@@ -39,35 +40,66 @@ body: |
3940
bb.0:
4041
liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
4142
42-
; CHECK-LABEL: name: _ZN1g1jEv
43-
; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
44-
; CHECK-NEXT: {{ $}}
45-
; CHECK-NEXT: $rbx = MOV64rr $rdx
46-
; CHECK-NEXT: $r14d = MOV32rr $esi
47-
; CHECK-NEXT: $r15 = MOV64rr $rdi
48-
; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
49-
; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
43+
44+
45+
46+
47+
; ENABLED-LABEL: name: _ZN1g1jEv
48+
; ENABLED: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
49+
; ENABLED-NEXT: {{ $}}
50+
; ENABLED-NEXT: $rbx = MOV64rr $rdx
51+
; ENABLED-NEXT: $r14d = MOV32rr $esi
52+
; ENABLED-NEXT: $r15 = MOV64rr $rdi
53+
; ENABLED-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
54+
; ENABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
5055
5156
;; The store to the stack slot is still present.
52-
; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
53-
54-
; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
55-
; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
56-
; CHECK-NEXT: $r13d = MOV32rr killed $eax
57-
; CHECK-NEXT: $rdi = MOV64rr $r15
58-
; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
59-
; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
60-
; CHECK-NEXT: renamable $eax = MOV32ri 1
61-
; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
57+
; ENABLED-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
58+
59+
; ENABLED-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
60+
; ENABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
61+
; ENABLED-NEXT: $r13d = MOV32rr killed $eax
62+
; ENABLED-NEXT: $rdi = MOV64rr $r15
63+
; ENABLED-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
64+
; ENABLED-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
65+
; ENABLED-NEXT: renamable $eax = MOV32ri 1
66+
; ENABLED-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
6267
6368
;; First FAKE_USE and its corresponding load are removed; second FAKE_USE of
6469
;; a restored value that is also used is preserved.
65-
; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
66-
; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
67-
; CHECK-NEXT: FAKE_USE killed renamable $r11d
70+
; ENABLED-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
71+
; ENABLED-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
72+
; ENABLED-NEXT: FAKE_USE killed renamable $r11d
73+
74+
; ENABLED-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
75+
; ENABLED-NEXT: RET64
76+
;
77+
; DISABLED-LABEL: name: _ZN1g1jEv
78+
; DISABLED: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx
79+
; DISABLED-NEXT: {{ $}}
80+
; DISABLED-NEXT: $rbx = MOV64rr $rdx
81+
; DISABLED-NEXT: $r14d = MOV32rr $esi
82+
; DISABLED-NEXT: $r15 = MOV64rr $rdi
83+
; DISABLED-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12
84+
; DISABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax
85+
; DISABLED-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0)
86+
; DISABLED-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1)
87+
; DISABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags
88+
; DISABLED-NEXT: $r13d = MOV32rr killed $eax
89+
; DISABLED-NEXT: $rdi = MOV64rr $r15
90+
; DISABLED-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
91+
; DISABLED-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg
92+
; DISABLED-NEXT: renamable $eax = MOV32ri 1
93+
; DISABLED-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags
6894
69-
; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
70-
; CHECK-NEXT: RET64
95+
;; Verify that when instr-ref is disabled, we do not remove fake uses.
96+
; DISABLED-NEXT: renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0)
97+
; DISABLED-NEXT: FAKE_USE renamable $eax, implicit killed $rax
98+
; DISABLED-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1)
99+
; DISABLED-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags
100+
; DISABLED-NEXT: FAKE_USE killed renamable $r11d
101+
; DISABLED-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags
102+
; DISABLED-NEXT: RET64
71103
$rbx = MOV64rr $rdx
72104
$r14d = MOV32rr $esi
73105
$r15 = MOV64rr $rdi

0 commit comments

Comments
 (0)