class LoopBase

Declaration

template <class BlockT, class LoopT>
class LoopBase { /* full declaration omitted */ };

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:73

Templates

BlockT
LoopT

Member Variables

private LoopT* ParentLoop
private std::vector<LoopT*> SubLoops
private std::vector<BlockT*> Blocks
private SmallPtrSet<const BlockT*, 8> DenseBlockSet

Method Overview

Methods

LoopBase<N, M>(const LoopBase<BlockT, LoopT>&)

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:88

Parameters

const LoopBase<BlockT, LoopT>&

LoopBase<N, M>(BlockT* BB)

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:507

Parameters

BlockT* BB

LoopBase<N, M>()

Description

This creates an empty loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:505

void addBasicBlockToLoop(
    BlockT* NewBB,
    LoopInfoBase<BlockT, LoopT>& LI)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:401

Parameters

BlockT* NewBB
LoopInfoBase<BlockT, LoopT>& LI

void addBlockEntry(BlockT* BB)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:439

Parameters

BlockT* BB

void addChildLoop(LoopT* NewChild)

Description

Add the specified loop to be a child of this loop. This updates the loop depth of the new child.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:411

Parameters

LoopT* NewChild

llvm::LoopBase::iterator begin() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:170

llvm::LoopBase::block_iterator block_begin() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:192

llvm::LoopBase::block_iterator block_end() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:193

inline iterator_range<
    llvm::LoopBase::block_iterator>
blocks() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:194

template <class InstT>
bool contains(const InstT* Inst) const

Description

Return true if the specified instruction is in this loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:154

Templates

InstT

Parameters

const InstT* Inst

bool contains(const LoopT* L) const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:138

Parameters

const LoopT* L

bool contains(const BlockT* BB) const

Description

Return true if the specified basic block is in this loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:148

Parameters

const BlockT* BB

llvm::LoopBase::iterator end() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:171

ArrayRef<BlockT*> getBlocks() const

Description

Get a list of the basic blocks which make up this loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:187

SmallPtrSetImpl<const BlockT*>& getBlocksSet()

Description

Return a direct, mutable handle to the blocks set so that we can mutate it efficiently.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:214

const SmallPtrSetImpl<const BlockT*>&
getBlocksSet() const

Description

Return a direct, immutable handle to the blocks set.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:220

std::vector<BlockT*>& getBlocksVector()

Description

Return a direct, mutable handle to the blocks vector so that we can mutate it efficiently with techniques like `std::remove`.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:208

BlockT* getExitBlock() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:301

void getExitBlocks(
    SmallVectorImpl<BlockT*>& ExitBlocks) const

Description

Return all of the successor blocks of this loop. These are the blocks _outside of the current loop_ which are branched to.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:297

Parameters

SmallVectorImpl<BlockT*>& ExitBlocks

void getExitEdges(
    SmallVectorImpl<llvm::LoopBase::Edge>&
        ExitEdges) const

Description

Return all pairs of (_inside_block_,_outside_block_).

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:328

Parameters

SmallVectorImpl<llvm::LoopBase::Edge>& ExitEdges

BlockT* getExitingBlock() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:293

void getExitingBlocks(
    SmallVectorImpl<BlockT*>& ExitingBlocks) const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:289

Parameters

SmallVectorImpl<BlockT*>& ExitingBlocks

BlockT* getHeader() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:104

template <class Type>
static void getInnerLoopsInPreorder(
    const LoopT& L,
    SmallVectorImpl<Type>& PreOrderLoops)

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:361

Templates

Type

Parameters

const LoopT& L
SmallVectorImpl<Type>& PreOrderLoops

unsigned int getLoopDepth() const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:96

BlockT* getLoopLatch() const

Description

If there is a single latch block for this loop, return it. A latch block is a block that contains a branch back to the header.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:346

void getLoopLatches(
    SmallVectorImpl<BlockT*>& LoopLatches) const

Description

Return all loop latch blocks of this loop. A latch block is a block that contains a branch back to the header.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:350

Parameters

SmallVectorImpl<BlockT*>& LoopLatches

BlockT* getLoopPredecessor() const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:342

