Skip to content

Commit 6a8411f

Browse files
committed
[AIEX] fix spillCalleeSavedRegisters crash
1 parent 9d58a20 commit 6a8411f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Target/AIE/AIEBaseFrameLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ bool AIEBaseFrameLowering::spillCalleeSavedRegisters(
219219
ArrayRef<CalleeSavedInfo> CSI, const TargetRegisterInfo *TRI) const {
220220
MachineFunction *MF = MBB.getParent();
221221
auto *TII = static_cast<const AIEBaseInstrInfo *>(STI.getInstrInfo());
222-
MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
223-
DebugLoc DL = MBBI->getDebugLoc();
222+
DebugLoc DL;
223+
if (auto MBBI = MBB.getLastNonDebugInstr(); MBBI != MBB.end())
224+
DL = MBBI->getDebugLoc(); // MBBI is valid
225+
224226
GPRTOCSGPRMap.clear();
225227
for (const CalleeSavedInfo &Info : CSI) {
226228
if (Info.isSpilledToReg()) {

0 commit comments

Comments
 (0)