diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2019-02-06 06:00:02 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2019-02-06 06:00:02 +0000 |
commit | 61e6ffc398e9b1e25488ea5b0dda546f18ef61e4 (patch) | |
tree | 5cc1c2430bcdf376131d63c0f30703c178716442 | |
parent | bad4db8b1a16545d601ac26fc7e2dd040af23135 (diff) | |
download | bcm5719-llvm-61e6ffc398e9b1e25488ea5b0dda546f18ef61e4.tar.gz bcm5719-llvm-61e6ffc398e9b1e25488ea5b0dda546f18ef61e4.zip |
[NFC] Extend API of DeleteDeadBlock(s) to collect updates without DTU
llvm-svn: 353274
-rw-r--r-- | llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h | 13 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 15 |
2 files changed, 20 insertions, 8 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h index a08d2a760a2..8134483b67d 100644 --- a/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -40,14 +40,21 @@ class TargetLibraryInfo; class Value; /// Delete the specified block, which must have no predecessors. -void DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU = nullptr); +void DeleteDeadBlock( + BasicBlock *BB, DomTreeUpdater *DTU = nullptr, + SmallVectorImpl<DominatorTree::UpdateType> *DTUpdates = nullptr); /// Delete the specified blocks from \p BB. The set of deleted blocks must have /// no predecessors that are not being deleted themselves. \p BBs must have no /// duplicating blocks. If there are loops among this set of blocks, all /// relevant loop info updates should be done before this function is called. -void DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, - DomTreeUpdater *DTU = nullptr); +/// If \p DTU is specified, all updates of DomTree are done immediately using +/// this updater. +/// If \p DTUpdates is specified, all updates to DomTree are also appended to +/// this vector, no matter if DTU is specified. +void DeleteDeadBlocks( + ArrayRef<BasicBlock *> BBs, DomTreeUpdater *DTU = nullptr, + SmallVectorImpl<DominatorTree::UpdateType> *DTUpdates = nullptr); /// We know that BB has one predecessor. If there are any single-entry PHI nodes /// in it, fold them away. This handles the case when all entries to the PHI diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index cb8614fcb98..82b9979cfc5 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -47,12 +47,15 @@ using namespace llvm; -void llvm::DeleteDeadBlock(BasicBlock *BB, DomTreeUpdater *DTU) { - DeleteDeadBlocks({BB}, DTU); +void llvm::DeleteDeadBlock( + BasicBlock *BB, DomTreeUpdater *DTU, + SmallVectorImpl<DominatorTree::UpdateType> *DTUpdates) { + DeleteDeadBlocks({BB}, DTU, DTUpdates); } -void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, - DomTreeUpdater *DTU) { +void llvm::DeleteDeadBlocks( + ArrayRef<BasicBlock *> BBs, DomTreeUpdater *DTU, + SmallVectorImpl<DominatorTree::UpdateType> *DTUpdates) { #ifndef NDEBUG // Make sure that all predecessors of each dead block is also dead. SmallPtrSet<BasicBlock *, 4> Dead(BBs.begin(), BBs.end()); @@ -68,7 +71,7 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, // of their predecessors is going away. for (BasicBlock *Succ : successors(BB)) { Succ->removePredecessor(BB); - if (DTU) + if (DTU || DTUpdates) Updates.push_back({DominatorTree::Delete, BB, Succ}); } @@ -92,6 +95,8 @@ void llvm::DeleteDeadBlocks(ArrayRef <BasicBlock *> BBs, } if (DTU) DTU->applyUpdates(Updates, /*ForceRemoveDuplicates*/ true); + if (DTUpdates) + DTUpdates->append(Updates.begin(), Updates.end()); for (BasicBlock *BB : BBs) if (DTU) |