[llvm] ba217b4 - [RegisterScavenging] Add asserts for better errors

Sebastian Neubauer via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 9 02:26:30 PDT 2021


Author: Sebastian Neubauer
Date: 2021-04-09T11:23:36+02:00
New Revision: ba217b465532f9251cbd11c2863312e4044aebbb

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

LOG: [RegisterScavenging] Add asserts for better errors

These cases were failing before, but with cryptic asserts.
Add asserts in the RegScavenger that fail earlier with better
messages. NFC

Differential Revision: https://reviews.llvm.org/D100109

Added: 
    

Modified: 
    llvm/lib/CodeGen/RegisterScavenging.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/RegisterScavenging.cpp b/llvm/lib/CodeGen/RegisterScavenging.cpp
index e885bfd59569..1f23073076c5 100644
--- a/llvm/lib/CodeGen/RegisterScavenging.cpp
+++ b/llvm/lib/CodeGen/RegisterScavenging.cpp
@@ -369,6 +369,10 @@ findSurvivorBackwards(const MachineRegisterInfo &MRI,
   const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
   LiveRegUnits Used(TRI);
 
+  assert(From->getParent() == To->getParent() &&
+         "Target instruction is in other than current basic block, use "
+         "enterBasicBlockEnd first");
+
   for (MachineBasicBlock::iterator I = From;; --I) {
     const MachineInstr &MI = *I;
 
@@ -423,6 +427,8 @@ findSurvivorBackwards(const MachineRegisterInfo &MRI,
       if (I == MBB.begin())
         break;
     }
+    assert(I != MBB.begin() && "Did not find target instruction while "
+                               "iterating backwards");
   }
 
   return std::make_pair(Survivor, Pos);


        


More information about the llvm-commits mailing list