LLVM 18.0.0git
|
#include "llvm/Analysis/DomTreeUpdater.h"
Public Types | |
enum class | UpdateStrategy : unsigned char { Eager = 0 , 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. | |
bool | isEager () const |
Returns true if the current strategy is Eager. | |
bool | hasDomTree () const |
Returns true if it holds a DominatorTree. | |
bool | hasPostDomTree () const |
Returns true if it holds a PostDominatorTree. | |
bool | hasPendingDeletedBB () const |
Returns true if there is BasicBlock awaiting deletion. | |
bool | isBBPendingDeletion (BasicBlock *DelBB) const |
Returns true if DelBB is awaiting deletion. | |
bool | hasPendingUpdates () const |
Returns true if either of DT or PDT is valid and the tree has at least one update pending. | |
bool | hasPendingDomTreeUpdates () const |
Returns true if there are DominatorTree updates queued. | |
bool | hasPendingPostDomTreeUpdates () const |
Returns true if there are PostDominatorTree updates queued. | |
LLVM_DUMP_METHOD void | dump () const |
Debug method to help view the internal state of this class. | |
Mutation APIs | |
These methods provide APIs for submitting updates to the DominatorTree and the PostDominatorTree. Note: There are two strategies to update the DominatorTree and the PostDominatorTree:
Although GenericDomTree provides several update primitives, it is not encouraged to use these APIs directly. | |
void | applyUpdates (ArrayRef< DominatorTree::UpdateType > Updates) |
Submit updates to all available trees. | |
void | applyUpdatesPermissive (ArrayRef< DominatorTree::UpdateType > Updates) |
Submit updates to all available trees. | |
void | recalculate (Function &F) |
Notify DTU that the entry block was replaced. | |
void | deleteBB (BasicBlock *DelBB) |
Delete DelBB. | |
void | callbackDeleteBB (BasicBlock *DelBB, std::function< void(BasicBlock *)> Callback) |
Delete DelBB. | |
Flush APIs | |
CAUTION! By the moment these flush APIs are called, the current CFG needs to be the same as the CFG which DTU is in sync with + all updates submitted. | |
DominatorTree & | getDomTree () |
Flush DomTree updates and return DomTree. | |
PostDominatorTree & | getPostDomTree () |
Flush PostDomTree updates and return PostDomTree. | |
void | flush () |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion. | |
Definition at line 28 of file DomTreeUpdater.h.
|
strong |
Enumerator | |
---|---|
Eager | |
Lazy |
Definition at line 30 of file DomTreeUpdater.h.
|
inlineexplicit |
Definition at line 32 of file DomTreeUpdater.h.
|
inline |
Definition at line 33 of file DomTreeUpdater.h.
|
inline |
Definition at line 35 of file DomTreeUpdater.h.
|
inline |
Definition at line 37 of file DomTreeUpdater.h.
|
inline |
Definition at line 39 of file DomTreeUpdater.h.
|
inline |
Definition at line 41 of file DomTreeUpdater.h.
|
inline |
Definition at line 44 of file DomTreeUpdater.h.
|
inline |
Definition at line 48 of file DomTreeUpdater.h.
References flush().
void llvm::DomTreeUpdater::applyUpdates | ( | ArrayRef< DominatorTree::UpdateType > | Updates | ) |
Submit updates to all available trees.
The Eager Strategy flushes updates immediately while the Lazy Strategy queues the updates.
Note: The "existence" of an edge in a CFG refers to the CFG which DTU is in sync with + all updates before that single update.
CAUTION!
Definition at line 230 of file DomTreeUpdater.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), Lazy, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorImpl< T >::reserve(), llvm::ArrayRef< T >::size(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::breakLoopBackedge(), llvm::changeToCall(), llvm::changeToInvokeAndSplitBasicBlock(), llvm::changeToUnreachable(), llvm::ConstantFoldTerminator(), createUnreachableSwitchDefault(), llvm::DeleteDeadBlocks(), llvm::deleteDeadLoop(), llvm::DuplicateInstructionsInSplitBetween(), llvm::ehAwareSplitEdge(), eliminateDeadSwitchCases(), FoldCondBranchOnValueKnownInPredecessorImpl(), llvm::FoldReturnIntoUncondBranch(), FoldTwoEntryPHINode(), llvm::MergeBlockIntoPredecessor(), performBranchToCommonDestFolding(), removeEmptyCleanup(), removeSwitchAfterSelectFold(), removeUndefIntroducingPredecessor(), llvm::removeUnwindEdge(), replaceConditionalBranchesOnConstant(), SimplifyCondBranchToCondBranch(), llvm::SplitBlockAndInsertIfThenElse(), llvm::splitBlockBefore(), SplitBlockImpl(), SwitchToLookupTable(), tailMergeBlocksWithSimilarFunctionTerminators(), TryToMergeLandingPad(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), tryWidenCondBranchToCondBranch(), llvm::UnrollLoop(), and UpdateAnalysisInformation().
void llvm::DomTreeUpdater::applyUpdatesPermissive | ( | ArrayRef< DominatorTree::UpdateType > | Updates | ) |
Submit updates to all available trees.
It will also
Note: The "existence" of an edge in a CFG refers to the CFG which DTU is in sync with + all updates before that single update.
CAUTION!
Definition at line 249 of file DomTreeUpdater.cpp.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), llvm::SmallSet< T, N, C >::count(), llvm::SmallSet< T, N, C >::insert(), isLazy(), Lazy, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), processSwitch(), llvm::SCCPSolver::removeNonFeasibleEdges(), splitCallSite(), and llvm::UnrollAndJamLoop().
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 189 of file DomTreeUpdater.cpp.
References Lazy, and llvm::BasicBlock::removeFromParent().
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 177 of file DomTreeUpdater.cpp.
References Lazy, and llvm::BasicBlock::removeFromParent().
Referenced by llvm::DeleteDeadBlocks(), llvm::MergeBasicBlockIntoOnlyPred(), runSCCP(), and splitCallSite().
LLVM_DUMP_METHOD void llvm::DomTreeUpdater::dump | ( | ) | const |
Debug method to help view the internal state of this class.
Definition at line 340 of file DomTreeUpdater.cpp.
References assert(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::dbgs(), Eager, llvm::SmallVectorTemplateCommon< T, typename >::end(), From, llvm::Value::getName(), llvm::Value::hasName(), I, llvm::DominatorTreeBase< BasicBlock, false >::Insert, and OS.
void llvm::DomTreeUpdater::flush | ( | ) |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion.
Definition at line 73 of file DomTreeUpdater.cpp.
Referenced by llvm::ehAwareSplitEdge(), llvm::JumpThreadingPass::run(), and ~DomTreeUpdater().
DominatorTree & llvm::DomTreeUpdater::getDomTree | ( | ) |
Flush DomTree updates and return DomTree.
It flushes Deleted BBs if both trees are up-to-date. It must only be called when it has a DomTree.
Definition at line 303 of file DomTreeUpdater.cpp.
References assert().
Referenced by runImpl(), llvm::RewriteStatepointsForGC::runOnFunction(), shouldSplitOnPredicatedArgument(), llvm::splitBlockBefore(), llvm::UnrollAndJamLoop(), llvm::UnrollLoop(), and UpdateAnalysisInformation().
PostDominatorTree & llvm::DomTreeUpdater::getPostDomTree | ( | ) |
Flush PostDomTree updates and return PostDomTree.
It flushes Deleted BBs if both trees are up-to-date. It must only be called when it has a PostDomTree.
Definition at line 310 of file DomTreeUpdater.cpp.
References assert().
|
inline |
Returns true if it holds a DominatorTree.
Definition at line 57 of file DomTreeUpdater.h.
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), shouldSplitOnPredicatedArgument(), and UpdateAnalysisInformation().
|
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 66 of file DomTreeUpdater.h.
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 154 of file DomTreeUpdater.cpp.
References llvm::SmallVectorBase< Size_T >::size().
Referenced by 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 160 of file DomTreeUpdater.cpp.
References llvm::SmallVectorBase< Size_T >::size().
Referenced by 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 150 of file DomTreeUpdater.cpp.
References hasPendingDomTreeUpdates(), and hasPendingPostDomTreeUpdates().
|
inline |
Returns true if it holds a PostDominatorTree.
Definition at line 60 of file DomTreeUpdater.h.
bool llvm::DomTreeUpdater::isBBPendingDeletion | ( | llvm::BasicBlock * | DelBB | ) | const |
Returns true if DelBB is awaiting deletion.
Returns false under Eager UpdateStrategy.
Definition at line 166 of file DomTreeUpdater.cpp.
References Eager.
Referenced by iterativelySimplifyCFG(), llvm::removeUnreachableBlocks(), and tailMergeBlocksWithSimilarFunctionTerminators().
|
inline |
Returns true if the current strategy is Eager.
Definition at line 54 of file DomTreeUpdater.h.
References Eager.
|
inline |
Returns true if the current strategy is Lazy.
Definition at line 51 of file DomTreeUpdater.h.
References Lazy.
Referenced by applyUpdatesPermissive().
void llvm::DomTreeUpdater::recalculate | ( | Function & | F | ) |
Notify DTU that the entry block was replaced.
Recalculate all available trees and flush all BasicBlocks awaiting deletion immediately.
Definition at line 120 of file DomTreeUpdater.cpp.
References Eager, F, llvm::DominatorTreeBase< NodeT, IsPostDom >::recalculate(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), and UpdateAnalysisInformation().