Skip to content

Commit

Permalink
[AArch64] Fix debug printing crash in AArch64RedundantCopyElimination
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davemgreen committed Aug 23, 2023
1 parent 50e1ad6 commit 22e596e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 22e596e

Please sign in to comment.