This is an archive of the discontinued LLVM Phabricator instance.

[RegisterScavenging] Add asserts for better errors
ClosedPublic

Authored by sebastian-ne on Apr 8 2021, 7:31 AM.

Details

Summary

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

Diff Detail

Event Timeline

sebastian-ne created this revision.Apr 8 2021, 7:31 AM
sebastian-ne requested review of this revision.Apr 8 2021, 7:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2021, 7:31 AM
arsenm added inline comments.Apr 8 2021, 8:47 AM
llvm/lib/CodeGen/RegisterScavenging.cpp
430

What if you did intend to scavenge at the beginning? Also seems weird to assert here when there's a break on begin above

sebastian-ne added inline comments.Apr 8 2021, 9:18 AM
llvm/lib/CodeGen/RegisterScavenging.cpp
430

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())).

arsenm accepted this revision.Apr 8 2021, 10:31 AM
This revision is now accepted and ready to land.Apr 8 2021, 10:31 AM
This revision was automatically updated to reflect the committed changes.