class Loop

Declaration

class Loop : public LoopBase { /* full declaration omitted */ };

Description

Represents a single loop in the control flow graph. Note that not all SCCs in the CFG are necessarily loops.

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

Inherits from: LoopBase

Method Overview

Methods

void dump() const

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

void dumpVerbose() const

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

Optional<llvm::Loop::LoopBounds> getBounds(
    llvm::ScalarEvolution& SE) const

Description

Return the struct LoopBounds collected if all struct members are found, else None.

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

Parameters

llvm::ScalarEvolution& SE

llvm::PHINode* getCanonicalInductionVariable()
    const

Description

Check to see if the loop has a canonical induction variable: an integer recurrence that starts at 0 and increments by one each time through the loop. If so, return the phi node that corresponds to it. The IndVarSimplify pass transforms loops to have a canonical induction variable.

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

bool getIncomingAndBackEdge(
    llvm::BasicBlock*& Incoming,
    llvm::BasicBlock*& Backedge) const

Description

Obtain the unique incoming and back edge. Return false if they are non-unique or the loop is dead; otherwise, return true.

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

Parameters

llvm::BasicBlock*& Incoming
llvm::BasicBlock*& Backedge

bool getInductionDescriptor(
    llvm::ScalarEvolution& SE,
    llvm::InductionDescriptor& IndDesc) const

Description

Get the loop induction descriptor for the loop induction variable. Return true if the loop induction variable is found.

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

Parameters

llvm::ScalarEvolution& SE
llvm::InductionDescriptor& IndDesc

llvm::PHINode* getInductionVariable(
    llvm::ScalarEvolution& SE) const

Description

Return the loop induction variable if found, else return nullptr. An instruction is considered as the loop induction variable if - it is an induction variable of the loop; and - it is used to determine the condition of the branch in the loop latch Note: the induction variable doesn't need to be canonical, i.e. starts at zero and increments by one each time through the loop (but it can be).

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

Parameters

llvm::ScalarEvolution& SE

llvm::Loop::LocRange getLocRange() const

Description

Return the source code span of the loop.

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

llvm::BranchInst* getLoopGuardBranch() const

Description

Return the loop guard branch, if it exists. This currently only works on simplified loop, as it requires a preheader and a latch to identify the guard. It will work on loops of the form:

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

llvm::MDNode* getLoopID() const

Description

Return the llvm.loop loop id metadata node for this loop if it is present. If this loop contains the same llvm.loop metadata on each branch to the header then the node is returned. If any latch instruction does not contain llvm.loop or if multiple latches contain different nodes then 0 is returned.

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

llvm::StringRef getName() const

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

llvm::DebugLoc getStartLoc() const

Description

Return the debug location of the start of this loop. This looks for a BB terminating instruction with a known debug location by looking at the preheader and header blocks. If it cannot find a terminating instruction with location information, it returns an unknown location.

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

bool hasLoopInvariantOperands(
    const llvm::Instruction* I) const

Description

Return true if all the operands of the specified instruction are loop invariant.

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

Parameters

const llvm::Instruction* I

bool isAnnotatedParallel() const

Description

Returns true if the loop is annotated parallel. A parallel loop can be assumed to not contain any dependencies between iterations by the compiler. That is, any loop-carried dependency checking can be skipped completely when parallelizing the loop on the target machine. Thus, if the parallel loop information originates from the programmer, e.g. via the OpenMP parallel for pragma, it is the programmer's responsibility to ensure there are no loop-carried dependencies. The final execution order of the instructions across iterations is not guaranteed, thus, the end result might or might not implement actual concurrent execution of instructions across multiple iterations.

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

bool isAuxiliaryInductionVariable(
    llvm::PHINode& AuxIndVar,
    llvm::ScalarEvolution& SE) const

Description

Return true if the given PHINode \p AuxIndVar is - in the loop header - not used outside of the loop - incremented by a loop invariant step for each loop iteration - step instruction opcode should be add or sub Note: auxiliary induction variable is not required to be used in the conditional branch in the loop latch. (but it can be)

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

Parameters

llvm::PHINode& AuxIndVar
llvm::ScalarEvolution& SE

bool isCanonical(llvm::ScalarEvolution& SE) const

Description

Return true if the loop induction variable starts at zero and increments by one each time through the loop.

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

Parameters

llvm::ScalarEvolution& SE

bool isGuarded() const

Description

Return true iff the loop is - in simplify rotated form, and - guarded by a loop guard branch.

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

bool isLCSSAForm(llvm::DominatorTree& DT) const

Description

Return true if the Loop is in LCSSA form.

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

Parameters

llvm::DominatorTree& DT

bool isLoopInvariant(const llvm::Value* V) const

Description

Return true if the specified value is loop invariant.

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

Parameters

const llvm::Value* V

bool isLoopSimplifyForm() const

Description

Return true if the Loop is in the form that the LoopSimplify form transforms loops to, which is sometimes called normal form.

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

bool isRecursivelyLCSSAForm(
    llvm::DominatorTree& DT,
    const llvm::LoopInfo& LI) const

Description

Return true if this Loop and all inner subloops are in LCSSA form.

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

Parameters

llvm::DominatorTree& DT
const llvm::LoopInfo& LI

bool isRotatedForm() const

Description

Return true if the loop is in rotated form. This does not check if the loop was rotated by loop rotation, instead it only checks if the loop is in rotated form (has a valid latch that exists the loop).

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

bool isSafeToClone() const

Description

Return true if the loop body is safe to clone in practice.

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

bool makeLoopInvariant(
    llvm::Instruction* I,
    bool& Changed,
    llvm::Instruction* InsertPt = nullptr,
    llvm::MemorySSAUpdater* MSSAU = nullptr) const

Description

If the given instruction is inside of the loop and it can be hoisted, do so to make it trivially loop-invariant. Return true if the instruction after any hoisting is loop invariant. This function can be used as a slightly more aggressive replacement for isLoopInvariant. If InsertPt is specified, it is the point to hoist instructions to. If null, the terminator of the loop preheader is used.

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

Parameters

llvm::Instruction* I
bool& Changed
llvm::Instruction* InsertPt = nullptr
llvm::MemorySSAUpdater* MSSAU = nullptr

bool makeLoopInvariant(
    llvm::Value* V,
    bool& Changed,
    llvm::Instruction* InsertPt = nullptr,
    llvm::MemorySSAUpdater* MSSAU = nullptr) const

Description

If the given value is an instruction inside of the loop and it can be hoisted, do so to make it trivially loop-invariant. Return true if the value after any hoisting is loop invariant. This function can be used as a slightly more aggressive replacement for isLoopInvariant. If InsertPt is specified, it is the point to hoist instructions to. If null, the terminator of the loop preheader is used.

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

Parameters

llvm::Value* V
bool& Changed
llvm::Instruction* InsertPt = nullptr
llvm::MemorySSAUpdater* MSSAU = nullptr

void setLoopAlreadyUnrolled()

Description

Add llvm.loop.unroll.disable to this loop's loop id metadata. Remove existing unroll metadata and add unroll disable metadata to indicate the loop has already been unrolled. This prevents a loop from being unrolled more than is directed by a pragma if the loop unrolling pass is run more than once (which it generally is).

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

void setLoopID(llvm::MDNode* LoopID) const

Description

Set the llvm.loop loop id metadata for this loop. The LoopID metadata node will be added to each terminator instruction in the loop that branches to the loop header. The LoopID metadata node should have one or more operands and the first operand should be the node itself.

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

Parameters

llvm::MDNode* LoopID