|
LLVM
7.0.0
|
Class to defer updates to a DominatorTree. More...
#include "llvm/IR/Dominators.h"
Public Member Functions | |
| DeferredDominance (DominatorTree &DT_) | |
| void | applyUpdates (ArrayRef< DominatorTree::UpdateType > Updates) |
| Queues multiple updates and discards duplicates. More... | |
| void | insertEdge (BasicBlock *From, BasicBlock *To) |
| Helper method for a single edge insertion. More... | |
| void | deleteEdge (BasicBlock *From, BasicBlock *To) |
| Helper method for a single edge deletion. More... | |
| void | deleteBB (BasicBlock *DelBB) |
| Delays the deletion of a basic block until a flush() event. More... | |
| bool | pendingDeletedBB (BasicBlock *DelBB) |
| Returns true if DelBB is awaiting deletion at a flush() event. More... | |
| bool | pending () |
| Returns true if pending DT updates are queued for a flush() event. More... | |
| DominatorTree & | flush () |
| Flushes all pending updates and block deletions. More... | |
| void | recalculate (Function &F) |
| Drops all internal state and forces a (slow) recalculation of the DominatorTree based on the current state of the LLVM IR in F. More... | |
| LLVM_DUMP_METHOD void | dump () const |
| Debug method to help view the state of pending updates. More... | |
Class to defer updates to a DominatorTree.
Definition: Applying updates to every edge insertion and deletion is expensive and not necessary. When one needs the DominatorTree for analysis they can request a flush() to perform a larger batch update. This has the advantage of the DominatorTree inspecting the set of updates to find duplicates or unnecessary subtree updates.
The scope of DeferredDominance operates at a Function level.
It is not necessary for the user to scrub the updates for duplicates or updates that point to the same block (Delete, BB_A, BB_A). Performance can be gained if the caller attempts to batch updates before submitting to applyUpdates(ArrayRef) in cases where duplicate edge requests will occur.
It is required for the state of the LLVM IR to be applied before submitting updates. The update routines must analyze the current state between a pair of (From, To) basic blocks to determine if the update needs to be queued. Example (good): TerminatorInstructionBB->removeFromParent(); DDT->deleteEdge(BB, Successor); Example (bad): DDT->deleteEdge(BB, Successor); TerminatorInstructionBB->removeFromParent();
Definition at line 307 of file Dominators.h.
|
inline |
Definition at line 309 of file Dominators.h.
References llvm::dump(), F(), Kind, and LLVM_DUMP_METHOD.
| void DeferredDominance::applyUpdates | ( | ArrayRef< DominatorTree::UpdateType > | Updates | ) |
Queues multiple updates and discards duplicates.
Definition at line 385 of file Dominators.cpp.
References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::none_of(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by llvm::changeToUnreachable(), llvm::ConstantFoldTerminator(), llvm::DeleteDeadBlock(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::removeUnreachableBlocks(), and llvm::TryToSimplifyUncondBranchFromEmptyBlock().
| void DeferredDominance::deleteBB | ( | BasicBlock * | DelBB | ) |
Delays the deletion of a basic block until a flush() event.
Definition at line 414 of file Dominators.cpp.
References assert(), llvm::BasicBlock::back(), llvm::BasicBlock::empty(), llvm::UndefValue::get(), llvm::BasicBlock::getContext(), llvm::BasicBlock::getInstList(), llvm::Value::getType(), I, llvm::iplist_impl< IntrusiveListT, TraitsT >::pop_back(), llvm::pred_empty(), llvm::Value::replaceAllUsesWith(), and llvm::Value::use_empty().
Referenced by llvm::DeleteDeadBlock(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::MergeBlockIntoPredecessor(), llvm::removeUnreachableBlocks(), and llvm::TryToSimplifyUncondBranchFromEmptyBlock().
| void DeferredDominance::deleteEdge | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Helper method for a single edge deletion.
It's almost always better to batch updates and call applyUpdates to quickly remove duplicate edges. This is best used when there is only a single deletion needed to update Dominators.
Definition at line 409 of file Dominators.cpp.
References llvm::DominatorTreeBase< BasicBlock, false >::Delete.
Referenced by llvm::ConstantFoldTerminator(), llvm::RemovePredecessorAndSimplify(), and llvm::removeUnwindEdge().
| LLVM_DUMP_METHOD void DeferredDominance::dump | ( | ) | const |
Debug method to help view the state of pending updates.
Definition at line 469 of file Dominators.cpp.
References llvm::any_of(), B, llvm::iplist_impl< IntrusiveListT, TraitsT >::clear(), llvm::dbgs(), llvm::DominatorTreeBase< BasicBlock, false >::Delete, E, llvm::BasicBlock::eraseFromParent(), llvm::Value::getName(), llvm::Value::hasName(), I, llvm::DominatorTreeBase< BasicBlock, false >::Insert, Kind, llvm::succ_begin(), and llvm::succ_end().
| DominatorTree & DeferredDominance::flush | ( | ) |
Flushes all pending updates and block deletions.
Returns a correct DominatorTree reference to be used by the caller for analysis.
Definition at line 443 of file Dominators.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates().
Referenced by processSwitch(), and llvm::RewriteStatepointsForGC::runOnFunction().
| void DeferredDominance::insertEdge | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Helper method for a single edge insertion.
It's almost always better to batch updates and call applyUpdates to quickly remove duplicate edges. This is best used when there is only a single insertion needed to update Dominators.
Definition at line 401 of file Dominators.cpp.
References llvm::DominatorTreeBase< BasicBlock, false >::Insert.
| bool DeferredDominance::pending | ( | ) |
Returns true if pending DT updates are queued for a flush() event.
Definition at line 439 of file Dominators.cpp.
| bool DeferredDominance::pendingDeletedBB | ( | BasicBlock * | DelBB | ) |
Returns true if DelBB is awaiting deletion at a flush() event.
Definition at line 432 of file Dominators.cpp.
| void DeferredDominance::recalculate | ( | Function & | F | ) |
Drops all internal state and forces a (slow) recalculation of the DominatorTree based on the current state of the LLVM IR in F.
This should only be used in corner cases such as the Entry block of F being deleted.
Definition at line 457 of file Dominators.cpp.
Referenced by llvm::MergeBasicBlockIntoOnlyPred().
1.8.13