@@ -582,8 +582,9 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI,
582
582
583
583
void RISCVFrameLowering::allocateStack (MachineBasicBlock &MBB,
584
584
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 {
587
588
DebugLoc DL;
588
589
const RISCVRegisterInfo *RI = STI.getRegisterInfo ();
589
590
const RISCVInstrInfo *TII = STI.getInstrInfo ();
@@ -592,7 +593,9 @@ void RISCVFrameLowering::allocateStack(MachineBasicBlock &MBB,
592
593
getStackAlign ());
593
594
594
595
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));
596
599
BuildMI (MBB, MBBI, DL, TII->get (TargetOpcode::CFI_INSTRUCTION))
597
600
.addCFIIndex (CFIIndex)
598
601
.setMIFlag (MachineInstr::FrameSetup);
@@ -715,10 +718,8 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
715
718
716
719
if (StackSize != 0 ) {
717
720
// 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 );
722
723
}
723
724
724
725
// The frame pointer is callee-saved, and code has been generated for us to
@@ -760,12 +761,8 @@ void RISCVFrameLowering::emitPrologue(MachineFunction &MF,
760
761
assert (SecondSPAdjustAmount > 0 &&
761
762
" SecondSPAdjustAmount should be greater than zero" );
762
763
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));
769
766
}
770
767
771
768
if (RVVStackSize) {
0 commit comments