[Dominators] Teach LoopDeletion to use the new incremental API
authorJakub Kuderski <kubakuderski@gmail.com>
Wed, 2 Aug 2017 18:17:52 +0000 (18:17 +0000)
committerJakub Kuderski <kubakuderski@gmail.com>
Wed, 2 Aug 2017 18:17:52 +0000 (18:17 +0000)
commitd869913f3bdb218fcc0e4357b01f1e5ecd8da2b4
treec51f3e4e9e9e7cbc446f310b3154daf7f668d4cb
parent0bd906ec8f7839ac9a802b82b48444d647bba88c
[Dominators] Teach LoopDeletion to use the new incremental API

Summary:
This patch makes LoopDeletion use the incremental DominatorTree API.

We modify LoopDeletion to perform the deletion in 5 steps:
1. Create a new dummy edge from the preheader to the exit, by adding a conditional branch.
2. Inform the DomTree about the new edge.
3. Remove the conditional branch and replace it with an unconditional edge to the exit. This removes the edge to the loop header, making it unreachable.
4. Inform the DomTree about the deleted edge.
5. Remove the unreachable block from the function.

Creating the dummy conditional branch is necessary to perform incremental DomTree update.
We should consider using the batch updater when it's ready.

Reviewers: dberlin, davide, grosser, sanjoy

Reviewed By: dberlin, grosser

Subscribers: mzolotukhin, llvm-commits

Differential Revision: https://reviews.llvm.org/D35391

llvm-svn: 309850
llvm/include/llvm/Support/GenericDomTree.h
llvm/lib/Transforms/Scalar/LoopDeletion.cpp
llvm/test/Transforms/LoopDeletion/2017-07-11-incremental-dt.ll [new file with mode: 0644]
llvm/unittests/IR/DominatorTreeTest.cpp