[PATCH] D100109: [RegisterScavenging] Add asserts for better errors

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 8 07:31:44 PDT 2021


sebastian-ne created this revision.
sebastian-ne added reviewers: arsenm, craigblackmore.
Herald added a subscriber: hiraditya.
sebastian-ne requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100109

Files:
  llvm/lib/CodeGen/RegisterScavenging.cpp


Index: llvm/lib/CodeGen/RegisterScavenging.cpp
===================================================================
--- llvm/lib/CodeGen/RegisterScavenging.cpp
+++ llvm/lib/CodeGen/RegisterScavenging.cpp
@@ -369,6 +369,10 @@
   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 @@
       if (I == MBB.begin())
         break;
     }
+    assert(I != MBB.begin() && "Did not find target instruction while "
+                               "iterating backwards");
   }
 
   return std::make_pair(Survivor, Pos);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100109.336102.patch
Type: text/x-patch
Size: 822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/1766d533/attachment.bin>


More information about the llvm-commits mailing list