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