@@ -825,15 +825,16 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
825
825
RVFI->getVarArgsSaveSize ();
826
826
uint64_t RVVStackSize = RVFI->getRVVStackSize ();
827
827
828
- bool RestoreFP = RI->hasStackRealignment (MF) || MFI. hasVarSizedObjects ( ) ||
829
- !hasReservedCallFrame (MF);
828
+ bool RestoreSPFromFP = RI->hasStackRealignment (MF) ||
829
+ MFI. hasVarSizedObjects () || !hasReservedCallFrame (MF);
830
830
if (RVVStackSize) {
831
- // If RestoreFP the stack pointer will be restored using the frame pointer
832
- // value.
833
- if (!RestoreFP) {
831
+ // If RestoreSPFromFP the stack pointer will be restored using the frame
832
+ // pointer value.
833
+ if (!RestoreSPFromFP)
834
834
adjustStackForRVV (MF, MBB, LastFrameDestroy, DL, RVVStackSize,
835
835
MachineInstr::FrameDestroy);
836
836
837
+ if (!hasFP (MF)) {
837
838
unsigned CFIIndex = MF.addFrameInst (MCCFIInstruction::cfiDefCfa (
838
839
nullptr , RI->getDwarfRegNum (SPReg, true ), RealStackSize));
839
840
BuildMI (MBB, LastFrameDestroy, DL,
@@ -851,13 +852,14 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
851
852
assert (SecondSPAdjustAmount > 0 &&
852
853
" SecondSPAdjustAmount should be greater than zero" );
853
854
854
- // If RestoreFP the stack pointer will be restored using the frame pointer
855
- // value.
856
- if (!RestoreFP) {
855
+ // If RestoreSPFromFP the stack pointer will be restored using the frame
856
+ // pointer value.
857
+ if (!RestoreSPFromFP)
857
858
RI->adjustReg (MBB, LastFrameDestroy, DL, SPReg, SPReg,
858
859
StackOffset::getFixed (SecondSPAdjustAmount),
859
860
MachineInstr::FrameDestroy, getStackAlign ());
860
861
862
+ if (!hasFP (MF)) {
861
863
unsigned CFIIndex = MF.addFrameInst (
862
864
MCCFIInstruction::cfiDefCfaOffset (nullptr , FirstSPAdjustAmount));
863
865
BuildMI (MBB, LastFrameDestroy, DL,
@@ -877,13 +879,15 @@ void RISCVFrameLowering::emitEpilogue(MachineFunction &MF,
877
879
// normally it's just checking the variable sized object is present or not
878
880
// is enough, but we also don't preserve that at prologue/epilogue when
879
881
// have vector objects in stack.
880
- if (RestoreFP ) {
882
+ if (RestoreSPFromFP ) {
881
883
assert (hasFP (MF) && " frame pointer should not have been eliminated" );
882
884
883
885
RI->adjustReg (MBB, LastFrameDestroy, DL, SPReg, FPReg,
884
886
StackOffset::getFixed (-FPOffset), MachineInstr::FrameDestroy,
885
887
getStackAlign ());
888
+ }
886
889
890
+ if (hasFP (MF)) {
887
891
unsigned CFIIndex = MF.addFrameInst (MCCFIInstruction::cfiDefCfa (
888
892
nullptr , RI->getDwarfRegNum (SPReg, true ), RealStackSize));
889
893
BuildMI (MBB, LastFrameDestroy, DL, TII->get (TargetOpcode::CFI_INSTRUCTION))
0 commit comments