LLVM 24.0.0git
llvm::LoopBase< BlockT, LoopT > Class Template Reference

Instances of this class are used to represent loops that are detected in the flow graph. More...

#include "llvm/Support/GenericLoopInfo.h"

Inheritance diagram for llvm::LoopBase< BlockT, LoopT >:
[legend]

Public Types

using iterator = typename std::vector<LoopT *>::const_iterator
using reverse_iterator
using block_iterator = typename ArrayRef<BlockT *>::const_iterator

Public Member Functions

unsigned getLoopDepth () const
 Return the nesting level of this loop.
BlockT * getHeader () const
LoopT * getParentLoop () const
 Return the parent loop if it exists or nullptr for top level loops.
const LoopT * getOutermostLoop () const
 Get the outermost loop in which this loop is contained.
LoopT * getOutermostLoop ()
void setParentLoop (LoopT *L)
 This is a raw interface for bypassing addChildLoop.
bool contains (const LoopT *L) const
 Return true if the specified loop is contained within this loop.
bool contains (const BlockT *BB) const
 Return true if the specified basic block is in this loop, using LoopInfo's block-to-loop map.
template<class InstT>
bool contains (const InstT *Inst) const
 Return true if the specified instruction is in this loop.
const std::vector< LoopT * > & getSubLoops () const
 Return the loops contained entirely within this loop.
iterator begin () const
iterator end () const
reverse_iterator rbegin () const
reverse_iterator rend () const
bool isInnermost () const
 Return true if the loop does not contain any (natural) loops.
bool isOutermost () const
 Return true if the loop does not have a parent (natural) loop.
ArrayRef< BlockT * > getBlocks () const
 Get a list of the basic blocks which make up this loop.
block_iterator block_begin () const
block_iterator block_end () const
iterator_range< block_iteratorblocks () const
unsigned getNumBlocks () const
 Get the number of blocks in this loop in constant time.
bool isInvalid () const
 Return true if this loop is no longer valid.
bool isLoopExiting (const BlockT *BB) const
 True if terminator in the block can branch to another block that is outside of the current loop.
bool isLoopLatch (const BlockT *BB) const
unsigned getNumBackEdges () const
 Calculate the number of back edges to the loop header.
void getExitingBlocks (SmallVectorImpl< BlockT * > &ExitingBlocks) const
 Return all blocks inside the loop that have successors outside of the loop.
BlockT * getExitingBlock () const
 If getExitingBlocks would return exactly one block, return that block.
void getExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const
 Return all of the successor blocks of this loop.
BlockT * getExitBlock () const
 If getExitBlocks would return exactly one block, return that block.
bool hasDedicatedExits () const
 Return true if no exit block for the loop has a predecessor that is outside the loop.
void getUniqueExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const
 Return all unique successor blocks of this loop.
void getUniqueNonLatchExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const
 Return all unique successor blocks of this loop except successors from Latch block are not considered.
BlockT * getUniqueExitBlock () const
 If getUniqueExitBlocks would return exactly one block, return that block.
BlockT * getLoopPreheader () const
 If there is a preheader for this loop, return it.
BlockT * getLoopPredecessor () const
 If the given loop's header has exactly one unique predecessor outside the loop, return it.
BlockT * getLoopLatch () const
 If there is a single latch block for this loop, return it.
void getLoopLatches (SmallVectorImpl< BlockT * > &LoopLatches) const
 Return all loop latch blocks of this loop.
SmallVector< const LoopT *, 4 > getLoopsInPreorder () const
 Return all loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.
SmallVector< LoopT *, 4 > getLoopsInPreorder ()
void addBasicBlockToLoop (BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI)
 This method is used by other analyses to update loop information.
void replaceChildLoopWith (LoopT *OldChild, LoopT *NewChild)
 This is used when splitting loops up.
void addChildLoop (LoopT *NewChild)
 Add the specified loop to be a child of this loop.
LoopT * removeChildLoop (iterator I)
 This removes the specified child from being a subloop of this loop.
LoopT * removeChildLoop (LoopT *Child)
 This removes the specified child from being a subloop of this loop.
void addBlockEntry (BlockT *BB)
 This adds a basic block directly to the basic block list.
void reserveBlocks (unsigned Size)
 interface to do reserve() for Blocks
