LLVM API Documentation

Public Member Functions | Friends
llvm::Loop Class Reference

#include <LoopInfo.h>

Inheritance diagram for llvm::Loop:
Inheritance graph
[legend]
Collaboration diagram for llvm::Loop:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Loop ()
bool isLoopInvariant (Value *V) const
bool hasLoopInvariantOperands (Instruction *I) const
bool makeLoopInvariant (Value *V, bool &Changed, Instruction *InsertPt=nullptr) const
bool makeLoopInvariant (Instruction *I, bool &Changed, Instruction *InsertPt=nullptr) const
PHINodegetCanonicalInductionVariable () const
bool isLCSSAForm (DominatorTree &DT) const
 isLCSSAForm - Return true if the Loop is in LCSSA form
bool isLoopSimplifyForm () const
bool isSafeToClone () const
 isSafeToClone - Return true if the loop body is safe to clone in practice.
bool isAnnotatedParallel () const
MDNodegetLoopID () const
void setLoopID (MDNode *LoopID) const
bool hasDedicatedExits () const
void getUniqueExitBlocks (SmallVectorImpl< BasicBlock * > &ExitBlocks) const
BasicBlockgetUniqueExitBlock () const
void dump () const
DebugLoc getStartLoc () const
 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.

Friends

class LoopInfoBase< BasicBlock, Loop >

Detailed Description

Definition at line 353 of file LoopInfo.h.


Constructor & Destructor Documentation

llvm::Loop::Loop ( ) [inline]

Definition at line 355 of file LoopInfo.h.


Member Function Documentation

void Loop::dump ( ) const

Definition at line 409 of file LoopInfo.cpp.

References llvm::dbgs(), and llvm::LoopBase< BasicBlock, Loop >::print().

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

Definition at line 141 of file LoopInfo.cpp.

References llvm::BasicBlock::begin(), llvm::LoopBase< BasicBlock, Loop >::contains(), llvm::LoopBase< BasicBlock, Loop >::getHeader(), llvm::PHINode::getIncomingValueForBlock(), H, I, llvm::pred_begin(), llvm::pred_end(), and std::swap().

MDNode * Loop::getLoopID ( ) const

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 or if multiple latches contain different nodes then 0 is returned.

Definition at line 234 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::LoopBase< BasicBlock, Loop >::getHeader(), llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::Instruction::getMetadata(), llvm::MDNode::getNumOperands(), llvm::TerminatorInst::getNumSuccessors(), llvm::MDNode::getOperand(), llvm::TerminatorInst::getSuccessor(), llvm::BasicBlock::getTerminator(), H, I, llvm::ARM_PROC::IE, isLoopSimplifyForm(), and LoopMDName.

Referenced by GetUnrollMetadata(), isAnnotatedParallel(), and SetLoopAlreadyUnrolled().

DebugLoc llvm::Loop::getStartLoc ( ) const [inline]

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.

Definition at line 461 of file LoopInfo.h.

References llvm::Instruction::getDebugLoc(), llvm::BasicBlock::getTerminator(), and llvm::DebugLoc::isUnknown().

Referenced by llvm::UnrollLoop().

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

Definition at line 400 of file LoopInfo.cpp.

References getUniqueExitBlocks(), and llvm::SmallVectorTemplateCommon< T >::size().

Referenced by ConnectProlog(), and llvm::UnrollRuntimeLoopProlog().

void Loop::getUniqueExitBlocks ( SmallVectorImpl< BasicBlock * > &  ExitBlocks) const

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

Definition at line 333 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::contains(), llvm::LoopBase< BasicBlock, Loop >::getExitBlocks(), llvm::pred_begin(), llvm::pred_end(), and llvm::SmallVectorTemplateCommon< T >::size().

Referenced by getUniqueExitBlocks(), and isLoopSimplifyForm().

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

Definition at line 69 of file LoopInfo.cpp.

References llvm::User::getNumOperands(), llvm::User::getOperand(), and isLoopInvariant().

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.

Definition at line 288 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), getLoopID(), llvm::MDNode::getNumOperands(), and llvm::MDNode::getOperand().

isLoopInvariant - Return true if the specified value is loop invariant

Definition at line 61 of file LoopInfo.cpp.

References contains(), and I.

Referenced by getStrideFromPointer(), hasLoopInvariantOperands(), and makeLoopInvariant().

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

Definition at line 205 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::LoopBase< BasicBlock, Loop >::getLoopPreheader(), and hasDedicatedExits().

Referenced by getLoopID(), isSimplifiedLoopNest(), setLoopID(), and llvm::UnrollRuntimeLoopProlog().

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

isSafeToClone - Return true if the loop body is safe to clone in practice. Routines that reform the loop CFG and split edges often fail on indirectbr.

Definition at line 213 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), and I.

Referenced by llvm::UnrollLoop().

bool Loop::makeLoopInvariant ( Value V,
bool Changed,
Instruction InsertPt = nullptr 
) const

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

makeLoopInvariant - If the given value is an instruciton 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.

Definition at line 86 of file LoopInfo.cpp.

References I.

Referenced by FindLIVLoopCondition(), makeLoopInvariant(), and simplifyOneLoop().

bool Loop::makeLoopInvariant ( Instruction I,
bool Changed,
Instruction InsertPt = nullptr 
) const

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

Definition at line 102 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::getLoopPreheader(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::BasicBlock::getTerminator(), isLoopInvariant(), llvm::isSafeToSpeculativelyExecute(), makeLoopInvariant(), llvm::Instruction::mayReadFromMemory(), and llvm::Instruction::moveBefore().

void Loop::setLoopID ( MDNode LoopID) const

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 should be the node itself.

Definition at line 268 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::LoopBase< BasicBlock, Loop >::getHeader(), llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::MDNode::getNumOperands(), llvm::TerminatorInst::getNumSuccessors(), llvm::MDNode::getOperand(), llvm::TerminatorInst::getSuccessor(), llvm::BasicBlock::getTerminator(), H, I, llvm::ARM_PROC::IE, isLoopSimplifyForm(), LoopMDName, and llvm::Instruction::setMetadata().

Referenced by SetLoopAlreadyUnrolled().


Friends And Related Function Documentation

friend class LoopInfoBase< BasicBlock, Loop > [friend]

Definition at line 482 of file LoopInfo.h.


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