[llvm] [RISCV] Force a frame pointer when the max reserved call frame exceeds simm12. (PR #182124)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 18 13:54:40 PST 2026
================
@@ -486,9 +486,26 @@ bool RISCVFrameLowering::hasFPImpl(const MachineFunction &MF) const {
const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
const MachineFrameInfo &MFI = MF.getFrameInfo();
- return MF.getTarget().Options.DisableFramePointerElim(MF) ||
- RegInfo->hasStackRealignment(MF) || MFI.hasVarSizedObjects() ||
- MFI.isFrameAddressTaken();
+ if (MF.getTarget().Options.DisableFramePointerElim(MF) ||
+ RegInfo->hasStackRealignment(MF) || MFI.hasVarSizedObjects() ||
+ MFI.isFrameAddressTaken())
+ return true;
+
+ // With large callframes around we may need to use FP to access the scavenging
+ // emergency spillslot.
+ //
+ // We calculate the MaxCallFrameSize at the end of isel so this value should
+ // be stable for the whole post-isel MIR pipeline.
+ //
+ // NOTE: The idea of forcing a frame pointer is copied from AArch64, but they
+ // conservatively return true when the call frame size hasd not been
+ // computed yet. On RISC-V that caused MachineOutliner tests to fail the
+ // MachineVerifier due to outlined functions not computing max call frame
+ // size thus the frame pointr would always be reserved.
----------------
lenary wrote:
```suggestion
// size thus the frame pointer would always be reserved.
```
https://github.com/llvm/llvm-project/pull/182124
More information about the llvm-commits
mailing list