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=0) const
bool makeLoopInvariant (Instruction *I, bool &Changed, Instruction *InsertPt=0) 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
bool hasDedicatedExits () const
void getUniqueExitBlocks (SmallVectorImpl< BasicBlock * > &ExitBlocks) const
BasicBlockgetUniqueExitBlock () const
void dump () const

Friends

class LoopInfoBase< BasicBlock, Loop >

Detailed Description

Definition at line 323 of file LoopInfo.h.


Constructor & Destructor Documentation

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

Definition at line 325 of file LoopInfo.h.


Member Function Documentation

void Loop::dump ( ) const

Definition at line 372 of file LoopInfo.cpp.

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

PHINode * Loop::getCanonicalInductionVariable ( ) const

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 139 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 llvm::swap().

BasicBlock * Loop::getUniqueExitBlock ( ) const

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

Definition at line 363 of file LoopInfo.cpp.

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

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

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

getUniqueExitBlocks - Return all unique successor blocks of this loop. These are the blocks _outside of the current loop_ which are branched to. This assumes that loop exits are in canonical form.

Definition at line 310 of file LoopInfo.cpp.

References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::SmallVectorTemplateCommon< T >::end(), hasDedicatedExits(), I, llvm::pred_begin(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::succ_begin(), and llvm::succ_end().

Referenced by getUniqueExitBlock().

bool Loop::hasDedicatedExits ( ) const
bool Loop::hasLoopInvariantOperands ( Instruction I) const

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

Definition at line 67 of file LoopInfo.cpp.

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

bool Loop::isAnnotatedParallel ( ) const

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 237 of file LoopInfo.cpp.

References llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::dyn_cast(), llvm::LoopBase< BasicBlock, Loop >::getLoopLatch(), llvm::Instruction::getMetadata(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and llvm::BasicBlock::getTerminator().

bool Loop::isLCSSAForm ( DominatorTree DT) const
bool Loop::isLoopInvariant ( Value V) const

isLoopInvariant - Return true if the specified value is loop invariant

Definition at line 59 of file LoopInfo.cpp.

References I.

Referenced by hasLoopInvariantOperands(), and makeLoopInvariant().

bool Loop::isLoopSimplifyForm ( ) const

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 208 of file LoopInfo.cpp.

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

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

bool Loop::isSafeToClone ( ) const

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 216 of file LoopInfo.cpp.

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

Referenced by llvm::UnrollLoop().

bool Loop::makeLoopInvariant ( Value V,
bool Changed,
Instruction InsertPt = 0 
) 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 84 of file LoopInfo.cpp.

References I.

Referenced by FindLIVLoopCondition(), and makeLoopInvariant().

bool Loop::makeLoopInvariant ( Instruction I,
bool Changed,
Instruction InsertPt = 0 
) 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 100 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().


Friends And Related Function Documentation

friend class LoopInfoBase< BasicBlock, Loop > [friend]

Definition at line 411 of file LoopInfo.h.


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