@@ -582,8 +582,9 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI,
582582
583583void RISCVFrameLowering::allocateStack (MachineBasicBlock &MBB,
584584 MachineBasicBlock::iterator MBBI,
585- StackOffset Offset, bool EmitCFI,
586- unsigned CFIIndex) const {
585+ MachineFunction &MF, StackOffset Offset,
586+ uint64_t RealStackSize,
587+ bool EmitCFI) const {
587588 DebugLoc DL;
588589 const RISCVRegisterInfo *RI = STI.getRegisterInfo ();
589590 const RISCVInstrInfo *TII = STI.getInstrInfo ();
@@ -592,7 +593,9 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,
592593 getStackAlign ());
593594
594595 if (EmitCFI) {
595- // Emit ".cfi_def_cfa_offset StackSize"
596+ // Emit ".cfi_def_cfa_offset RealStackSize"
597+ unsigned CFIIndex = MF.addFrameInst (
598+ MCCFIInstruction::cfiDefCfaOffset (nullptr , RealStackSize));
596599 BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::CFI_INSTRUCTION))
597600 .addCFIIndex (CFIIndex)
598601 .setMIFlag (MachineInstr::FrameSetup);
@@ -715,10 +718,8 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
715718
716719 if (StackSize != 0 ) {
717720 // Allocate space on the stack if necessary.
718- unsigned CFIIndex = MF.addFrameInst (
719- MCCFIInstruction::cfiDefCfaOffset (nullptr , RealStackSize));
720- allocateStack (MBB, MBBI, StackOffset::getFixed (-StackSize),
721- /* EmitCFI=*/ true , CFIIndex);
721+ allocateStack (MBB, MBBI, MF, StackOffset::getFixed (-StackSize),
722+ RealStackSize, /* EmitCFI=*/ true );
722723 }
723724
724725 // The frame pointer is callee-saved, and code has been generated for us to
@@ -760,12 +761,8 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
760761 assert (SecondSPAdjustAmount > 0 &&
761762 " SecondSPAdjustAmount should be greater than zero" );
762763
763- // If we are using a frame-pointer, and thus emitted ".cfi_def_cfa fp, 0",
764- // don't emit an sp-based .cfi_def_cfa_offset
765- unsigned CFIIndex = MF.addFrameInst (MCCFIInstruction::cfiDefCfaOffset (
766- nullptr , getStackSizeWithRVVPadding (MF)));
767- allocateStack (MBB, MBBI, StackOffset::getFixed (-SecondSPAdjustAmount),
768- !hasFP (MF), CFIIndex);
764+ allocateStack (MBB, MBBI, MF, StackOffset::getFixed (-SecondSPAdjustAmount),
765+ getStackSizeWithRVVPadding (MF), !hasFP (MF));
769766 }
770767
771768 if (RVVStackSize) {
0 commit comments