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:74

Templates

BlockT
LoopT

Method Overview

Methods

LoopBase<N, M>(BlockT* BB)

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

Parameters

BlockT* BB

LoopBase<N, M>()

Description

This creates an empty loop.

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

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:365

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:403

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:375

Parameters

LoopT* NewChild

llvm::LoopBase::iterator begin() const

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

llvm::LoopBase::block_iterator block_begin() const

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

llvm::LoopBase::block_iterator block_end() const

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

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

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

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:125

Parameters

const BlockT* BB

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:115

Parameters

const LoopT* L

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:131

Templates

InstT

Parameters

const InstT* Inst

bool empty() const

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

llvm::LoopBase::iterator end() const

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

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:154

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

Description

Return a direct, immutable handle to the blocks set.

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:181

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:175

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:268

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:264

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:292

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:260

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:256

Parameters

SmallVectorImpl<BlockT*>& ExitingBlocks

BlockT* getHeader() const

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

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:325

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:97

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:310

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:314

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:306

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:300

SmallVector<LoopT*, 4> getLoopsInPreorder()

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

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:341

unsigned int getNumBackEdges() const

Description

Calculate the number of back edges to the loop header.

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

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:168

LoopT* getParentLoop() const

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

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

Description

Return the loops contained entirely within this loop.

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

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

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

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:286

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:276

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:282

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:272

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:459

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:198

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:208

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:222

Parameters

const BlockT* BB

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:423

Parameters

BlockT* BB

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

Description

Print loop with all the BBs inside it.

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

Parameters

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

llvm::LoopBase::reverse_iterator rbegin() const

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

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:440

Parameters

BlockT* BB

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:396

Parameters

LoopT* Child

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:384

Parameters

llvm::LoopBase::iterator I

llvm::LoopBase::reverse_iterator rend() const

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

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:371

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:416

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:410

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:109

Parameters

LoopT* L

void verifyLoop() const

Description

Verify loop structure

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

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:453

Parameters

DenseSet<const LoopT*>* Loops

~LoopBase<N, M>()

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