[llvm] r353274 - [NFC] Extend API of DeleteDeadBlock(s) to collect updates without DTU
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 5 22:00:03 PST 2019
Author: mkazantsev
Date: Tue Feb 5 22:00:02 2019
New Revision: 353274
URL: http://llvm.org/viewvc/llvm-project?rev=353274&view=rev
Log:
[NFC] Extend API of DeleteDeadBlock(s) to collect updates without DTU
Modified:
llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=353274&r1=353273&r2=353274&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Tue Feb 5 22:00:02 2019
@@ -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
Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=353274&r1=353273&r2=353274&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Tue Feb 5 22:00:02 2019
@@ -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 <Ba
// 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 <Ba
}
if (DTU)
DTU->applyUpdates(Updates, /*ForceRemoveDuplicates*/ true);
+ if (DTUpdates)
+ DTUpdates->append(Updates.begin(), Updates.end());
for (BasicBlock *BB : BBs)
if (DTU)
More information about the llvm-commits
mailing list