@@ -607,20 +607,22 @@ bool RISCVRegisterInfo::needsFrameBaseReg(MachineInstr *MI,
607607 const MachineFrameInfo &MFI = MF.getFrameInfo ();
608608 const RISCVFrameLowering *TFI = getFrameLowering (MF);
609609 const MachineRegisterInfo &MRI = MF.getRegInfo ();
610- unsigned CalleeSavedSize = 0 ;
611610 Offset += getFrameIndexInstrOffset (MI, FIOperandNum);
612611
613- // Estimate the stack size used to store callee saved registers(
614- // excludes reserved registers).
615- BitVector ReservedRegs = getReservedRegs (MF);
616- for (const MCPhysReg *R = MRI.getCalleeSavedRegs (); MCPhysReg Reg = *R; ++R) {
617- if (!ReservedRegs.test (Reg))
618- CalleeSavedSize += getSpillSize (*getMinimalPhysRegClass (Reg));
619- }
612+ if (TFI->hasFP (MF) && !shouldRealignStack (MF)) {
613+ // Estimate the stack size used to store callee saved registers(
614+ // excludes reserved registers).
615+ unsigned CalleeSavedSize = 0 ;
616+ BitVector ReservedRegs = getReservedRegs (MF);
617+ for (const MCPhysReg *R = MRI.getCalleeSavedRegs (); MCPhysReg Reg = *R;
618+ ++R) {
619+ if (!ReservedRegs.test (Reg))
620+ CalleeSavedSize += getSpillSize (*getMinimalPhysRegClass (Reg));
621+ }
620622
621- int64_t MaxFPOffset = Offset - CalleeSavedSize;
622- if (TFI->hasFP (MF) && !shouldRealignStack (MF))
623+ int64_t MaxFPOffset = Offset - CalleeSavedSize;
623624 return !isFrameOffsetLegal (MI, RISCV::X8, MaxFPOffset);
625+ }
624626
625627 // Assume 128 bytes spill slots size to estimate the maximum possible
626628 // offset relative to the stack pointer.
0 commit comments