Skip to content

Commit 1c80a6c

Browse files
committed
[Statepoints] FixupStatepoint: properly set isKill on spilled register.
When spilling statepoint meta arg register it is incorrect to blindly mark it as killed - it may be used in non-meta args (e.g., as call parameter).
1 parent 891b2be commit 1c80a6c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,14 @@ static Register performCopyPropagation(Register Reg,
157157
MachineBasicBlock::iterator &RI,
158158
bool &IsKill, const TargetInstrInfo &TII,
159159
const TargetRegisterInfo &TRI) {
160-
if (!EnableCopyProp)
161-
return Reg;
162-
163160
// First check if statepoint itself uses Reg in non-meta operands.
164161
int Idx = RI->findRegisterUseOperandIdx(Reg, false, &TRI);
165-
if (Idx >= 0 && (unsigned)Idx < StatepointOpers(&*RI).getNumDeoptArgsIdx())
162+
if (Idx >= 0 && (unsigned)Idx < StatepointOpers(&*RI).getNumDeoptArgsIdx()) {
163+
IsKill = false;
164+
return Reg;
165+
}
166+
167+
if (!EnableCopyProp)
166168
return Reg;
167169

168170
MachineBasicBlock *MBB = RI->getParent();

llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved | FileCheck %s
2+
# RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved -verify-machineinstrs | FileCheck %s
33

44
# Check that COPY is not eliminated if dest register is used in
55
# non-meta arguments of statepoint.
@@ -76,7 +76,7 @@ body: |
7676
; CHECK: liveins: $rcx, $rsi
7777
; CHECK: renamable $rdi = COPY $rsi
7878
; CHECK: MOV64mr %stack.0, 1, $noreg, 0, $noreg, killed renamable $rcx :: (store 8 into %stack.0)
79-
; CHECK: MOV64mr %stack.1, 1, $noreg, 0, $noreg, killed $rdi :: (store 8 into %stack.1)
79+
; CHECK: MOV64mr %stack.1, 1, $noreg, 0, $noreg, $rdi :: (store 8 into %stack.1)
8080
; CHECK: STATEPOINT 0, 0, 1, @foo, $rdi, 2, 0, 2, 0, 2, 1, 1, 8, %stack.1, 0, 1, 8, %stack.0, 0, 1, 8, %stack.0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (volatile load store 8 on %stack.0), (load 8 from %stack.1)
8181
; CHECK: renamable $rax = MOV64rm %stack.0, 1, $noreg, 0, $noreg :: (load 8 from %stack.0)
8282
; CHECK: RET 0, $rax

0 commit comments

Comments
 (0)