[llvm] 22e596e - [AArch64] Fix debug printing crash in AArch64RedundantCopyElimination

David Green via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 03:49:41 PDT 2023


Author: David Green
Date: 2023-08-23T11:49:36+01:00
New Revision: 22e596e986511b6f7a4ef2ffbd7d6fefe5d02607

URL: https://github.com/llvm/llvm-project/commit/22e596e986511b6f7a4ef2ffbd7d6fefe5d02607
DIFF: https://github.com/llvm/llvm-project/commit/22e596e986511b6f7a4ef2ffbd7d6fefe5d02607.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
index 369801a8ea7ced..1494312886a40d 100644
--- a/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
+++ b/llvm/lib/Target/AArch64/AArch64RedundantCopyElimination.cpp
@@ -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))


        


More information about the llvm-commits mailing list