Skip to content

Commit 7161f38

Browse files
committed
Prefer SIRegisterInfo to MCRegisterInfo and add braces
1 parent aa9705f commit 7161f38

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
}
@@ -1227,12 +1228,13 @@ void SIFrameLowering::emitCSRSpillStores(MachineFunction &MF,
12271228
int FI = Reg.second;
12281229
buildPrologSpill(ST, TRI, *FuncInfo, LiveUnits, MF, MBB, MBBI, DL,
12291230
VGPR, FI, FrameReg);
1230-
if (NeedsFrameMoves)
1231+
if (NeedsFrameMoves) {
12311232
// We spill the entire VGPR, so we can get away with just cfi_offset
12321233
buildCFI(MBB, MBBI, DL,
12331234
MCCFIInstruction::createOffset(
12341235
nullptr, MCRI->getDwarfRegNum(VGPR, false),
12351236
MFI.getObjectOffset(FI) * ST.getWavefrontSize()));
1237+
}
12361238
}
12371239
};
12381240

@@ -1281,7 +1283,7 @@ void SIFrameLowering::emitCSRSpillStores(MachineFunction &MF,
12811283
// Skip if FP is saved to a scratch SGPR, the save has already been emitted.
12821284
// Otherwise, FP has been moved to a temporary register and spill it
12831285
// instead.
1284-
bool IsFramePtrPrologSpill = Spill.first == FramePtrReg ? true : false;
1286+
bool IsFramePtrPrologSpill = Spill.first == FramePtrReg;
12851287
Register Reg = IsFramePtrPrologSpill ? FramePtrRegScratchCopy : Spill.first;
12861288
if (!Reg)
12871289
continue;
@@ -1650,11 +1652,9 @@ void SIFrameLowering::emitEpilogue(MachineFunction &MF,
16501652
FramePtrRegScratchCopy);
16511653
}
16521654

1653-
const bool NeedsFrameMoves = MF.needsFrameMoves();
1654-
if (hasFP(MF)) {
1655-
if (NeedsFrameMoves)
1656-
emitDefCFA(MBB, MBBI, DL, StackPtrReg, /*AspaceAlreadyDefined=*/false,
1657-
MachineInstr::FrameDestroy);
1655+
if (hasFP(MF) && MF.needsFrameMoves()) {
1656+
emitDefCFA(MBB, MBBI, DL, StackPtrReg, /*AspaceAlreadyDefined=*/false,
1657+
MachineInstr::FrameDestroy);
16581658
}
16591659

16601660
if (FPSaved) {

0 commit comments

Comments
 (0)