Skip to content

Commit 0311f70

Browse files
committed
Prefer SIRegisterInfo to MCRegisterInfo and add braces
1 parent 19367bb commit 0311f70

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/lib/Target/AMDGPU/SIFrameLowering.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ void SIFrameLowering::emitDefCFA(MachineBasicBlock &MBB,
101101
MachineInstr::MIFlag Flags) const {
102102
MachineFunction &MF = *MBB.getParent();
103103
const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
104-
const MCRegisterInfo *MCRI = MF.getContext().getRegisterInfo();
104+
const SIRegisterInfo *TRI = ST.getRegisterInfo();
105105

106-
MCRegister DwarfStackPtrReg = MCRI->getDwarfRegNum(StackPtrReg, false);
106+
MCRegister DwarfStackPtrReg = TRI->getDwarfRegNum(StackPtrReg, false);
107107
MCCFIInstruction CFIInst =
108108
ST.enableFlatScratch()
109109
? createScaledCFAInPrivateWave(ST, DwarfStackPtrReg)
@@ -350,11 +350,12 @@ class PrologEpilogSGPRSpillBuilder {
350350

351351
// FIXME: CFI for EXEC needs a fix by accurately computing the spill
352352
// offset for both the low and high components.
353-
if (SubReg != AMDGPU::EXEC_LO)
353+
if (SubReg != AMDGPU::EXEC_LO) {
354354
TFI->buildCFI(MBB, MI, DL,
355355
MCCFIInstruction::createOffset(
356356
nullptr, MCRI->getDwarfRegNum(SubReg, false),
357357
MFI.getObjectOffset(FI) * ST.getWavefrontSize()));
358+
}
358359
}
359360
DwordOff += 4;
360361
}
@@ -1216,12 +1217,13 @@ void SIFrameLowering::emitCSRSpillStores(MachineFunction &MF,
12161217
int FI = Reg.second;
12171218
buildPrologSpill(ST, TRI, *FuncInfo, LiveUnits, MF, MBB, MBBI, DL,
12181219
VGPR, FI, FrameReg);
1219-
if (NeedsFrameMoves)
1220+
if (NeedsFrameMoves) {
12201221
// We spill the entire VGPR, so we can get away with just cfi_offset
12211222
buildCFI(MBB, MBBI, DL,
12221223
MCCFIInstruction::createOffset(
12231224
nullptr, MCRI->getDwarfRegNum(VGPR, false),
12241225
MFI.getObjectOffset(FI) * ST.getWavefrontSize()));
1226+
}
12251227
}
12261228
};
12271229

@@ -1270,7 +1272,7 @@ void SIFrameLowering::emitCSRSpillStores(MachineFunction &MF,
12701272
// Skip if FP is saved to a scratch SGPR, the save has already been emitted.
12711273
// Otherwise, FP has been moved to a temporary register and spill it
12721274
// instead.
1273-
bool IsFramePtrPrologSpill = Spill.first == FramePtrReg ? true : false;
1275+
bool IsFramePtrPrologSpill = Spill.first == FramePtrReg;
12741276
Register Reg = IsFramePtrPrologSpill ? FramePtrRegScratchCopy : Spill.first;
12751277
if (!Reg)
12761278
continue;
@@ -1639,11 +1641,9 @@ void SIFrameLowering::emitEpilogue(MachineFunction &MF,
16391641
FramePtrRegScratchCopy);
16401642
}
16411643

1642-
const bool NeedsFrameMoves = MF.needsFrameMoves();
1643-
if (hasFP(MF)) {
1644-
if (NeedsFrameMoves)
1645-
emitDefCFA(MBB, MBBI, DL, StackPtrReg, /*AspaceAlreadyDefined=*/false,
1646-
MachineInstr::FrameDestroy);
1644+
if (hasFP(MF) && MF.needsFrameMoves()) {
1645+
emitDefCFA(MBB, MBBI, DL, StackPtrReg, /*AspaceAlreadyDefined=*/false,
1646+
MachineInstr::FrameDestroy);
16471647
}
16481648

16491649
if (FPSaved) {

0 commit comments

Comments
 (0)