LLVM 20.0.0git
|
#include "llvm/Analysis/GenericDomTreeUpdater.h"
Public Types | |
enum class | UpdateStrategy : unsigned char { Eager = 0 , Lazy = 1 } |
using | BasicBlockT = typename DomTreeT::NodeType |
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< typename DomTreeT::UpdateType > Updates) |
Submit updates to all available trees. | |
void | applyUpdatesPermissive (ArrayRef< typename DomTreeT::UpdateType > 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 (typename DomTreeT::UpdateType 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 (typename DomTreeT::UpdateType 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< typename DomTreeT::UpdateType, 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.
|
strong |
Enumerator | |
---|---|
Eager | |
Lazy |
Definition at line 31 of file GenericDomTreeUpdater.h.
|
inlineexplicit |
Definition at line 34 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 36 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 38 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 40 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 42 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 44 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 47 of file GenericDomTreeUpdater.h.
|
inline |
Definition at line 51 of file GenericDomTreeUpdater.h.
References assert(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingUpdates().
|
protected |
Helper function to apply all pending DomTree updates.
Definition at line 248 of file GenericDomTreeUpdaterImpl.h.
References assert(), E, and I.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::flush().
|
protected |
Helper function to apply all pending PostDomTree updates.
Definition at line 265 of file GenericDomTreeUpdaterImpl.h.
References assert(), E, and I.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::flush().
void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyUpdates | ( | ArrayRef< typename DomTreeT::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 58 of file GenericDomTreeUpdaterImpl.h.
References llvm::ArrayRef< T >::size().
Referenced by llvm::breakLoopBackedge(), llvm::changeToCall(), llvm::changeToInvokeAndSplitBasicBlock(), llvm::changeToUnreachable(), llvm::ConstantFoldTerminator(), createUnreachableSwitchDefault(), llvm::DeleteDeadBlocks(), llvm::deleteDeadLoop(), llvm::DuplicateInstructionsInSplitBetween(), llvm::ehAwareSplitEdge(), eliminateDeadSwitchCases(), llvm::VPlan::execute(), llvm::VPIRBasicBlock::execute(), expandToSwitch(), foldCondBranchOnValueKnownInPredecessorImpl(), foldMemChr(), llvm::FoldReturnIntoUncondBranch(), foldTwoEntryPHINode(), llvm::MergeBlockIntoPredecessor(), mergeNestedCondBranch(), performBranchToCommonDestFolding(), processSwitch(), removeEmptyCleanup(), removeSwitchAfterSelectFold(), removeUndefIntroducingPredecessor(), llvm::removeUnwindEdge(), replaceConditionalBranchesOnConstant(), runImpl(), SimplifyCondBranchToCondBranch(), llvm::SplitBlockAndInsertIfThenElse(), llvm::splitBlockBefore(), SplitBlockImpl(), switchToLookupTable(), tailMergeBlocksWithSimilarFunctionTerminators(), tryToMergeLandingPad(), llvm::TryToSimplifyUncondBranchFromEmptyBlock(), tryWidenCondBranchToCondBranch(), llvm::UnrollLoop(), and UpdateAnalysisInformation().
void llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::applyUpdatesPermissive | ( | ArrayRef< typename DomTreeT::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 79 of file GenericDomTreeUpdaterImpl.h.
References llvm::SmallSet< T, N, C >::count(), 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 329 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 153 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 309 of file GenericDomTreeUpdaterImpl.h.
|
inline |
Apply all pending updates to available trees and flush all BasicBlocks awaiting deletion.
Definition at line 196 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 135 of file GenericDomTreeUpdaterImpl.h.
References assert().
Referenced by llvm::VPlan::execute(), 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 144 of file GenericDomTreeUpdaterImpl.h.
References assert().
|
inline |
Returns true if it holds a DomTreeT.
Definition at line 64 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 73 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 94 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::DT, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendDTUpdateIndex, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendUpdates, and llvm::SmallVectorBase< Size_T >::size().
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 102 of file GenericDomTreeUpdater.h.
References llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PDT, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendPDTUpdateIndex, llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::PendUpdates, and llvm::SmallVectorBase< Size_T >::size().
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 88 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 67 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 77 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 61 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 58 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 219 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 282 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 27 of file GenericDomTreeUpdaterImpl.h.
References F.
Referenced by llvm::MergeBasicBlockIntoOnlyPred(), and UpdateAnalysisInformation().
|
protected |
Helper function to flush deleted BasicBlocks if all available trees are up-to-date.
Definition at line 322 of file GenericDomTreeUpdaterImpl.h.
|
protected |
Definition at line 214 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDeletedBB(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::isBBPendingDeletion().
|
protected |
Definition at line 211 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasDomTree(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDomTreeUpdates().
|
protected |
Definition at line 215 of file GenericDomTreeUpdater.h.
|
protected |
Definition at line 216 of file GenericDomTreeUpdater.h.
|
protected |
Definition at line 212 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingPostDomTreeUpdates(), and llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPostDomTree().
|
protected |
Definition at line 209 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingDomTreeUpdates().
|
protected |
Definition at line 210 of file GenericDomTreeUpdater.h.
Referenced by llvm::GenericDomTreeUpdater< DerivedT, DomTreeT, PostDomTreeT >::hasPendingPostDomTreeUpdates().
|
protected |
|
protected |
Definition at line 213 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().