-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[RISCV] Use implicit def/use of SP for PROBED_STACKALLOC*. #139153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CC: @rzinsly |
@llvm/pr-subscribers-backend-risc-v Author: Craig Topper (topperc) ChangesFull diff: https://github.com/llvm/llvm-project/pull/139153.diff 2 Files Affected:
diff --git a/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp b/llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
index 72bec74584059..68907ba4a85d9 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) {
@@ -829,7 +828,6 @@ 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);
if (EmitCFI) {
@@ -2420,7 +2418,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 4a4290483e94b..e4ab8ff40b079 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -1452,17 +1452,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:$scratch),
- []>,
- Sched<[]>;
-def PROBED_STACKALLOC_RVV : Pseudo<(outs GPR:$sp),
- (ins GPR:$scratch),
+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 GPR:$rd),
(ins GPR:$scratch),
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
def PROBED_STACKALLOC_RVV : Pseudo<(outs), | ||
(ins GPR:$target), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(pedantic nit) Not sure it makes any difference, but from liveness point of view this should probably be:
def PROBED_STACKALLOC_RVV : Pseudo<(outs), | |
(ins GPR:$target), | |
let Constraints = "$scratch = $target" in | |
def PROBED_STACKALLOC_RVV : Pseudo<(outs GPR:$scratch), | |
(ins GPR:$target), |
since RVV expansion modifies the $target
register.
No description provided.