BlockT* getLoopPreheader() const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:336

SmallVector<LoopT*, 4> getLoopsInPreorder()

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:384

SmallVector<const LoopT*, 4> getLoopsInPreorder()
    const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:377

unsigned int getNumBackEdges() const

Description

Calculate the number of back edges to the loop header.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:266

unsigned int getNumBlocks() const

Description

Get the number of blocks in this loop in constant time. Invalidate the loop, indicating that it is no longer a loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:201

const LoopT* getOutermostLoop() const

Description

Get the outermost loop in which this loop is contained. This may be the loop itself, if it already is the outermost loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:117

LoopT* getOutermostLoop()

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:124

LoopT* getParentLoop() const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:113

const std::vector<LoopT*>& getSubLoops() const

Description

Return the loops contained entirely within this loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:159

std::vector<LoopT*>& getSubLoopsVector()

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:163

BlockT* getUniqueExitBlock() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:319

void getUniqueExitBlocks(
    SmallVectorImpl<BlockT*>& ExitBlocks) const

Description

Return all unique successor blocks of this loop. These are the blocks _outside of the current loop_ which are branched to.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:309

Parameters

SmallVectorImpl<BlockT*>& ExitBlocks

void getUniqueNonLatchExitBlocks(
    SmallVectorImpl<BlockT*>& ExitBlocks) const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:315

Parameters

SmallVectorImpl<BlockT*>& ExitBlocks

bool hasDedicatedExits() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:305

bool hasNoExitBlocks() const

Description

Return true if this loop does not have any exit blocks.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:322

bool isAnnotatedParallel() const

Description

Returns true if the loop is annotated parallel. Derived classes can override this method using static template polymorphism.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:495

bool isInnermost() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:181

bool isInvalid() const

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:231

bool isLoopExiting(const BlockT* BB) const

Description

True if terminator in the block can branch to another block that is outside of the current loop. \p BB must be inside the loop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:241

Parameters

const BlockT* BB

bool isLoopLatch(const BlockT* BB) const

Description

Returns true if \p BB is a loop-latch. A latch block is a block that contains a branch back to the header. This function is useful when there are multiple latches in a loop because

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:255

Parameters

const BlockT* BB

bool isOutermost() const

Description

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

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:184

void moveToHeader(BlockT* BB)

Description

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).

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:459

Parameters

BlockT* BB

void print(llvm::raw_ostream& OS,
           bool Verbose = false,
           bool PrintNested = true,
           unsigned int Depth = 0) const

Description

Print loop with all the BBs inside it.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:498

Parameters

llvm::raw_ostream& OS
bool Verbose = false
bool PrintNested = true
unsigned int Depth = 0

llvm::LoopBase::reverse_iterator rbegin() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:172

void removeBlockFromLoop(BlockT* BB)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:476

Parameters

BlockT* BB

LoopT* removeChildLoop(llvm::LoopBase::iterator I)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:420

Parameters

llvm::LoopBase::iterator I

LoopT* removeChildLoop(LoopT* Child)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:432

Parameters

LoopT* Child

llvm::LoopBase::reverse_iterator rend() const

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:173

void replaceChildLoopWith(LoopT* OldChild,
                          LoopT* NewChild)

Description

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.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:407

Parameters

LoopT* OldChild
LoopT* NewChild

void reserveBlocks(unsigned int size)

Description

interface to do reserve() for Blocks

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:452

Parameters

unsigned int size

void reverseBlock(unsigned int from)

Description

interface to reverse Blocks[from, end of loop] in this loop

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:446

Parameters

unsigned int from

void setParentLoop(LoopT* L)

Description

This is a raw interface for bypassing addChildLoop.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:132

Parameters

LoopT* L

void verifyLoop() const

Description

Verify loop structure

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:486

void verifyLoopNest(
    DenseSet<const LoopT*>* Loops) const

Description

Verify loop structure of this loop and all nested loops.

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:489

Parameters

DenseSet<const LoopT*>* Loops

~LoopBase<N, M>()

Declared at: llvm/include/llvm/Analysis/LoopInfo.h:521