void reserveSubLoops (unsigned Size)
 interface to do reserve() for SubLoops
void moveToHeader (BlockT *BB)
 This method is used to move BB (which must be part of this loop) to be the loop header of the loop (the block that dominates all others).
void removeBlockFromLoop (BlockT *BB)
 This removes the specified basic block from the current loop, updating the Blocks as appropriate.
void verifyLoop () const
 Verify loop structure.
void verifyLoopNest (DenseSet< const LoopT * > *Loops) const
 Verify loop structure of this loop and all nested loops.
bool isAnnotatedParallel () const
 Returns true if the loop is annotated parallel.
void print (raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
 Print loop with all the BBs inside it.

Static Public Member Functions

template<class Type>
static void getInnerLoopsInPreorder (const LoopT &L, SmallVectorImpl< Type > &PreOrderLoops)
 Return all inner loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.

Protected Member Functions

 LoopBase ()
 This creates an empty loop.
 ~LoopBase ()

Friends

class LoopInfoBase< BlockT, LoopT >

Detailed Description

template<class BlockT, class LoopT>
class llvm::LoopBase< BlockT, LoopT >

Instances of this class are used to represent loops that are detected in the flow graph.

Definition at line 59 of file GenericLoopInfo.h.

Member Typedef Documentation

◆ block_iterator

template<class BlockT, class LoopT>
using llvm::LoopBase< BlockT, LoopT >::block_iterator = typename ArrayRef<BlockT *>::const_iterator

Definition at line 203 of file GenericLoopInfo.h.

◆ iterator

template<class BlockT, class LoopT>
using llvm::LoopBase< BlockT, LoopT >::iterator = typename std::vector<LoopT *>::const_iterator

Definition at line 179 of file GenericLoopInfo.h.

◆ reverse_iterator

template<class BlockT, class LoopT>
using llvm::LoopBase< BlockT, LoopT >::reverse_iterator
Initial value:
typename std::vector<LoopT *>::const_reverse_iterator

Definition at line 180 of file GenericLoopInfo.h.

Constructor & Destructor Documentation

◆ LoopBase()

template<class BlockT, class LoopT>
llvm::LoopBase< BlockT, LoopT >::LoopBase ( )
inlineprotected

This creates an empty loop.

Definition at line 486 of file GenericLoopInfo.h.

◆ ~LoopBase()

template<class BlockT, class LoopT>
llvm::LoopBase< BlockT, LoopT >::~LoopBase ( )
inlineprotected

Definition at line 497 of file GenericLoopInfo.h.

References BlockData.

Member Function Documentation

◆ addBasicBlockToLoop()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::addBasicBlockToLoop ( BlockT * NewBB,
LoopInfoBase< BlockT, LoopT > & LIB )

This method is used by other analyses to update loop information.

addBasicBlockToLoop - This method is used by other analyses to update loop information.

NewBB is set to be a new member of the current loop. Because of this, it is added as a member of all parent loops, and is added to the specified LoopInfo object as being in the current basic block. It is not valid to replace the loop header with this method.

Definition at line 281 of file GenericLoopInfoImpl.h.

References assert(), and isInvalid().

Referenced by llvm::addClonedBlockToLoopInfo(), buildClonedLoops(), cloneLoopBlocks(), llvm::cloneLoopWithPreheader(), llvm::VPBasicBlock::connectToPredecessors(), llvm::expandReductionViaLoop(), splitBlock(), and UpdateAnalysisInformation().

◆ addBlockEntry()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::addBlockEntry ( BlockT * BB)
inline

This adds a basic block directly to the basic block list.

This should only be used by transformations that create new loops. Other transformations should use addBasicBlockToLoop.

Definition at line 413 of file GenericLoopInfo.h.

References assert(), BlockData, and isInvalid().

Referenced by separateNestedLoop().

◆ addChildLoop()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::addChildLoop ( LoopT * NewChild)
inline

◆ begin()

template<class BlockT, class LoopT>
iterator llvm::LoopBase< BlockT, LoopT >::begin ( ) const
inline

◆ block_begin()

template<class BlockT, class LoopT>
block_iterator llvm::LoopBase< BlockT, LoopT >::block_begin ( ) const
inline

◆ block_end()

template<class BlockT, class LoopT>
block_iterator llvm::LoopBase< BlockT, LoopT >::block_end ( ) const
inline

Definition at line 205 of file GenericLoopInfo.h.

References getBlocks().

Referenced by blocks(), and llvm::VPlan::execute().

◆ blocks()

◆ contains() [1/3]

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::contains ( const BlockT * BB) const
inline

Return true if the specified basic block is in this loop, using LoopInfo's block-to-loop map.

This is only valid when that map agrees with the block lists. Avoid when the loop nest is being restructured, when a block may appear in a loop's block list before it is mapped to that loop. Code in such a transient state must scan getBlocks() directly instead.

Definition at line 160 of file GenericLoopInfo.h.

References assert(), contains(), and isInvalid().

◆ contains() [2/3]

template<class BlockT, class LoopT>
template<class InstT>
bool llvm::LoopBase< BlockT, LoopT >::contains ( const InstT * Inst) const
inline

Return true if the specified instruction is in this loop.

Definition at line 170 of file GenericLoopInfo.h.

References contains().

◆ contains() [3/3]

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::contains ( const LoopT * L) const
inline

Return true if the specified loop is contained within this loop.

This walks the parent chain and is O(depth). Deep nesting is not a performance target (yet).

Definition at line 142 of file GenericLoopInfo.h.

References assert(), and isInvalid().

Referenced by llvm::RecurrenceDescriptor::AddReductionVar(), llvm::LoopSafetyInfo::allLoopPathsLeadToBlock(), areInnerLoopLatchPHIsSupported(), buildClonedLoops(), CanProveNotTakenFirstIteration(), checkOuterLoopInsts(), collectCastInstrs(), llvm::collectChildrenInLoop(), collectTransitivePredecessors(), ConnectProlog(), contains(), contains(), llvm::ICFLoopSafetyInfo::doesNotWriteMemoryBefore(), llvm::ICFLoopSafetyInfo::doesNotWriteMemoryBefore(), llvm::ScalarEvolution::getAddRecExpr(), getInnermostLoopFor(), llvm::getLoopConvergenceHeart(), getLoopLatches(), getMinMaxRecurrence(), getNumBackEdges(), getSingleSchedPred(), hoistLoopToNewParent(), inSubLoop(), isExitingLoop(), llvm::RecurrenceDescriptor::isFixedOrderRecurrence(), isFoldableInLoop(), llvm::InductionDescriptor::isFPInductionPHI(), isLoopExiting(), isLoopLatch(), isNotUsedOrFoldableInLoop(), llvm::isSafeToUnrollAndJam(), llvm::isUniformLoop(), needToInsertPhisForLCSSA(), noConflictingReadWrites(), partitionLoopBlocks(), pointerInvalidatedByLoop(), llvm::promoteLoopAccessesToScalars(), rebuildLoopAfterUnswitch(), llvm::LoopInfo::replacementPreservesLCSSAForm(), sink(), splitPredecessorsOfLoopExit(), llvm::UnrollAndJamLoop(), llvm::UnrollLoop(), unswitchNontrivialInvariants(), unswitchTrivialSwitch(), and visitPointers().

◆ end()

template<class BlockT, class LoopT>
iterator llvm::LoopBase< BlockT, LoopT >::end ( ) const
inline

◆ getBlocks()

◆ getExitBlock()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getExitBlock ( ) const

If getExitBlocks would return exactly one block, return that block.

getExitBlock - If getExitBlocks would return exactly one block, return that block.

Otherwise return null.

Definition at line 106 of file GenericLoopInfoImpl.h.

References llvm::getExitBlockHelper().

Referenced by checkLoopsStructure(), DoFlattenLoopPair(), llvm::LoopNest::getInterveningInstructions(), simplifyLCSSAPhis(), splitLoopBound(), and llvm::UnrollAndJamLoop().

◆ getExitBlocks()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::getExitBlocks ( SmallVectorImpl< BlockT * > & ExitBlocks) const

Return all of the successor blocks of this loop.

getExitBlocks - Return all of the successor blocks of this loop.

These are the blocks outside of the current loop which are branched to.

Definition at line 63 of file GenericLoopInfoImpl.h.

References assert(), blocks, llvm::children(), contains(), isInvalid(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by isReachableImpl(), and verifyLoop().

◆ getExitingBlock()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getExitingBlock ( ) const

If getExitingBlocks would return exactly one block, return that block.

getExitingBlock - If getExitingBlocks would return exactly one block, return that block.

Otherwise return null.

Definition at line 47 of file GenericLoopInfoImpl.h.

References llvm::any_of(), assert(), blocks, llvm::children(), contains(), llvm::find_singleton(), isExitBlock(), and isInvalid().

Referenced by checkLoopsStructure(), DoFlattenLoopPair(), splitLoopBound(), and llvm::UnrollAndJamLoop().

◆ getExitingBlocks()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::getExitingBlocks ( SmallVectorImpl< BlockT * > & ExitingBlocks) const

Return all blocks inside the loop that have successors outside of the loop.

getExitingBlocks - Return all blocks inside the loop that have successors outside of the loop.

These are the blocks inside of the current loop which branch out. The returned list is always unique.

Definition at line 32 of file GenericLoopInfoImpl.h.

References assert(), blocks, llvm::children(), contains(), isInvalid(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ getHeader()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getHeader ( ) const
inline

Definition at line 105 of file GenericLoopInfo.h.

References getBlocks().

Referenced by llvm::addClonedBlockToLoopInfo(), llvm::BlockFrequencyInfoImplBase::addLoopSuccessorsToDist(), llvm::RecurrenceDescriptor::AddReductionVar(), llvm::addStringMetadataToLoop(), llvm::LoopSafetyInfo::allLoopPathsLeadToBlock(), areAllLoadsDereferenceable(), buildClonedLoops(), CanProveNotTakenFirstIteration(), CanWidenIV(), checkLoopsStructure(), checkOuterLoopInsts(), checkOverflow(), checkPHIs(), llvm::cloneLoopWithPreheader(), collectTransitivePredecessors(), CompareSCEVComplexity(), llvm::LoopSafetyInfo::computeBlockColors(), llvm::SimpleLoopSafetyInfo::computeLoopSafetyInfo(), createStringMetadata(), detectShiftUntilBitTestIdiom(), detectShiftUntilZeroIdiom(), llvm::ICFLoopSafetyInfo::doesNotWriteMemoryBefore(), DoFlattenLoopPair(), emitBasicBlockLoopComments(), llvm::SystemZPostRASchedStrategy::enterMBB(), FlattenLoopPair(), llvm::ScalarEvolution::getAddExpr(), llvm::ScalarEvolution::getAddRecExpr(), llvm::LoopNest::getInterveningInstructions(), llvm::getLoopConvergenceHeart(), getLoopLatch(), getLoopLatches(), llvm::BlockFrequencyInfoImplBase::getLoopName(), getLoopPredecessor(), getMinMaxRecurrence(), getNumBackEdges(), getSingleSchedPred(), llvm::getStartAndEndForAccess(), llvm::getStartAndEndForAccess(), llvm::getStrideFromAddRec(), llvm::VPlanTransforms::handleMultiUseReductions(), hasSupportedLoopDepth(), llvm::ScalarEvolution::isBasicBlockEntryGuardedByCond(), isExistingPhi(), isExplicitVecOuterLoop(), llvm::RecurrenceDescriptor::isFixedOrderRecurrence(), llvm::InductionDescriptor::isFPInductionPHI(), llvm::SimpleLoopSafetyInfo::isGuaranteedToExecute(), llvm::InductionDescriptor::isInductionPHI(), llvm::ScalarEvolution::isKnownViaInduction(), isLoadInvariantInLoop(), isLoopLatch(), pointerInvalidatedByLoop(), print(), llvm::SCEV::print(), PrintParentLoopComment(), removeBlockFromLoops(), llvm::LoopVectorizationUtils::reportVectorization(), llvm::LoopInterchangePass::run(), splitLoopBound(), llvm::UnrollAndJamLoop(), updateLoopInfo(), llvm::MachineTraceMetrics::Ensemble::verify(), verifyLoop(), and visitPointers().

◆ getInnerLoopsInPreorder()

template<class BlockT, class LoopT>
template<class Type>
void llvm::LoopBase< BlockT, LoopT >::getInnerLoopsInPreorder ( const LoopT & L,
SmallVectorImpl< Type > & PreOrderLoops )
inlinestatic

Return all inner loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.

Definition at line 335 of file GenericLoopInfo.h.

References llvm::SmallVectorImpl< T >::append(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SmallVectorImpl< T >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by getLoopsInPreorder(), and getLoopsInPreorder().

◆ getLoopDepth()

template<class BlockT, class LoopT>
unsigned llvm::LoopBase< BlockT, LoopT >::getLoopDepth ( ) const
inline

Return the nesting level of this loop.

An outer-most loop has depth 1, for consistency with loop depth values used for basic blocks, where depth 0 is used for blocks not inside any loops.

Definition at line 97 of file GenericLoopInfo.h.

References assert(), D(), and isInvalid().

Referenced by checkDependencies(), emitBasicBlockLoopComments(), llvm::ScalarEvolution::getAddRecExpr(), getInnerMostLoop(), llvm::LoopNest::getInnermostLoop(), getInnermostLoopFor(), print(), PrintParentLoopComment(), and UpdateAnalysisInformation().

◆ getLoopLatch()

◆ getLoopLatches()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::getLoopLatches ( SmallVectorImpl< BlockT * > & LoopLatches) const
inline

Return all loop latch blocks of this loop.

A latch block is a block that contains a branch back to the header.

Definition at line 324 of file GenericLoopInfo.h.

References assert(), contains(), getHeader(), H, llvm::inverse_children(), isInvalid(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ getLoopPredecessor()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getLoopPredecessor ( ) const

If the given loop's header has exactly one unique predecessor outside the loop, return it.

getLoopPredecessor - If the given loop's header has exactly one unique predecessor outside the loop, return it.

Otherwise return null. This is less strict that the loop "preheader" concept, which requires the predecessor to have exactly one successor.

Definition at line 234 of file GenericLoopInfoImpl.h.

References assert(), contains(), getHeader(), llvm::inverse_children(), and isInvalid().

Referenced by getLoopPreheader(), and llvm::ScalarEvolution::isBasicBlockEntryGuardedByCond().

◆ getLoopPreheader()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getLoopPreheader ( ) const

If there is a preheader for this loop, return it.

getLoopPreheader - If there is a preheader for this loop, return it.

A loop has a preheader if there is only one edge to the header of the loop from outside of the loop. If this is the case, the block branching to the header of the loop is the preheader node.

This method returns null if there is no preheader for the loop.

A loop has a preheader if there is only one edge to the header of the loop from outside of the loop and it is legal to hoist instructions into the predecessor. If this is the case, the block branching to the header of the loop is the preheader node.

This method returns null if there is no preheader for the loop.

Definition at line 209 of file GenericLoopInfoImpl.h.

References assert(), llvm::children(), getLoopPredecessor(), llvm::hasSingleElement(), isInvalid(), and llvm::detail::isLegalToHoistInto().

Referenced by llvm::RecurrenceDescriptor::AddReductionVar(), buildClonedLoops(), CanProveNotTakenFirstIteration(), checkLoopsStructure(), checkOverflow(), checkPHIs(), llvm::cloneLoopWithPreheader(), llvm::VPlanTransforms::createHeaderPhiRecipes(), detectPopcountIdiom(), detectShiftUntilBitTestIdiom(), detectShiftUntilLessThanIdiom(), detectShiftUntilZeroIdiom(), detectShiftUntilZeroIdiom(), DoFlattenLoopPair(), FlattenLoopPair(), llvm::LoopNest::getInterveningInstructions(), getMinMaxRecurrence(), llvm::hoistRegion(), llvm::RecurrenceDescriptor::isFixedOrderRecurrence(), llvm::InductionDescriptor::isInductionPHI(), partitionLoopBlocks(), llvm::promoteLoopAccessesToScalars(), splitLoopBound(), llvm::UnrollAndJamLoop(), and llvm::LoopVectorizationPlanner::updateLoopMetadataAndProfileInfo().

◆ getLoopsInPreorder() [1/2]

template<class BlockT, class LoopT>
SmallVector< LoopT *, 4 > llvm::LoopBase< BlockT, LoopT >::getLoopsInPreorder ( )
inline

◆ getLoopsInPreorder() [2/2]

template<class BlockT, class LoopT>
SmallVector< const LoopT *, 4 > llvm::LoopBase< BlockT, LoopT >::getLoopsInPreorder ( ) const
inline

Return all loops in the loop nest rooted by the loop in preorder, with siblings in forward program order.

Definition at line 351 of file GenericLoopInfo.h.

References getInnerLoopsInPreorder(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

Referenced by checkDependencies(), llvm::cloneLoopWithPreheader(), and partitionOuterLoopBlocks().

◆ getNumBackEdges()

template<class BlockT, class LoopT>
unsigned llvm::LoopBase< BlockT, LoopT >::getNumBackEdges ( ) const
inline

Calculate the number of back edges to the loop header.

Definition at line 255 of file GenericLoopInfo.h.

References assert(), contains(), llvm::count_if(), getHeader(), llvm::inverse_children(), and isInvalid().

Referenced by detectShiftUntilBitTestIdiom(), and detectShiftUntilZeroIdiom().

◆ getNumBlocks()

template<class BlockT, class LoopT>
unsigned llvm::LoopBase< BlockT, LoopT >::getNumBlocks ( ) const
inline

Get the number of blocks in this loop in constant time.

Invalidate the loop, indicating that it is no longer a loop.

Definition at line 213 of file GenericLoopInfo.h.

References assert(), and isInvalid().

Referenced by cloneLoopNest(), detectShiftUntilBitTestIdiom(), detectShiftUntilZeroIdiom(), llvm::LoopBlocksDFS::LoopBlocksDFS(), and verifyLoop().

◆ getOutermostLoop() [1/2]

template<class BlockT, class LoopT>
LoopT * llvm::LoopBase< BlockT, LoopT >::getOutermostLoop ( )
inline

Definition at line 125 of file GenericLoopInfo.h.

◆ getOutermostLoop() [2/2]

template<class BlockT, class LoopT>
const LoopT * llvm::LoopBase< BlockT, LoopT >::getOutermostLoop ( ) const
inline

Get the outermost loop in which this loop is contained.

This may be the loop itself, if it already is the outermost loop.

Definition at line 118 of file GenericLoopInfo.h.

◆ getParentLoop()

template<class BlockT, class LoopT>
LoopT * llvm::LoopBase< BlockT, LoopT >::getParentLoop ( ) const
inline

Return the parent loop if it exists or nullptr for top level loops.

A loop is either top-level in a function (that is, it is not contained in any other loop) or it is entirely enclosed in some other loop. If a loop is top-level, it has no parent, otherwise its parent is the innermost loop in which it is enclosed.

Definition at line 114 of file GenericLoopInfo.h.

Referenced by llvm::addClonedBlockToLoopInfo(), buildClonedLoops(), checkLoopsStructure(), llvm::cloneLoopWithPreheader(), emitBasicBlockLoopComments(), llvm::LoopInfo::erase(), expandBounds(), getInnerMostLoop(), getInnermostLoopFor(), getTopMostExitingLoop(), llvm::hasIterationCountInvariantInParent(), hoistLoopToNewParent(), isOutermost(), PrintParentLoopComment(), removeBlockFromLoops(), llvm::LoopFlattenPass::run(), llvm::UnrollAndJamLoop(), llvm::UnrollLoop(), unswitchNontrivialInvariants(), and updateLoopInfo().

◆ getSubLoops()

template<class BlockT, class LoopT>
const std::vector< LoopT * > & llvm::LoopBase< BlockT, LoopT >::getSubLoops ( ) const
inline

Return the loops contained entirely within this loop.

Definition at line 175 of file GenericLoopInfo.h.

References assert(), and isInvalid().

Referenced by areInnerLoopLatchPHIsSupported(), begin(), checkLoopsStructure(), end(), llvm::LoopNest::getMaxPerfectDepth(), isEligibleLoopForm(), isInnermost(), populateWorklist(), rbegin(), and rend().

◆ getUniqueExitBlock()

template<class BlockT, class LoopT>
BlockT * llvm::LoopBase< BlockT, LoopT >::getUniqueExitBlock ( ) const

If getUniqueExitBlocks would return exactly one block, return that block.

Otherwise return null.

Definition at line 157 of file GenericLoopInfoImpl.h.

References llvm::getExitBlockHelper().

Referenced by areInnerLoopExitPHIsSupported(), and areOuterLoopExitPHIsSupported().

◆ getUniqueExitBlocks()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::getUniqueExitBlocks ( SmallVectorImpl< BlockT * > & ExitBlocks) const

Return all unique successor blocks of this loop.

These are the blocks outside of the current loop which are branched to.

Definition at line 141 of file GenericLoopInfoImpl.h.

References llvm::getUniqueExitBlocksHelper().

Referenced by hasDedicatedExits(), sink(), and splitPredecessorsOfLoopExit().

◆ getUniqueNonLatchExitBlocks()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::getUniqueNonLatchExitBlocks ( SmallVectorImpl< BlockT * > & ExitBlocks) const

Return all unique successor blocks of this loop except successors from Latch block are not considered.

If the exit comes from Latch has also non Latch predecessor in a loop it will be added to ExitBlocks. These are the blocks outside of the current loop which are branched to.

Definition at line 148 of file GenericLoopInfoImpl.h.

References assert(), getLoopLatch(), and llvm::getUniqueExitBlocksHelper().

◆ hasDedicatedExits()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::hasDedicatedExits ( ) const

Return true if no exit block for the loop has a predecessor that is outside the loop.

Definition at line 111 of file GenericLoopInfoImpl.h.

References contains(), getUniqueExitBlocks(), and llvm::inverse_children().

◆ isAnnotatedParallel()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isAnnotatedParallel ( ) const
inline

Returns true if the loop is annotated parallel.

Derived classes can override this method using static template polymorphism.

Definition at line 476 of file GenericLoopInfo.h.

Referenced by print().

◆ isInnermost()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isInnermost ( ) const
inline

Return true if the loop does not contain any (natural) loops.

Definition at line 193 of file GenericLoopInfo.h.

References getSubLoops().

Referenced by cloneLoopNest(), emitBasicBlockLoopComments(), llvm::LoopInfo::erase(), llvm::VPlan::execute(), isExplicitVecOuterLoop(), and llvm::LoopVectorizationUtils::reportVectorization().

◆ isInvalid()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isInvalid ( ) const
inline

Return true if this loop is no longer valid.

The only valid use of this helper is "assert(L.isInvalid())" or equivalent, since IsInvalid is set to true by the destructor. In other words, if this accessor returns true, the caller has already triggered UB by calling this accessor; and so it can only be called in a context where a return value of true indicates a programmer error.

Definition at line 224 of file GenericLoopInfo.h.

Referenced by addBasicBlockToLoop(), addBlockEntry(), addChildLoop(), blocks(), contains(), contains(), llvm::LoopInfo::erase(), getBlocks(), getExitBlocks(), getExitingBlock(), getExitingBlocks(), getLoopDepth(), getLoopLatch(), getLoopLatches(), getLoopPredecessor(), getLoopPreheader(), getNumBackEdges(), getNumBlocks(), getSubLoops(), isLoopExiting(), isLoopLatch(), moveToHeader(), removeBlockFromLoop(), removeChildLoop(), replaceChildLoopWith(), reserveBlocks(), reserveSubLoops(), setParentLoop(), verifyLoop(), and verifyLoopNest().

◆ isLoopExiting()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isLoopExiting ( const BlockT * BB) const
inline

True if terminator in the block can branch to another block that is outside of the current loop.

BB must be inside the loop.

Definition at line 234 of file GenericLoopInfo.h.

References assert(), llvm::children(), contains(), and isInvalid().

Referenced by getTopMostExitingLoop(), print(), and llvm::VirtRegAuxInfo::weightCalcHelper().

◆ isLoopLatch()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isLoopLatch ( const BlockT * BB) const
inline

Definition at line 248 of file GenericLoopInfo.h.

References assert(), contains(), getHeader(), llvm::inverse_children(), llvm::is_contained(), and isInvalid().

Referenced by print().

◆ isOutermost()

template<class BlockT, class LoopT>
bool llvm::LoopBase< BlockT, LoopT >::isOutermost ( ) const
inline

Return true if the loop does not have a parent (natural) loop.

Definition at line 196 of file GenericLoopInfo.h.

References getParentLoop().

Referenced by llvm::LoopInfo::erase(), and getCacheCostImpl().

◆ moveToHeader()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::moveToHeader ( BlockT * BB)
inline

This method is used to move BB (which must be part of this loop) to be the loop header of the loop (the block that dominates all others).

Definition at line 438 of file GenericLoopInfo.h.

References assert(), BlockData, and isInvalid().

◆ print()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::print ( raw_ostream & OS,
bool Verbose = false,
bool PrintNested = true,
unsigned Depth = 0 ) const

◆ rbegin()

template<class BlockT, class LoopT>
reverse_iterator llvm::LoopBase< BlockT, LoopT >::rbegin ( ) const
inline

Definition at line 184 of file GenericLoopInfo.h.

References getSubLoops().

◆ removeBlockFromLoop()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::removeBlockFromLoop ( BlockT * BB)
inline

This removes the specified basic block from the current loop, updating the Blocks as appropriate.

This does not update the mapping in the LoopInfo class.

Definition at line 456 of file GenericLoopInfo.h.

References assert(), BlockData, llvm::MutableArrayRef< T >::end(), llvm::find(), I, and isInvalid().

◆ removeChildLoop() [1/2]

template<class BlockT, class LoopT>
LoopT * llvm::LoopBase< BlockT, LoopT >::removeChildLoop ( iterator I)
inline

This removes the specified child from being a subloop of this loop.

The loop is not deleted, as it will presumably be inserted into another loop.

Definition at line 394 of file GenericLoopInfo.h.

References assert(), begin(), I, and isInvalid().

Referenced by llvm::LoopInfo::erase(), hoistLoopToNewParent(), rebuildLoopAfterUnswitch(), and removeChildLoop().

◆ removeChildLoop() [2/2]

template<class BlockT, class LoopT>
LoopT * llvm::LoopBase< BlockT, LoopT >::removeChildLoop ( LoopT * Child)
inline

This removes the specified child from being a subloop of this loop.

The loop is not deleted, as it will presumably be inserted into another loop.

Definition at line 406 of file GenericLoopInfo.h.

References llvm::find(), and removeChildLoop().

◆ rend()

template<class BlockT, class LoopT>
reverse_iterator llvm::LoopBase< BlockT, LoopT >::rend ( ) const
inline

Definition at line 185 of file GenericLoopInfo.h.

References getSubLoops().

◆ replaceChildLoopWith()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::replaceChildLoopWith ( LoopT * OldChild,
LoopT * NewChild )

This is used when splitting loops up.

replaceChildLoopWith - This is used when splitting loops up.

It replaces the OldChild entry in our children list with NewChild, and updates the parent pointer of OldChild to be null and the NewChild to be this loop. This updates the loop depth of the new child.

Definition at line 311 of file GenericLoopInfoImpl.h.

References assert(), and isInvalid().

Referenced by separateNestedLoop().

◆ reserveBlocks()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::reserveBlocks ( unsigned Size)
inline

interface to do reserve() for Blocks

Definition at line 424 of file GenericLoopInfo.h.

References assert(), isInvalid(), and Size.

Referenced by buildClonedLoops().

◆ reserveSubLoops()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::reserveSubLoops ( unsigned Size)
inline

interface to do reserve() for SubLoops

Definition at line 431 of file GenericLoopInfo.h.

References assert(), isInvalid(), and Size.

◆ setParentLoop()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::setParentLoop ( LoopT * L)
inline

This is a raw interface for bypassing addChildLoop.

Definition at line 133 of file GenericLoopInfo.h.

References assert(), and isInvalid().

◆ verifyLoop()

◆ verifyLoopNest()

template<class BlockT, class LoopT>
void llvm::LoopBase< BlockT, LoopT >::verifyLoopNest ( DenseSet< const LoopT * > * Loops) const

Verify loop structure of this loop and all nested loops.

verifyLoop - Verify loop structure of this loop and all nested loops.

Definition at line 401 of file GenericLoopInfoImpl.h.

References assert(), begin(), E(), end(), I, isInvalid(), Loops, and verifyLoop().

◆ LoopInfoBase< BlockT, LoopT >

template<class BlockT, class LoopT>
friend class LoopInfoBase< BlockT, LoopT >
friend

Definition at line 479 of file GenericLoopInfo.h.

References llvm::Depth, and llvm::Verbose.

Member Data Documentation

◆ BlockData

template<class BlockT, class LoopT>
BlockT** llvm::LoopBase< BlockT, LoopT >::BlockData = nullptr

◆ PendingHeader

template<class BlockT, class LoopT>
BlockT* llvm::LoopBase< BlockT, LoopT >::PendingHeader

Definition at line 72 of file GenericLoopInfo.h.


The documentation for this class was generated from the following files: