I filed a bug https://bugs.llvm.org/show_bug.cgi?id=35884 which I want to fix but I’m in trouble with detecting who is wrong
The story is as follows:
LoopDeletion tries to delete an invariant loop which has a def with use in some unreachable block.
The IR is well-formed due to any use in unreachable block is dominated as Verifier states.
LoopDeletion detected the loop as invariant due to LCSSA builder did not create a Phi node for this def because this def is in
block which does not dominate exit.
When BB with def is destroyed the destroying of def instruction causes an assert due to it has use.
So I wonder who is wrong here:
LCSSA which did not create a Phi node
LoopDeletion which did not take into account that instruction can be used in unreachable block and used a bulk deletion.
Any help is appreciated.