The function LI.erase has some invariants that need to be preserved when it tries to
remove a loop which is not the top-level loop. In particular, it requires loop's preheader
to be strictly in loop's parent. Our current logic of deletion of dead blocks may erase the
information about preheader before we handle the loop, and therefore we may hit this
assertion.
This patch changes the logic of loop deletion: we make them top-level loops before
we actually erase them. This allows us to trigger the simple branch of erase logic which
just detatches blocks from the loop and does not try to do some complex stuff that need
this invariant.
Thanks to @uabelho for reporting this!
this REQUIRES was still needed because of the use of -debug-only.
Fixed in r353842