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:546
Inherits from: LoopBase
Method Overview
- private Loop(llvm::BasicBlock * BB)
- private Loop()
- public void dump() const
- public void dumpVerbose() const
- public Optional<llvm::Loop::LoopBounds> getBounds(llvm::ScalarEvolution & SE) const
- public llvm::PHINode * getCanonicalInductionVariable() const
- public bool getIncomingAndBackEdge(llvm::BasicBlock *& Incoming, llvm::BasicBlock *& Backedge) const
- public bool getInductionDescriptor(llvm::ScalarEvolution & SE, llvm::InductionDescriptor & IndDesc) const
- public llvm::PHINode * getInductionVariable(llvm::ScalarEvolution & SE) const
- public llvm::ICmpInst * getLatchCmpInst() const
- public llvm::Loop::LocRange getLocRange() const
- public llvm::BranchInst * getLoopGuardBranch() const
- public llvm::MDNode * getLoopID() const
- public llvm::StringRef getName() const
- public llvm::DebugLoc getStartLoc() const
- public bool hasLoopInvariantOperands(const llvm::Instruction * I) const
- public bool isAnnotatedParallel() const
- public bool isAuxiliaryInductionVariable(llvm::PHINode & AuxIndVar, llvm::ScalarEvolution & SE) const
- public bool isCanonical(llvm::ScalarEvolution & SE) const
- public bool isGuarded() const
- public bool isLCSSAForm(const llvm::DominatorTree & DT, bool IgnoreTokens = true) const
- public bool isLoopInvariant(const llvm::Value * V) const
- public bool isLoopSimplifyForm() const
- public bool isRecursivelyLCSSAForm(const llvm::DominatorTree & DT, const llvm::LoopInfo & LI, bool IgnoreTokens = true) const
- public bool isRotatedForm() const
- public bool isSafeToClone() const
- public bool makeLoopInvariant(llvm::Instruction * I, bool & Changed, llvm::Instruction * InsertPt = nullptr, llvm::MemorySSAUpdater * MSSAU = nullptr) const
- public bool makeLoopInvariant(llvm::Value * V, bool & Changed, llvm::Instruction * InsertPt = nullptr, llvm::MemorySSAUpdater * MSSAU = nullptr) const
- public void setLoopAlreadyUnrolled()
- public void setLoopID(llvm::MDNode * LoopID) const
- public void setLoopMustProgress()
- private ~Loop()
Methods
¶Loop(llvm::BasicBlock* BB)
Loop(llvm::BasicBlock* BB)
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:900
Parameters
- llvm::BasicBlock* BB
¶Loop()
Loop()
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:896
¶void dump() const
void dump() const
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:875
¶void dumpVerbose() const
void dumpVerbose() const
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:876
¶Optional<llvm::Loop::LoopBounds> getBounds(
llvm::ScalarEvolution& SE) const
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:751
Parameters
¶llvm::PHINode* getCanonicalInductionVariable()
const
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:609
¶bool getIncomingAndBackEdge(
llvm::BasicBlock*& Incoming,
llvm::BasicBlock*& Backedge) const
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:616
Parameters
- llvm::BasicBlock*& Incoming
- llvm::BasicBlock*& Backedge
¶bool getInductionDescriptor(
llvm::ScalarEvolution& SE,
llvm::InductionDescriptor& IndDesc) const
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:764
Parameters
- llvm::ScalarEvolution& SE
- llvm::InductionDescriptor& IndDesc
¶llvm::PHINode* getInductionVariable(
llvm::ScalarEvolution& SE) const
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:760
Parameters
¶llvm::ICmpInst* getLatchCmpInst() const
llvm::ICmpInst* getLatchCmpInst() const
Description
Get the latch condition instruction.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:612
¶llvm::Loop::LocRange getLocRange() const
llvm::Loop::LocRange getLocRange() const
Description
Return the source code span of the loop.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:886
¶llvm::BranchInst* getLoopGuardBranch() const
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:795
¶llvm::MDNode* getLoopID() const
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:854
¶llvm::StringRef getName() const
llvm::StringRef getName() const
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:888
¶llvm::DebugLoc getStartLoc() const
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:883
¶bool hasLoopInvariantOperands(
const llvm::Instruction* I) const
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:572
Parameters
- const llvm::Instruction* I
¶bool isAnnotatedParallel() const
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:846
¶bool isAuxiliaryInductionVariable(
llvm::PHINode& AuxIndVar,
llvm::ScalarEvolution& SE) const
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:774
Parameters
- llvm::PHINode& AuxIndVar
- llvm::ScalarEvolution& SE
¶bool isCanonical(llvm::ScalarEvolution& SE) const
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:815
Parameters
¶bool isGuarded() const
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:800
¶bool isLCSSAForm(const llvm::DominatorTree& DT,
bool IgnoreTokens = true) const
bool isLCSSAForm(const llvm::DominatorTree& DT,
bool IgnoreTokens = true) const
Description
Return true if the Loop is in LCSSA form. If \p IgnoreTokens is set to true, token values defined inside loop are allowed to violate LCSSA form.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:819
Parameters
- const llvm::DominatorTree& DT
- bool IgnoreTokens = true
¶bool isLoopInvariant(const llvm::Value* V) const
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:568
Parameters
- const llvm::Value* V
¶bool isLoopSimplifyForm() const
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:829
¶bool isRecursivelyLCSSAForm(
const llvm::DominatorTree& DT,
const llvm::LoopInfo& LI,
bool IgnoreTokens = true) const
bool isRecursivelyLCSSAForm(
const llvm::DominatorTree& DT,
const llvm::LoopInfo& LI,
bool IgnoreTokens = true) const
Description
Return true if this Loop and all inner subloops are in LCSSA form. If \p IgnoreTokens is set to true, token values defined inside loop are allowed to violate LCSSA form.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:824
Parameters
- const llvm::DominatorTree& DT
- const llvm::LoopInfo& LI
- bool IgnoreTokens = true
¶bool isRotatedForm() const
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:807
¶bool isSafeToClone() const
bool isSafeToClone() const
Description
Return true if the loop body is safe to clone in practice.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:832
¶bool makeLoopInvariant(
llvm::Instruction* I,
bool& Changed,
llvm::Instruction* InsertPt = nullptr,
llvm::MemorySSAUpdater* MSSAU = nullptr) const
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 \c I is already loop-invariant, and false if \c I can't be made loop-invariant. If \c I is made loop-invariant, \c Changed is set to true. 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:598
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
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 \c V is already loop-invariant, and false if \c V can't be made loop-invariant. If \c V is made loop-invariant, \c Changed is set to true. 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:584
Parameters
- llvm::Value* V
- bool& Changed
- llvm::Instruction* InsertPt = nullptr
- llvm::MemorySSAUpdater* MSSAU = nullptr
¶void setLoopAlreadyUnrolled()
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:870
¶void setLoopID(llvm::MDNode* LoopID) const
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:862
Parameters
- llvm::MDNode* LoopID
¶void setLoopMustProgress()
void setLoopMustProgress()
Description
Add llvm.loop.mustprogress to this loop's loop id metadata.
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:873
¶~Loop()
~Loop()
Declared at: llvm/include/llvm/Analysis/LoopInfo.h:901