LLVM 20.0.0git
|
#include "llvm/Analysis/GenericDomTreeUpdater.h"
Classes | |
struct | CriticalEdge |
Helper structure used to hold all the basic blocks involved in the split of a critical edge. More... | |
struct | DomTreeUpdate |
Public Types | |
enum class | UpdateStrategy : unsigned char { Eager = 0 , Lazy = 1 } |
using | BasicBlockT = typename DomTreeT::NodeType |
using | UpdateT = typename DomTreeT::UpdateType |
Public Member Functions | |
GenericDomTreeUpdater (UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (DomTreeT &DT_, UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (DomTreeT *DT_, UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (PostDomTreeT &PDT_, UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (PostDomTreeT *PDT_, UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (DomTreeT &DT_, PostDomTreeT &PDT_, UpdateStrategy Strategy_) | |
GenericDomTreeUpdater (DomTreeT *DT_, PostDomTreeT *PDT_, UpdateStrategy Strategy_) | |
~GenericDomTreeUpdater () | |
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 DomTreeT. | |
bool | hasPostDomTree () const |
Returns true if it holds a PostDomTreeT. | |
bool | hasPendingDeletedBB () const |
Returns true if there is BasicBlockT awaiting deletion. | |
bool | isBBPendingDeletion (BasicBlockT *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 DomTreeT updates queued. | |
bool | hasPendingPostDomTreeUpdates () const |
Returns true if there are PostDomTreeT 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 DomTreeT and the PostDominatorTree. Note: There are two strategies to update the DomTreeT and the PostDominatorTree:
Although GenericDomTree provides several update primitives, it is not encouraged to use these APIs directly. | |
template<typename FuncT > | |
void | recalculate (FuncT &F) |
Notify DTU that the entry block was replaced. | |
void | applyUpdates (ArrayRef< UpdateT > Updates) |
Submit updates to all available trees. | |
void | splitCriticalEdge (BasicBlockT *FromBB, BasicBlockT *ToBB, BasicBlockT *NewBB) |
Apply updates that the critical edge (FromBB, ToBB) has been split with NewBB. | |
void | applyUpdatesPermissive (ArrayRef< UpdateT > Updates) |
Submit updates to all available trees. | |
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. | |
DomTreeT & | getDomTree () |
Flush DomTree updates and return DomTree. | |
PostDomTreeT & | getPostDomTree () |
Flush PostDomTree updates and return PostDomTree. | |
void | flush () |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion. | |
Protected Member Functions | |
bool | isSelfDominance (UpdateT Update) const |
Returns true if the update is self dominance. | |
void | applyDomTreeUpdates () |
Helper function to apply all pending DomTree updates. | |
void | applyPostDomTreeUpdates () |
Helper function to apply all pending PostDomTree updates. | |
bool | isUpdateValid (UpdateT Update) const |
Returns true if the update appears in the LLVM IR. | |
void | eraseDelBBNode (BasicBlockT *DelBB) |
Erase Basic Block node before it is unlinked from Function in the DomTree and PostDomTree. | |
void | tryFlushDeletedBB () |
Helper function to flush deleted BasicBlocks if all available trees are up-to-date. | |
void | dropOutOfDateUpdates () |
Drop all updates applied by all available trees and delete BasicBlocks if all available trees are up-to-date. | |
Protected Attributes | |
SmallVector< DomTreeUpdate, 16 > | PendUpdates |
size_t | PendDTUpdateIndex = 0 |
size_t | PendPDTUpdateIndex = 0 |
DomTreeT * | DT = nullptr |
PostDomTreeT * | PDT = nullptr |
const UpdateStrategy | Strategy |
SmallPtrSet< BasicBlockT *, 8 > | DeletedBBs |
bool | IsRecalculatingDomTree = false |
bool | IsRecalculatingPostDomTree = false |
Definition at line 24 of file GenericDomTreeUpdater.h.
using llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::BasicBlockT = typename DomTreeT::NodeType |
Definition at line 32 of file GenericDomTreeUpdater.h.
using llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::UpdateT = typename DomTreeT::UpdateType |
Definition at line 33 of file GenericDomTreeUpdater.h.
|
strong |
Enumerator | |
---|---|
Eager | |
Lazy |
Definition at line 31 of file GenericDomTreeUpdater.h.
|
inlineexplicit |
Definition at line 35 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 37 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 39 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 41 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 43 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 45 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 48 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 52 of file GenericDomTreeUpdater.h.
References assert(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingUpdates().
|
inlineprotected |
Helper function to apply all pending DomTree updates.
Definition at line 249 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::flush().
|
inlineprotected |
Helper function to apply all pending PostDomTree updates.
Definition at line 252 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::flush().
void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyUpdates | ( | ArrayRef< UpdateT > | 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 59 of file GenericDomTreeUpdaterImpl.h.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), and llvm::ArrayRef< T >::size().
Referenced by llvm::breakLoopBackedge(), llvm::changeToCall(), llvm::changeToInvokeAndSplitBasicBlock(), llvm::changeToUnreachable(), llvm::VPBasicBlock::connectToPredecessors(), llvm::ConstantFoldTerminator(), createUnreachableSwitchDefault(), llvm::DeleteDeadBlocks(), llvm::deleteDeadLoop(), llvm::DuplicateInstructionsInSplitBetween(), llvm::ehAwareSplitEdge(), eliminateDeadSwitchCases(), llvm::VPlan::execute(), expandToSwitch(), llvm::ControlFlowHub::finalize(), foldCondBranchOnValueKnownInPredecessorImpl(), foldMemChr(), llvm::FoldReturnIntoUncondBranch(), foldTwoEntryPHINode(), llvm::MergeBlockIntoPredecessor(), mergeNestedCondBranch(), performBranchToCommonDestFolding(), processSwitch(), removeEmptyCleanup(), removeSwitchAfterSelectFold(), removeUndefIntroducingPredecessor(), llvm::removeUnwindEdge(), replaceConditionalBranchesOnConstant(), runImpl(), SimplifyCondBranchToCondBranch(), simplifySwitchOfCmpIntrinsic(), llvm::SplitBlockAndInsertIfThenElse(), llvm::splitBlockBefore(), SplitBlockImpl(), switchToLookupTable(), tailMergeBlocksWithSimilarFunctionTerminators(), tryToMergeLandingPad(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), tryWidenCondBranchToCondBranch(), llvm::UnrollLoop(), and UpdateAnalysisInformation().
void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyUpdatesPermissive | ( | ArrayRef< UpdateT > | 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 80 of file GenericDomTreeUpdaterImpl.h.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::applyUpdates(), llvm::SmallSet< T, N, C >::insert(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), processSwitch(), llvm::SCCPSolver::removeNonFeasibleEdges(), splitCallSite(), and llvm::UnrollAndJamLoop().
|
protected |
Drop all updates applied by all available trees and delete BasicBlocks if all available trees are up-to-date.
Definition at line 351 of file GenericDomTreeUpdaterImpl.h.
References assert(), B, and E.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::flush().
LLVM_DUMP_METHOD void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::dump |
Debug method to help view the internal state of this class.
Definition at line 171 of file GenericDomTreeUpdaterImpl.h.
References llvm::dbgs(), and OS.
|
protected |
Erase Basic Block node before it is unlinked from Function in the DomTree and PostDomTree.
Definition at line 331 of file GenericDomTreeUpdaterImpl.h.
References llvm::DominatorTreeBase< NodeT, IsPostDom >::eraseNode(), and llvm::DominatorTreeBase< NodeT, IsPostDom >::getNode().
|
inline |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion.
Definition at line 202 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyDomTreeUpdates(), llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyPostDomTreeUpdates(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::dropOutOfDateUpdates().
Referenced by llvm::ehAwareSplitEdge(), llvm::VPlan::execute(), and llvm::JumpThreadingPass::run().
DomTreeT & llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::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 153 of file GenericDomTreeUpdaterImpl.h.
Referenced by runImpl(), llvm::RewriteStatepointsForGC::runOnFunction(), shouldSplitOnPredicatedArgument(), llvm::splitBlockBefore(), llvm::UnrollAndJamLoop(), llvm::UnrollLoop(), and UpdateAnalysisInformation().
PostDomTreeT & llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::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 162 of file GenericDomTreeUpdaterImpl.h.
References assert().
|
inline |
Returns true if it holds a DomTreeT.
Definition at line 65 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::DT.
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), shouldSplitOnPredicatedArgument(), and UpdateAnalysisInformation().
|
inline |
Returns true if there is BasicBlockT 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 74 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::DeletedBBs, and llvm::SmallPtrSetImplBase::empty().
|
inline |
Returns true if there are DomTreeT updates queued.
Returns false under Eager UpdateStrategy or DT is nullptr.
Definition at line 95 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::DT, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendDTUpdateIndex, and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendUpdates.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingUpdates().
|
inline |
Returns true if there are PostDomTreeT updates queued.
Returns false under Eager UpdateStrategy or PDT is nullptr.
Definition at line 103 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PDT, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendPDTUpdateIndex, and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendUpdates.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingUpdates().
|
inline |
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 MachineBasicBlock awaiting deletion. Returns false under Eager UpdateStrategy.
Definition at line 89 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDomTreeUpdates(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingPostDomTreeUpdates().
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::~GenericDomTreeUpdater().
|
inline |
Returns true if it holds a PostDomTreeT.
Definition at line 68 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PDT.
|
inline |
Returns true if DelBB is awaiting deletion.
Returns false under Eager UpdateStrategy.
Definition at line 78 of file GenericDomTreeUpdater.h.
References llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::DeletedBBs, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Eager, llvm::SmallPtrSetImplBase::empty(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Strategy.
Referenced by iterativelySimplifyCFG(), llvm::removeUnreachableBlocks(), and tailMergeBlocksWithSimilarFunctionTerminators().
|
inline |
Returns true if the current strategy is Eager.
Definition at line 62 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Eager, and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Strategy.
|
inline |
Returns true if the current strategy is Lazy.
Definition at line 59 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Lazy, and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::Strategy.
|
inlineprotected |
Returns true if the update is self dominance.
Definition at line 243 of file GenericDomTreeUpdater.h.
|
protected |
Returns true if the update appears in the LLVM IR.
It is used to check whether an update is valid in insertEdge/deleteEdge or is unnecessary in the batch update.
Definition at line 304 of file GenericDomTreeUpdaterImpl.h.
References From, llvm::is_contained(), and llvm::successors().
template void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::recalculate | ( | FuncT & | F | ) |
Notify DTU that the entry block was replaced.
Recalculate all available trees and flush all BasicBlocks awaiting deletion immediately.
Definition at line 28 of file GenericDomTreeUpdaterImpl.h.
References F, and llvm::DominatorTreeBase< NodeT, IsPostDom >::recalculate().
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), and UpdateAnalysisInformation().
void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::splitCriticalEdge | ( | BasicBlockT * | FromBB, |
BasicBlockT * | ToBB, | ||
BasicBlockT * | NewBB | ||
) |
Apply updates that the critical edge (FromBB, ToBB) has been split with NewBB.
Definition at line 134 of file GenericDomTreeUpdaterImpl.h.
References E.
Referenced by llvm::MachineBasicBlock::SplitCriticalEdge().
|
protected |
Helper function to flush deleted BasicBlocks if all available trees are up-to-date.
Definition at line 344 of file GenericDomTreeUpdaterImpl.h.
|
protected |
Definition at line 238 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDeletedBB(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isBBPendingDeletion().
|
protected |
Definition at line 235 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasDomTree(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDomTreeUpdates().
|
protected |
Definition at line 239 of file GenericDomTreeUpdater.h.
|
protected |
Definition at line 240 of file GenericDomTreeUpdater.h.
|
protected |
Definition at line 236 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingPostDomTreeUpdates(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPostDomTree().
|
protected |
Definition at line 233 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDomTreeUpdates().
|
protected |
Definition at line 234 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingPostDomTreeUpdates().
|
protected |
|
protected |
Definition at line 237 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isBBPendingDeletion(), llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isEager(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isLazy().