LLVM API Documentation
#include <LoopInfo.h>
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 |
PHINode * | getCanonicalInductionVariable () const |
bool | isLCSSAForm (DominatorTree &DT) const |
isLCSSAForm - Return true if the Loop is in LCSSA form More... | |
bool | isLoopSimplifyForm () const |
bool | isSafeToClone () const |
isSafeToClone - Return true if the loop body is safe to clone in practice. More... | |
bool | isAnnotatedParallel () const |
MDNode * | getLoopID () const |
void | setLoopID (MDNode *LoopID) const |
bool | hasDedicatedExits () const |
void | getUniqueExitBlocks (SmallVectorImpl< BasicBlock * > &ExitBlocks) const |
BasicBlock * | getUniqueExitBlock () const |
void | dump () const |
![]() | |
LoopBase () | |
Loop ctor - This creates an empty loop. More... | |
~LoopBase () | |
unsigned | getLoopDepth () const |
BlockT * | getHeader () const |
LoopT * | getParentLoop () const |
void | setParentLoop (LoopT *L) |
setParentLoop is a raw interface for bypassing addChildLoop. More... | |
bool | contains (const LoopT *L) const |
bool | contains (const BlockT *BB) const |
template<class InstT > | |
bool | contains (const InstT *Inst) const |
const std::vector< LoopT * > & | getSubLoops () const |
std::vector< LoopT * > & | getSubLoopsVector () |
iterator | begin () const |
iterator | end () const |
reverse_iterator | rbegin () const |
reverse_iterator | rend () const |
bool | empty () const |
const std::vector< BlockT * > & | getBlocks () const |
block_iterator | block_begin () const |
block_iterator | block_end () const |
unsigned | getNumBlocks () const |
getNumBlocks - Get the number of blocks in this loop in constant time. More... | |
bool | isLoopExiting (const BlockT *BB) const |
unsigned | getNumBackEdges () const |
void | getExitingBlocks (SmallVectorImpl< BlockT * > &ExitingBlocks) const |
BlockT * | getExitingBlock () const |
void | getExitBlocks (SmallVectorImpl< BlockT * > &ExitBlocks) const |
BlockT * | getExitBlock () const |
void | getExitEdges (SmallVectorImpl< Edge > &ExitEdges) const |
getExitEdges - Return all pairs of (inside_block,outside_block). More... | |
BlockT * | getLoopPreheader () const |
BlockT * | getLoopPredecessor () const |
BlockT * | getLoopLatch () const |
void | addBasicBlockToLoop (BlockT *NewBB, LoopInfoBase< BlockT, LoopT > &LI) |
void | replaceChildLoopWith (LoopT *OldChild, LoopT *NewChild) |
void | addChildLoop (LoopT *NewChild) |
LoopT * | removeChildLoop (iterator I) |
void | addBlockEntry (BlockT *BB) |
void | reverseBlock (unsigned from) |
reverseBlocks - interface to reverse Blocks[from, end of loop] in this loop More... | |
void | reserveBlocks (unsigned size) |
reserveBlocks- interface to do reserve() for Blocks More... | |
void | moveToHeader (BlockT *BB) |
void | removeBlockFromLoop (BlockT *BB) |
void | verifyLoop () const |
verifyLoop - Verify loop structure More... | |
void | verifyLoopNest (DenseSet< const LoopT * > *Loops) const |
verifyLoop - Verify loop structure of this loop and all nested loops. More... | |
void | print (raw_ostream &OS, unsigned Depth=0) const |
Friends | |
class | LoopInfoBase< BasicBlock, Loop > |
Additional Inherited Members | |
![]() | |
typedef std::vector< LoopT * > ::const_iterator | iterator |
typedef std::vector< LoopT * > ::const_reverse_iterator | reverse_iterator |
typedef std::vector< BlockT * > ::const_iterator | block_iterator |
typedef std::pair< const BlockT *, const BlockT * > | Edge |
Edge type. More... | |
![]() | |
LoopBase (BlockT *BB) | |
Definition at line 338 of file LoopInfo.h.
|
inline |
Definition at line 340 of file LoopInfo.h.
void Loop::dump | ( | ) | const |
Definition at line 411 of file LoopInfo.cpp.
References llvm::dbgs(), and llvm::LoopBase< N, M >::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 142 of file LoopInfo.cpp.
References llvm::BasicBlock::begin(), llvm::LoopBase< N, M >::contains(), llvm::LoopBase< N, M >::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 236 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::LoopBase< N, M >::getHeader(), llvm::LoopBase< N, M >::getLoopLatch(), llvm::Instruction::getMetadata(), llvm::MDNode::getNumOperands(), llvm::TerminatorInst::getNumSuccessors(), llvm::MDNode::getOperand(), llvm::TerminatorInst::getSuccessor(), H, I, llvm::ARM_PROC::IE, isLoopSimplifyForm(), and LoopMDName.
Referenced by isAnnotatedParallel().
BasicBlock * Loop::getUniqueExitBlock | ( | ) | const |
getUniqueExitBlock - If getUniqueExitBlocks would return exactly one block, return that block. Otherwise return null.
Definition at line 402 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 354 of file LoopInfo.cpp.
References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::SmallVectorImpl< T >::clear(), llvm::LoopBase< N, M >::contains(), llvm::SmallVectorTemplateCommon< T >::end(), hasDedicatedExits(), I, llvm::pred_begin(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::succ_begin(), and llvm::succ_end().
Referenced by getUniqueExitBlock().
bool Loop::hasDedicatedExits | ( | ) | const |
hasDedicatedExits - Return true if no exit block for the loop has a predecessor that is outside the loop.
Definition at line 335 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::contains(), llvm::LoopBase< N, M >::getExitBlocks(), llvm::pred_begin(), llvm::pred_end(), and llvm::SmallVectorTemplateCommon< T >::size().
Referenced by getUniqueExitBlocks(), and isLoopSimplifyForm().
bool Loop::hasLoopInvariantOperands | ( | Instruction * | I | ) | const |
hasLoopInvariantOperands - Return true if all the operands of the specified instruction are loop invariant.
Definition at line 70 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 290 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), getLoopID(), llvm::MDNode::getNumOperands(), and llvm::MDNode::getOperand().
bool Loop::isLCSSAForm | ( | DominatorTree & | DT | ) | const |
isLCSSAForm - Return true if the Loop is in LCSSA form
Definition at line 179 of file LoopInfo.cpp.
References llvm::BasicBlock::begin(), llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::LoopBase< N, M >::contains(), llvm::BasicBlock::end(), getParent(), I, llvm::DominatorTree::isReachableFromEntry(), and P.
isLoopInvariant - Return true if the specified value is loop invariant
Definition at line 62 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 207 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::getLoopLatch(), llvm::LoopBase< N, M >::getLoopPreheader(), and hasDedicatedExits().
Referenced by getLoopID(), isSimplifiedLoopNest(), setLoopID(), 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 215 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::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 87 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 103 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::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 270 of file LoopInfo.cpp.
References llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::LoopBase< N, M >::getHeader(), llvm::LoopBase< N, M >::getLoopLatch(), llvm::MDNode::getNumOperands(), llvm::TerminatorInst::getNumSuccessors(), llvm::MDNode::getOperand(), llvm::TerminatorInst::getSuccessor(), H, I, llvm::ARM_PROC::IE, isLoopSimplifyForm(), LoopMDName, and llvm::Instruction::setMetadata().
|
friend |
Definition at line 442 of file LoopInfo.h.