[llvm] 555d68f - [RISCV] Use implicit def/use of SP for PROBED_STACKALLOC*. (#139153)
via llvm-commits
llvm-commits at lists.llvm.org
Fri May 16 14:43:25 PDT 2025
Author: Craig Topper
Date: 2025-05-16T14:43:22-07:00
New Revision: 555d68f3db3fd189809bd19dd274e3bf5ac68d2f
URL: https://github.com/llvm/llvm-project/commit/555d68f3db3fd189809bd19dd274e3bf5ac68d2f
DIFF: https://github.com/llvm/llvm-project/commit/555d68f3db3fd189809bd19dd274e3bf5ac68d2f.diff
LOG: [RISCV] Use implicit def/use of SP for PROBED_STACKALLOC*. (#139153)
Added:
Modified:
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index b80608c05ad57..470ebcbc83aff 100644
--- a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -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();
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index ef054120d5443..ac48c80c56bb8 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -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),
More information about the llvm-commits
mailing list