|
LLVM
7.0.0
|
#include "llvm/IR/DomTreeUpdater.h"
Public Types | |
| enum | UpdateStrategy : unsigned char { UpdateStrategy::Eager = 0, UpdateStrategy::Lazy = 1 } |
Public Member Functions | |
| DomTreeUpdater (UpdateStrategy Strategy_) | |
| DomTreeUpdater (DominatorTree &DT_, UpdateStrategy Strategy_) | |
| DomTreeUpdater (DominatorTree *DT_, UpdateStrategy Strategy_) | |
| DomTreeUpdater (PostDominatorTree &PDT_, UpdateStrategy Strategy_) | |
| DomTreeUpdater (PostDominatorTree *PDT_, UpdateStrategy Strategy_) | |
| DomTreeUpdater (DominatorTree &DT_, PostDominatorTree &PDT_, UpdateStrategy Strategy_) | |
| DomTreeUpdater (DominatorTree *DT_, PostDominatorTree *PDT_, UpdateStrategy Strategy_) | |
| ~DomTreeUpdater () | |
| bool | isLazy () const |
| Returns true if the current strategy is Lazy. More... | |
| bool | isEager () const |
| Returns true if the current strategy is Eager. More... | |
| bool | hasDomTree () const |
| Returns true if it holds a DominatorTree. More... | |
| bool | hasPostDomTree () const |
| Returns true if it holds a PostDominatorTree. More... | |
| bool | hasPendingDeletedBB () const |
| Returns true if there is BasicBlock awaiting deletion. More... | |
| bool | isBBPendingDeletion (BasicBlock *DelBB) const |
| Returns true if DelBB is awaiting deletion. More... | |
| bool | hasPendingUpdates () const |
| Returns true if either of DT or PDT is valid and the tree has at least one update pending. More... | |
| bool | hasPendingDomTreeUpdates () const |
| Returns true if there are DominatorTree updates queued. More... | |
| bool | hasPendingPostDomTreeUpdates () const |
| Returns true if there are PostDominatorTree updates queued. More... | |
| void | applyUpdates (ArrayRef< DominatorTree::UpdateType > Updates, bool ForceRemoveDuplicates=false) |
| Apply updates on all available trees. More... | |
| void | insertEdge (BasicBlock *From, BasicBlock *To) |
| Notify all available trees on an edge insertion. More... | |
| void | insertEdgeRelaxed (BasicBlock *From, BasicBlock *To) |
| Notify all available trees on an edge insertion. More... | |
| void | deleteEdge (BasicBlock *From, BasicBlock *To) |
| Notify all available trees on an edge deletion. More... | |
| void | deleteEdgeRelaxed (BasicBlock *From, BasicBlock *To) |
| Notify all available trees on an edge deletion. More... | |
| void | deleteBB (BasicBlock *DelBB) |
| Delete DelBB. More... | |
| void | callbackDeleteBB (BasicBlock *DelBB, std::function< void(BasicBlock *)> Callback) |
| Delete DelBB. More... | |
| bool | recalculate (Function &F) |
| Recalculate all available trees. More... | |
| DominatorTree & | getDomTree () |
| Flush DomTree updates and return DomTree. More... | |
| PostDominatorTree & | getPostDomTree () |
| Flush PostDomTree updates and return PostDomTree. More... | |
| void | flush () |
| Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion. More... | |
| LLVM_DUMP_METHOD void | dump () const |
| Debug method to help view the internal state of this class. More... | |
Definition at line 27 of file DomTreeUpdater.h.
|
strong |
| Enumerator | |
|---|---|
| Eager | |
| Lazy | |
Definition at line 29 of file DomTreeUpdater.h.
|
inlineexplicit |
Definition at line 31 of file DomTreeUpdater.h.
|
inline |
Definition at line 32 of file DomTreeUpdater.h.
|
inline |
Definition at line 34 of file DomTreeUpdater.h.
|
inline |
Definition at line 36 of file DomTreeUpdater.h.
|
inline |
Definition at line 38 of file DomTreeUpdater.h.
|
inline |
Definition at line 40 of file DomTreeUpdater.h.
|
inline |
Definition at line 43 of file DomTreeUpdater.h.
|
inline |
Definition at line 47 of file DomTreeUpdater.h.
References flush().
| void llvm::DomTreeUpdater::applyUpdates | ( | ArrayRef< DominatorTree::UpdateType > | Updates, |
| bool | ForceRemoveDuplicates = false |
||
| ) |
Apply updates on all available trees.
Under Eager UpdateStrategy with ForceRemoveDuplicates enabled or under Lazy UpdateStrategy, it will discard duplicated updates and self-dominance updates. If both DT and PDT are nullptrs, this function discards all updates. The Eager Strategy applies the updates immediately while the Lazy Strategy queues the updates. It is required for the state of the LLVM IR to be updated before applying the Updates because the internal update routine will analyze the current state of the relationship between a pair of (From, To) BasicBlocks to determine whether a single update needs to be discarded.
Definition at line 270 of file DomTreeUpdater.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), Lazy, llvm::none_of(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::callbackDeleteBB | ( | BasicBlock * | DelBB, |
| std::function< void(BasicBlock *)> | Callback | ||
| ) |
Delete DelBB.
DelBB will be removed from its Parent and erased from available trees if it exists. Then the callback will be called. Finally, DelBB will be deleted. Under Eager UpdateStrategy, DelBB will be processed immediately. Under Lazy UpdateStrategy, DelBB will be queued until a flush event and all available trees are up-to-date. Assert if any instruction of DelBB is modified while awaiting deletion. Multiple callbacks can be queued for one DelBB under Lazy UpdateStrategy.
Definition at line 229 of file DomTreeUpdater.cpp.
References assert(), llvm::BasicBlock::back(), llvm::BasicBlock::empty(), llvm::DominatorTreeBase< NodeT, IsPostDom >::eraseNode(), llvm::UndefValue::get(), llvm::BasicBlock::getContext(), llvm::BasicBlock::getInstList(), llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode(), llvm::Value::getType(), I, Lazy, llvm::iplist_impl< IntrusiveListT, TraitsT >::pop_back(), llvm::pred_empty(), llvm::BasicBlock::removeFromParent(), llvm::Value::replaceAllUsesWith(), and llvm::Value::use_empty().
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::deleteBB | ( | BasicBlock * | DelBB | ) |
Delete DelBB.
DelBB will be removed from its Parent and erased from available trees if it exists and finally get deleted. Under Eager UpdateStrategy, DelBB will be processed immediately. Under Lazy UpdateStrategy, DelBB will be queued until a flush event and all available trees are up-to-date. Assert if any instruction of DelBB is modified while awaiting deletion. When both DT and PDT are nullptrs, DelBB will be queued until flush() is called.
Definition at line 217 of file DomTreeUpdater.cpp.
References Lazy, and llvm::BasicBlock::removeFromParent().
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::deleteEdge | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Notify all available trees on an edge deletion.
If both DT and PDT are nullptrs, this function discards the update. Under either Strategy, self-dominance update will be removed. The Eager Strategy applies the update immediately while the Lazy Strategy queues the update. It is recommended to only use this method when you have exactly one deletion (and no insertions). It is recommended to use applyUpdates() in all other cases. This function has to be called after making the update on the actual CFG. An internal functions checks if the edge doesn't exist in the CFG in DEBUG mode.
Definition at line 364 of file DomTreeUpdater.cpp.
References assert(), llvm::DominatorTreeBase< BasicBlock, false >::Delete, llvm::DominatorTreeBase< NodeT, IsPostDom >::deleteEdge(), and Eager.
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::deleteEdgeRelaxed | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Notify all available trees on an edge deletion.
Under either Strategy, the following updates will be discard silently
Definition at line 389 of file DomTreeUpdater.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::DominatorTreeBase< BasicBlock, false >::Delete, llvm::DominatorTreeBase< NodeT, IsPostDom >::deleteEdge(), E, Eager, llvm::SmallVectorImpl< T >::erase(), and llvm::SmallVectorBase::size().
Referenced by hasPendingDeletedBB().
| LLVM_DUMP_METHOD void llvm::DomTreeUpdater::dump | ( | ) | const |
Debug method to help view the internal state of this class.
Definition at line 433 of file DomTreeUpdater.cpp.
References assert(), llvm::sys::path::begin(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::dbgs(), Eager, llvm::sys::path::end(), llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::Value::getName(), llvm::Value::hasName(), I, and llvm::DominatorTreeBase< BasicBlock, false >::Insert.
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::flush | ( | ) |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion.
Does nothing under Eager UpdateStrategy.
Definition at line 107 of file DomTreeUpdater.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), E, llvm::SmallVectorTemplateCommon< T, typename >::end(), hasPendingPostDomTreeUpdates(), hasPendingUpdates(), I, Lazy, and llvm::SmallVectorBase::size().
Referenced by hasPendingDeletedBB(), and ~DomTreeUpdater().
| DominatorTree & llvm::DomTreeUpdater::getDomTree | ( | ) |
Flush DomTree updates and return DomTree.
It also flush out of date updates applied by all available trees and flush Deleted BBs if both trees are up-to-date. It must only be called when it has a DomTree.
Definition at line 304 of file DomTreeUpdater.cpp.
References assert().
Referenced by hasPendingDeletedBB().
| PostDominatorTree & llvm::DomTreeUpdater::getPostDomTree | ( | ) |
Flush PostDomTree updates and return PostDomTree.
It also flush out of date updates applied by all available trees and flush Deleted BBs if both trees are up-to-date. It must only be called when it has a PostDomTree.
Definition at line 311 of file DomTreeUpdater.cpp.
References assert().
Referenced by hasPendingDeletedBB().
|
inline |
Returns true if it holds a DominatorTree.
Definition at line 56 of file DomTreeUpdater.h.
|
inline |
Returns true if there is BasicBlock awaiting deletion.
The deletion will only happen until a flush event and all available trees are up-to-date. Returns false under Eager UpdateStrategy.
Definition at line 65 of file DomTreeUpdater.h.
References applyUpdates(), callbackDeleteBB(), deleteBB(), llvm::CallbackVH::deleted(), deleteEdge(), deleteEdgeRelaxed(), dump(), F(), flush(), function, getDomTree(), getPostDomTree(), hasPendingDomTreeUpdates(), hasPendingPostDomTreeUpdates(), hasPendingUpdates(), insertEdge(), insertEdgeRelaxed(), isBBPendingDeletion(), Kind, LLVM_DUMP_METHOD, and recalculate().
| bool llvm::DomTreeUpdater::hasPendingDomTreeUpdates | ( | ) | const |
Returns true if there are DominatorTree updates queued.
Returns false under Eager UpdateStrategy or DT is nullptr.
Definition at line 194 of file DomTreeUpdater.cpp.
References llvm::SmallVectorBase::size().
Referenced by hasPendingDeletedBB(), and hasPendingUpdates().
| bool llvm::DomTreeUpdater::hasPendingPostDomTreeUpdates | ( | ) | const |
Returns true if there are PostDominatorTree updates queued.
Returns false under Eager UpdateStrategy or PDT is nullptr.
Definition at line 200 of file DomTreeUpdater.cpp.
References llvm::SmallVectorBase::size().
Referenced by flush(), hasPendingDeletedBB(), and hasPendingUpdates().
| bool llvm::DomTreeUpdater::hasPendingUpdates | ( | ) | const |
Returns true if either of DT or PDT is valid and the tree has at least one update pending.
If DT or PDT is nullptr it is treated as having no pending updates. This function does not check whether there is BasicBlock awaiting deletion. Returns false under Eager UpdateStrategy.
Definition at line 190 of file DomTreeUpdater.cpp.
References hasPendingDomTreeUpdates(), and hasPendingPostDomTreeUpdates().
Referenced by flush(), hasPendingDeletedBB(), and recalculate().
|
inline |
Returns true if it holds a PostDominatorTree.
Definition at line 59 of file DomTreeUpdater.h.
| void llvm::DomTreeUpdater::insertEdge | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Notify all available trees on an edge insertion.
If both DT and PDT are nullptrs, this function discards the update. Under either Strategy, self-dominance update will be removed. The Eager Strategy applies the update immediately while the Lazy Strategy queues the update. It is recommended to only use this method when you have exactly one insertion (and no deletions). It is recommended to use applyUpdates() in all other cases. This function has to be called after making the update on the actual CFG. An internal functions checks if the edge exists in the CFG in DEBUG mode.
Definition at line 318 of file DomTreeUpdater.cpp.
References assert(), Eager, llvm::DominatorTreeBase< BasicBlock, false >::Insert, and llvm::DominatorTreeBase< NodeT, IsPostDom >::insertEdge().
Referenced by hasPendingDeletedBB().
| void llvm::DomTreeUpdater::insertEdgeRelaxed | ( | BasicBlock * | From, |
| BasicBlock * | To | ||
| ) |
Notify all available trees on an edge insertion.
Under either Strategy, the following updates will be discard silently
Definition at line 343 of file DomTreeUpdater.cpp.
References Eager, llvm::DominatorTreeBase< BasicBlock, false >::Insert, and llvm::DominatorTreeBase< NodeT, IsPostDom >::insertEdge().
Referenced by hasPendingDeletedBB().
| bool llvm::DomTreeUpdater::isBBPendingDeletion | ( | llvm::BasicBlock * | DelBB | ) | const |
Returns true if DelBB is awaiting deletion.
Returns false under Eager UpdateStrategy.
Definition at line 206 of file DomTreeUpdater.cpp.
References Eager.
Referenced by hasPendingDeletedBB().
|
inline |
Returns true if the current strategy is Eager.
Definition at line 53 of file DomTreeUpdater.h.
References Eager.
|
inline |
Returns true if the current strategy is Lazy.
Definition at line 50 of file DomTreeUpdater.h.
References Lazy.
Recalculate all available trees.
Under Lazy Strategy, available trees will only be recalculated if there are pending updates or there is BasicBlock awaiting deletion. Returns true if at least one tree is recalculated.
Definition at line 155 of file DomTreeUpdater.cpp.
References Eager, hasPendingUpdates(), llvm::DominatorTreeBase< NodeT, IsPostDom >::recalculate(), and llvm::SmallVectorBase::size().
Referenced by hasPendingDeletedBB().
1.8.13