[RISCV] Use implicit def/use of SP for PROBED_STACKALLOC*. (#139153)

This commit is contained in:
Craig Topper
2025-05-16 14:43:22 -07:00
committed by GitHub
parent 7175970fc5
commit 555d68f3db
2 changed files with 9 additions and 11 deletions

View File

@@ -633,7 +633,6 @@ void RISCVFrameLowering::allocateAndProbeStackForRVV(
// It will be expanded to a probe loop in `inlineStackProbe`.
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC_RVV))
.addReg(SPReg)
.addReg(TargetReg);
if (EmitCFI) {
@@ -828,9 +827,7 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,
}
// It will be expanded to a probe loop in `inlineStackProbe`.
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC))
.addReg(SPReg)
.addReg(TargetReg);
BuildMI(MBB, MBBI, DL, TII->get(RISCV::PROBED_STACKALLOC)).addReg(TargetReg);
if (EmitCFI) {
// Set the CFA register back to SP.
@@ -2433,7 +2430,7 @@ void RISCVFrameLowering::inlineStackProbe(MachineFunction &MF,
MI->getOpcode() == RISCV::PROBED_STACKALLOC_RVV) {
MachineBasicBlock::iterator MBBI = MI->getIterator();
DebugLoc DL = MBB.findDebugLoc(MBBI);
Register TargetReg = MI->getOperand(1).getReg();
Register TargetReg = MI->getOperand(0).getReg();
emitStackProbeInline(MBBI, DL, TargetReg,
(MI->getOpcode() == RISCV::PROBED_STACKALLOC_RVV));
MBBI->eraseFromParent();

View File

@@ -1518,17 +1518,18 @@ def GIAddrRegImm :
/// Stack probing
let hasSideEffects = 1, mayLoad = 1, mayStore = 1, isCodeGenOnly = 1 in {
let hasSideEffects = 1, mayLoad = 1, mayStore = 1, isCodeGenOnly = 1,
Defs = [X2], Uses = [X2] in {
// Probed stack allocation of a constant size, used in function prologues when
// stack-clash protection is enabled.
def PROBED_STACKALLOC : Pseudo<(outs GPR:$sp),
(ins GPR:$target),
[]>,
Sched<[]>;
def PROBED_STACKALLOC_RVV : Pseudo<(outs GPR:$sp),
def PROBED_STACKALLOC : Pseudo<(outs),
(ins GPR:$target),
[]>,
Sched<[]>;
def PROBED_STACKALLOC_RVV : Pseudo<(outs),
(ins GPR:$target),
[]>,
Sched<[]>;
let usesCustomInserter = 1 in
def PROBED_STACKALLOC_DYN : Pseudo<(outs),
(ins GPR:$target),