Skip to content

Commit 57452bb

Browse files
authored
[NFC][RISCV] Remove CFIIndex argument from allocateStack (#117871)
Calculates CFIIndex inside RISCVFrameLowering::allocateStack instead of sending it by argument.
1 parent a6fa51f commit 57452bb

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

llvm/lib/Target/RISCV/RISCVFrameLowering.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,9 @@ static MCCFIInstruction createDefCFAOffset(const TargetRegisterInfo &TRI,
582582

583583
void 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) {

llvm/lib/Target/RISCV/RISCVFrameLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class RISCVFrameLowering : public TargetFrameLowering {
7979
}
8080

8181
void allocateStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
82-
StackOffset Offset, bool EmitCFI, unsigned CFIIndex) const;
82+
MachineFunction &MF, StackOffset Offset,
83+
uint64_t RealStackSize, bool EmitCFI) const;
8384

8485
protected:
8586
const RISCVSubtarget &STI;

0 commit comments

Comments
 (0)