[AArch64] Fix debug printing crash in AArch64RedundantCopyElimination

The LastChange can be MBB->end(), so it is not valid to dereference it for
printing. Fix the DEBUG statement to check for end() and handle it specially.
This commit is contained in:
David Green 2023-08-23 11:49:36 +01:00
parent 50e1ad6ed2
commit 22e596e986

View File

@ -462,7 +462,9 @@ bool AArch64RedundantCopyElimination::optimizeBlock(MachineBasicBlock *MBB) {
// Clear kills in the range where changes were made. This is conservative,
// but should be okay since kill markers are being phased out.
LLVM_DEBUG(dbgs() << "Clearing kill flags.\n\tFirstUse: " << *FirstUse
<< "\tLastChange: " << *LastChange);
<< "\tLastChange: ";
if (LastChange == MBB->end()) dbgs() << "<end>\n";
else dbgs() << *LastChange);
for (MachineInstr &MMI : make_range(FirstUse, PredMBB->end()))
MMI.clearKillInfo();
for (MachineInstr &MMI : make_range(MBB->begin(), LastChange))