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

Sebastian Neubauer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 8 09:18:12 PDT 2021


sebastian-ne added inline comments.


================
Comment at: llvm/lib/CodeGen/RegisterScavenging.cpp:430
     }
+    assert(I != MBB.begin() && "Did not find target instruction while "
+                               "iterating backwards");
----------------
arsenm wrote:
> What if you did intend to scavenge at the beginning? Also seems weird to assert here when there's a break on begin above
I tried to scavenge a register with `scavengeRegisterBackwards` while the scavenger was in forward mode.
The break above gets only hit when `FoundTo == true`, so when `I == To`. If we never find `To` while iterating backwards from `From` (because `To` is somewhere down in the basic block), we will never break and it will crash when trying to access an invalid `I` (the error message is something like `Assertion failed: (!NodePtr->isKnownSentinel())`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100109/new/

https://reviews.llvm.org/D100109



More information about the llvm-commits mailing list