[llvm] [llvm] Support multiple save/restore points in mir (PR #119357)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 2 09:53:02 PDT 2025
================
@@ -478,12 +478,59 @@ bool RISCVRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
MachineInstr &MI = *II;
MachineFunction &MF = *MI.getParent()->getParent();
MachineRegisterInfo &MRI = MF.getRegInfo();
+ const MachineFrameInfo &MFI = MF.getFrameInfo();
DebugLoc DL = MI.getDebugLoc();
int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
Register FrameReg;
StackOffset Offset =
getFrameLowering(MF)->getFrameIndexReference(MF, FrameIndex, FrameReg);
+
+ const auto &CSI =
+ getFrameLowering(MF)->getUnmanagedCSI(MF, MFI.getCalleeSavedInfo());
+
+ if (!CSI.empty()) {
+ int MinCSFI = CSI.front().getFrameIdx();
+ int MaxCSFI = CSI.back().getFrameIdx();
+
+ // If our FrameIndex is CSI FrameIndex we in some cases need additional
+ // adjustment
+ if (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI) {
+ MachineBasicBlock *SpilledIn = nullptr;
+ MachineBasicBlock *RestoredIn = nullptr;
+ auto It = std::find_if(CSI.begin(), CSI.end(), [FrameIndex](auto &CS) {
+ return CS.getFrameIdx() == FrameIndex;
+ });
+
+ if (It != CSI.end()) {
----------------
michaelmaitland wrote:
IS it possible for this condition to be false? If so, will SpilledIn and RestoredIn be nullptr below? I think that would be an issue. If it cannot be false, maybe we should drop the `if` statement here.
https://github.com/llvm/llvm-project/pull/119357
More information about the llvm-commits
mailing list