Skip to content

Commit 555d68f

Browse files
authored
[RISCV] Use implicit def/use of SP for PROBED_STACKALLOC*. (#139153)
1 parent 7175970 commit 555d68f

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,6 @@ void RISCVFrameLowering::allocateAndProbeStackForRVV(
633633

634634
// It will be expanded to a probe loop in `inlineStackProbe`.
635635
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC_RVV))
636-
.addReg(SPReg)
637636
.addReg(TargetReg);
638637

639638
if (EmitCFI) {
@@ -828,9 +827,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,
828827
}
829828

830829
// It will be expanded to a probe loop in `inlineStackProbe`.
831-
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC))
832-
.addReg(SPReg)
833-
.addReg(TargetReg);
830+
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC)).addReg(TargetReg);
834831

835832
if (EmitCFI) {
836833
// Set the CFA register back to SP.
@@ -2433,7 +2430,7 @@ void RISCVFrameLowering::inlineStackProbe(MachineFunction &MF,
24332430
MI->getOpcode() == RISCV::PROBED_STACKALLOC_RVV) {
24342431
MachineBasicBlock::iterator MBBI = MI->getIterator();
24352432
DebugLoc DL = MBB.findDebugLoc(MBBI);
2436-
Register TargetReg = MI->getOperand(1).getReg();
2433+
Register TargetReg = MI->getOperand(0).getReg();
24372434
emitStackProbeInline(MBBI, DL, TargetReg,
24382435
(MI->getOpcode() == RISCV::PROBED_STACKALLOC_RVV));
24392436
MBBI->eraseFromParent();

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,17 +1518,18 @@ def GIAddrRegImm :
15181518

15191519
/// Stack probing
15201520

1521-
let hasSideEffects = 1, mayLoad = 1, mayStore = 1, isCodeGenOnly = 1 in {
1521+
let hasSideEffects = 1, mayLoad = 1, mayStore = 1, isCodeGenOnly = 1,
1522+
Defs = [X2], Uses = [X2] in {
15221523
// Probed stack allocation of a constant size, used in function prologues when
15231524
// stack-clash protection is enabled.
1524-
def PROBED_STACKALLOC : Pseudo<(outs GPR:$sp),
1525-
(ins GPR:$target),
1526-
[]>,
1527-
Sched<[]>;
1528-
def PROBED_STACKALLOC_RVV : Pseudo<(outs GPR:$sp),
1525+
def PROBED_STACKALLOC : Pseudo<(outs),
15291526
(ins GPR:$target),
15301527
[]>,
15311528
Sched<[]>;
1529+
def PROBED_STACKALLOC_RVV : Pseudo<(outs),
1530+
(ins GPR:$target),
1531+
[]>,
1532+
Sched<[]>;
15321533
let usesCustomInserter = 1 in
15331534
def PROBED_STACKALLOC_DYN : Pseudo<(outs),
15341535
(ins GPR:$target),

0 commit comments

Comments
 (0)