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=nullptr) const |
bool | makeLoopInvariant (Instruction *I, bool &Changed, Instruction *InsertPt=nullptr) const |
PHINode * | getCanonicalInductionVariable () 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 |
MDNode * | getLoopID () const |
void | setLoopID (MDNode *LoopID) const |
bool | hasDedicatedExits () const |
void | getUniqueExitBlocks (SmallVectorImpl< BasicBlock * > &ExitBlocks) const |
BasicBlock * | getUniqueExitBlock () 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 > |
Definition at line 353 of file LoopInfo.h.
llvm::Loop::Loop | ( | ) | [inline] |
Definition at line 355 of file LoopInfo.h.
void Loop::dump | ( | ) | const |
Definition at line 409 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 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().
BasicBlock * Loop::getUniqueExitBlock | ( | ) | const |
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 |
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 352 of file LoopInfo.cpp.
References llvm::SmallVectorTemplateCommon< T >::begin(), llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::SmallVectorImpl< T >::clear(), llvm::LoopBase< BasicBlock, Loop >::contains(), llvm::SmallVectorTemplateCommon< T >::end(), hasDedicatedExits(), I, llvm::pred_begin(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::SmallVectorTemplateBase< T, isPodLike >::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 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().
bool Loop::hasLoopInvariantOperands | ( | Instruction * | I | ) | const |
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().
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 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().
bool Loop::isLCSSAForm | ( | DominatorTree & | DT | ) | const |
isLCSSAForm - Return true if the Loop is in LCSSA form
Definition at line 178 of file LoopInfo.cpp.
References llvm::BasicBlock::begin(), llvm::LoopBase< BasicBlock, Loop >::block_begin(), llvm::LoopBase< BasicBlock, Loop >::block_end(), llvm::LoopBase< BasicBlock, Loop >::contains(), llvm::BasicBlock::end(), llvm::Instruction::getParent(), I, llvm::DominatorTree::isReachableFromEntry(), and P.
Referenced by llvm::formLCSSA().
bool Loop::isLoopInvariant | ( | Value * | V | ) | const |
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().
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 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().
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 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().
friend class LoopInfoBase< BasicBlock, Loop > [friend] |
Definition at line 482 of file LoopInfo.h.