|
LLVM 24.0.0git
|
Cycle information for a function. More...
#include "llvm/ADT/GenericCycleInfo.h"
Classes | |
| struct | const_child_iterator |
| Iteration over child cycles, yielding handles. More... | |
Public Types | |
| using | BlockT = typename ContextT::BlockT |
| using | FunctionT = typename ContextT::FunctionT |
| using | const_toplevel_iterator = const_child_iterator |
| Iteration over top-level cycles. | |
Public Member Functions | |
| GenericCycleInfo ()=default | |
| GenericCycleInfo (GenericCycleInfo &&)=default | |
| GenericCycleInfo & | operator= (GenericCycleInfo &&)=default |
| void | clear () |
| Reset the object to its initial state. | |
| void | compute (FunctionT &F) |
| Compute the cycle info for a function. | |
| void | splitCriticalEdge (BlockT *Pred, BlockT *Succ, BlockT *New) |
| const FunctionT * | getFunction () const |
| const ContextT & | getSSAContext () const |
| auto | cycles () const |
| All cycles in forest preorder. | |
| CycleRef | getCycle (const BlockT *Block) const |
Find the innermost cycle containing Block. | |
| BlockT * | getHeader (CycleRef C) const |
| bool | isReducible (CycleRef C) const |
| CycleRef | getParentCycle (CycleRef C) const |
| unsigned | getDepth (CycleRef C) const |
| size_t | getNumBlocks (CycleRef C) const |
| ArrayRef< BlockT * > | getEntries (CycleRef C) const |
| bool | isEntry (CycleRef C, const BlockT *Block) const |
| void | setSingleEntry (CycleRef C, BlockT *Block) |
| bool | contains (CycleRef Outer, CycleRef Inner) const |
Returns true iff Outer contains Inner. O(1). Non-strict. | |
| iterator_range< const_child_iterator > | children (CycleRef C) const |
| Printable | printEntries (CycleRef C, const ContextT &Ctx) const |
| bool | contains (CycleRef C, const BlockT *Block) const |
Return whether Block is contained in C. O(1). | |
| ArrayRef< BlockT * > | getBlocks (CycleRef C) const |
Return the blocks of C, including those of nested cycles. | |
| CycleRef | getSmallestCommonCycle (CycleRef A, CycleRef B) const |
| Find the innermost cycle containing both given cycles. | |
| CycleRef | getSmallestCommonCycle (BlockT *A, BlockT *B) const |
| Find the innermost cycle containing both given blocks. | |
| unsigned | getCycleDepth (const BlockT *Block) const |
Return the depth of the innermost cycle containing Block, or 0 if it is not contained in any cycle. | |
| CycleRef | getTopLevelParentCycle (const BlockT *Block) const |
| void | getExitBlocks (CycleRef C, SmallVectorImpl< BlockT * > &TmpStorage) const |
Return all of the successor blocks of C: the blocks outside of C which are branched to from within it. | |
| void | getExitingBlocks (CycleRef C, SmallVectorImpl< BlockT * > &TmpStorage) const |
Return all blocks of C that have a successor outside of C. | |
| BlockT * | getCyclePreheader (CycleRef C) const |
Return the preheader block for C. | |
| BlockT * | getCyclePredecessor (CycleRef C) const |
If C has exactly one entry with exactly one predecessor, return it, otherwise return nullptr. | |
| void | verifyCycle (CycleRef C) const |
Verify that C is actually a well-formed cycle in the CFG. | |
| void | verifyCycleNest (CycleRef C) const |
Verify the parent-child relations of C. | |
| void | addBlockToCycle (BlockT *Block, CycleRef C) |
Assumes that C is the innermost cycle containing Block. | |
| void | verifyCycleNest (bool VerifyFull=false) const |
| Methods for debug and self-test. | |
| void | verify () const |
| Verify that the entire cycle tree well-formed. | |
| void | print (raw_ostream &Out) const |
| Print the cycle info. | |
| void | dump () const |
| Printable | print (CycleRef C) const |
| Print a single cycle: its depth, entries, and remaining blocks. | |
| const_toplevel_iterator | toplevel_begin () const |
| const_toplevel_iterator | toplevel_end () const |
| iterator_range< const_toplevel_iterator > | toplevel_cycles () const |
Friends | |
| template<typename> | |
| class | GenericCycleInfoCompute |
Cycle information for a function.
Definition at line 78 of file GenericCycleInfo.h.
| using llvm::GenericCycleInfo< ContextT >::BlockT = typename ContextT::BlockT |
Definition at line 80 of file GenericCycleInfo.h.
| using llvm::GenericCycleInfo< ContextT >::const_toplevel_iterator = const_child_iterator |
Iteration over top-level cycles.
Definition at line 338 of file GenericCycleInfo.h.
| using llvm::GenericCycleInfo< ContextT >::FunctionT = typename ContextT::FunctionT |
Definition at line 81 of file GenericCycleInfo.h.
|
default |
|
default |
References GenericCycleInfo().
| void llvm::GenericCycleInfo< ContextT >::addBlockToCycle | ( | BlockT * | Block, |
| CycleRef | C ) |
Assumes that C is the innermost cycle containing Block.
Block will be appended to C and all of its parent cycles. Block will be added to BlockMap with C.
Definition at line 312 of file GenericCycleImpl.h.
References llvm::Block, and llvm::CallingConv::C.
Referenced by fixIrreducible(), and splitCriticalEdge().
|
inline |
Definition at line 250 of file GenericCycleInfo.h.
References llvm::CallingConv::C, llvm::First, and llvm::make_range().
| void llvm::GenericCycleInfo< ContextT >::clear | ( | ) |
Reset the object to its initial state.
Definition at line 552 of file GenericCycleImpl.h.
| void llvm::GenericCycleInfo< ContextT >::compute | ( | FunctionT & | F | ) |
Compute the cycle info for a function.
Definition at line 562 of file GenericCycleImpl.h.
References llvm::dbgs(), F, GenericCycleInfoCompute, LLVM_DEBUG, and llvm::GenericCycleInfoCompute< ContextT >::run().
Referenced by annotateAllFunctions(), llvm::buildModuleSummaryIndex(), llvm::OptimizationRemarkEmitter::OptimizationRemarkEmitter(), llvm::CycleAnalysis::run(), and llvm::MachineCycleAnalysis::run().
|
inline |
Return whether Block is contained in C. O(1).
Definition at line 265 of file GenericCycleInfo.h.
References llvm::Block, llvm::CallingConv::C, contains(), getCycle(), and llvm::CycleRef::isValid().
|
inline |
Returns true iff Outer contains Inner. O(1). Non-strict.
Definition at line 245 of file GenericCycleInfo.h.
References I.
Referenced by contains(), fixIrreducible(), llvm::isCycleInvariant(), and llvm::SIInstrInfo::isSafeToSink().
|
inline |
All cycles in forest preorder.
Definition at line 199 of file GenericCycleInfo.h.
References I, llvm::map_range(), and llvm::seq().
Referenced by FixIrreducibleImpl().
|
inline |
Definition at line 332 of file GenericCycleInfo.h.
References llvm::dbgs(), and print().
|
inline |
Return the blocks of C, including those of nested cycles.
Definition at line 271 of file GenericCycleInfo.h.
References llvm::ArrayRef(), and llvm::CallingConv::C.
Referenced by getExitBlocks(), getExitingBlocks(), print(), updateLoopInfo(), verifyCycle(), verifyCycleNest(), and verifyCycleNest().
|
inline |
Find the innermost cycle containing Block.
Block or an invalid handle if it is not contained in any cycle. Definition at line 208 of file GenericCycleInfo.h.
References llvm::Block, and llvm::Number.
Referenced by contains(), getCycleDepth(), getSmallestCommonCycle(), getTopLevelParentCycle(), isNotInCycle(), llvm::isPotentiallyReachable(), llvm::SIInstrInfo::isSafeToSink(), mayBeInCycle(), splitCriticalEdge(), and verifyCycleNest().
|
inline |
Return the depth of the innermost cycle containing Block, or 0 if it is not contained in any cycle.
Definition at line 282 of file GenericCycleInfo.h.
References llvm::Block, llvm::CallingConv::C, getCycle(), and getDepth().
| auto llvm::GenericCycleInfo< ContextT >::getCyclePredecessor | ( | CycleRef | C | ) | const |
If C has exactly one entry with exactly one predecessor, return it, otherwise return nullptr.
Definition at line 87 of file GenericCycleImpl.h.
References llvm::CallingConv::C, contains(), getHeader(), isReducible(), and llvm::predecessors().
Referenced by getCyclePreheader().
| auto llvm::GenericCycleInfo< ContextT >::getCyclePreheader | ( | CycleRef | C | ) | const |
Return the preheader block for C.
Pre-header is well-defined for reducible cycle in docs/LoopTerminology.md as: the only one entering block and its only edge is to the entry block. Return null for irreducible cycles.
Definition at line 68 of file GenericCycleImpl.h.
References assert(), llvm::CallingConv::C, getCyclePredecessor(), isReducible(), and llvm::succ_size().
|
inline |
Definition at line 223 of file GenericCycleInfo.h.
References llvm::CallingConv::C.
Referenced by getCycleDepth(), getSmallestCommonCycle(), print(), and print().
|
inline |
Definition at line 229 of file GenericCycleInfo.h.
References llvm::ArrayRef(), and llvm::CallingConv::C.
Referenced by fixIrreducible(), llvm::isCycleInvariant(), isEntry(), printEntries(), and verifyCycle().
| void llvm::GenericCycleInfo< ContextT >::getExitBlocks | ( | CycleRef | C, |
| SmallVectorImpl< BlockT * > & | TmpStorage ) const |
Return all of the successor blocks of C: the blocks outside of C which are branched to from within it.
Definition at line 39 of file GenericCycleImpl.h.
References llvm::SmallVectorImpl< T >::append(), llvm::Block, llvm::CallingConv::C, contains(), getBlocks(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::successors().
Referenced by isReachableImpl(), and verifyCycle().
| void llvm::GenericCycleInfo< ContextT >::getExitingBlocks | ( | CycleRef | C, |
| SmallVectorImpl< BlockT * > & | TmpStorage ) const |
Return all blocks of C that have a successor outside of C.
Definition at line 55 of file GenericCycleImpl.h.
References llvm::Block, llvm::CallingConv::C, contains(), getBlocks(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::successors().
Referenced by llvm::SIInstrInfo::isSafeToSink().
|
inline |
Definition at line 195 of file GenericCycleInfo.h.
|
inline |
Definition at line 218 of file GenericCycleInfo.h.
References llvm::CallingConv::C.
Referenced by fixIrreducible(), getCyclePredecessor(), mayBeInCycle(), updateLoopInfo(), verifyCycle(), and verifyCycleNest().
|
inline |
Definition at line 224 of file GenericCycleInfo.h.
References llvm::CallingConv::C.
Referenced by verifyCycle().
|
inline |
Definition at line 222 of file GenericCycleInfo.h.
References llvm::CallingConv::C.
Referenced by fixIrreducible(), getSmallestCommonCycle(), getTopLevelParentCycle(), and llvm::SIInstrInfo::isSafeToSink().
| auto llvm::GenericCycleInfo< ContextT >::getSmallestCommonCycle | ( | BlockT * | A, |
| BlockT * | B ) const |
Find the innermost cycle containing both given blocks.
A and B or nullptr if there is no such cycle. Definition at line 620 of file GenericCycleImpl.h.
References A(), B(), getCycle(), and getSmallestCommonCycle().
| auto llvm::GenericCycleInfo< ContextT >::getSmallestCommonCycle | ( | CycleRef | A, |
| CycleRef | B ) const |
Find the innermost cycle containing both given cycles.
A and B or nullptr if there is no such cycle. Definition at line 591 of file GenericCycleImpl.h.
References A(), B(), getDepth(), and getParentCycle().
Referenced by getSmallestCommonCycle(), and splitCriticalEdge().
|
inline |
Definition at line 196 of file GenericCycleInfo.h.
|
inline |
Definition at line 287 of file GenericCycleInfo.h.
References llvm::Block, llvm::CallingConv::C, getCycle(), getParentCycle(), and P.
Referenced by isReachableImpl().
|
inline |
Definition at line 233 of file GenericCycleInfo.h.
References llvm::Block, llvm::CallingConv::C, getEntries(), and llvm::is_contained().
Referenced by print().
|
inline |
Definition at line 221 of file GenericCycleInfo.h.
References llvm::CallingConv::C.
Referenced by fixIrreducible(), getCyclePredecessor(), and getCyclePreheader().
|
default |
References F, and GenericCycleInfo().
| Printable llvm::GenericCycleInfo< ContextT >::print | ( | CycleRef | C | ) | const |
Print a single cycle: its depth, entries, and remaining blocks.
Definition at line 670 of file GenericCycleImpl.h.
References llvm::Block, llvm::CallingConv::C, getBlocks(), getDepth(), isEntry(), and printEntries().
| void llvm::GenericCycleInfo< ContextT >::print | ( | raw_ostream & | Out | ) | const |
Print the cycle info.
Definition at line 659 of file GenericCycleImpl.h.
References llvm::CallingConv::C, cycles, llvm::Depth, getDepth(), I, and llvm::print().
Referenced by dump(), and fixIrreducible().
|
inline |
Definition at line 256 of file GenericCycleInfo.h.
References llvm::CallingConv::C, and getEntries().
Referenced by print().
|
inline |
Definition at line 238 of file GenericCycleInfo.h.
References llvm::Block, and llvm::CallingConv::C.
Referenced by fixIrreducible().
| void llvm::GenericCycleInfo< ContextT >::splitCriticalEdge | ( | BlockT * | Pred, |
| BlockT * | Succ, | ||
| BlockT * | New ) |
Definition at line 574 of file GenericCycleImpl.h.
References addBlockToCycle(), llvm::CallingConv::C, getCycle(), getSmallestCommonCycle(), and verifyCycleNest().
|
inline |
Definition at line 340 of file GenericCycleInfo.h.
Referenced by toplevel_cycles().
|
inline |
Definition at line 347 of file GenericCycleInfo.h.
References llvm::make_range(), toplevel_begin(), and toplevel_end().
|
inline |
Definition at line 343 of file GenericCycleInfo.h.
Referenced by toplevel_cycles().
| void llvm::GenericCycleInfo< ContextT >::verify | ( | ) | const |
Verify that the entire cycle tree well-formed.
Definition at line 653 of file GenericCycleImpl.h.
References verifyCycleNest().
Referenced by FixIrreducibleImpl(), and llvm::CycleInfoVerifierPass::run().
| void llvm::GenericCycleInfo< ContextT >::verifyCycle | ( | CycleRef | C | ) | const |
Verify that C is actually a well-formed cycle in the CFG.
Definition at line 108 of file GenericCycleImpl.h.
References llvm::any_of(), assert(), B(), llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::CallingConv::C, llvm::children(), contains(), llvm::detail::DenseSetImpl< ValueT, MapTy >::contains(), llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::depth_first(), llvm::depth_first_ext(), llvm::SmallVectorTemplateCommon< T, typename >::end(), getBlocks(), getEntries(), getExitBlocks(), getHeader(), getNumBlocks(), getParent(), llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), llvm::df_iterator_default_set< NodeRef, SmallSize >::insert(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::inverse_children(), llvm_unreachable, llvm::SmallPtrSetImplBase::size(), and verifyCycleNest().
Referenced by fixIrreducible(), and verifyCycleNest().
| void llvm::GenericCycleInfo< ContextT >::verifyCycleNest | ( | bool | VerifyFull = false | ) | const |
Methods for debug and self-test.
Verify the internal consistency of the cycle tree.
Note that this does not check that cycles are really cycles in the CFG, or that the right set of cycles in the CFG were found.
Definition at line 631 of file GenericCycleImpl.h.
References assert(), llvm::CallingConv::C, contains(), cycles, getBlocks(), getCycle(), getHeader(), llvm::detail::DenseSetImpl< ValueT, MapTy >::insert(), llvm::CycleRef::isValid(), verifyCycle(), and verifyCycleNest().
| void llvm::GenericCycleInfo< ContextT >::verifyCycleNest | ( | CycleRef | C | ) | const |
Verify the parent-child relations of C.
Note that this does not check that C is really a cycle in the CFG.
Definition at line 182 of file GenericCycleImpl.h.
References assert(), llvm::CallingConv::C, llvm::children(), contains(), and getBlocks().
Referenced by splitCriticalEdge(), verify(), verifyCycle(), and verifyCycleNest().
Definition at line 82 of file GenericCycleInfo.h.
References llvm::Depth, and GenericCycleInfoCompute.
Referenced by compute(), and GenericCycleInfoCompute.