[SimpleLoopUnswitch] remove a chain of dead blocks at once
authorFedor Sergeev <fedor.sergeev@azul.com>
Tue, 4 Sep 2018 20:19:41 +0000 (20:19 +0000)
committerFedor Sergeev <fedor.sergeev@azul.com>
Tue, 4 Sep 2018 20:19:41 +0000 (20:19 +0000)
commit8b6effd9690024d8138de9c903d88a0c3f706487
treeb82c48d08fe2ac9865fffb191afdf2e112132cfe
parentc43f006bc22b59b6eb7a906580cf567000d6e41d
[SimpleLoopUnswitch] remove a chain of dead blocks at once

Recent change to deleteDeadBlocksFromLoop was not enough to
fix all the problems related to dead blocks after nontrivial
unswitching of switches.

We need to delete all the dead blocks that were created during
unswitching, otherwise we will keep having problems with phi's
or dead blocks.

This change removes all the dead blocks that are reachable from the loop,
not trying to track whether these blocks are newly created by unswitching
or not. While not completely correct, we are unlikely to get loose but
reachable dead blocks that do not belong to our loop nest.

It does fix all the failures currently known, in particular PR38778.

Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D51519

llvm-svn: 341398
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
llvm/test/Transforms/SimpleLoopUnswitch/delete-dead-blocks.ll