26#include "llvm/Config/llvm-config.h"
47#ifdef EXPENSIVE_CHECKS
67 return all_of(
I->operands(), [
this](
Value *V) { return isLoopInvariant(V); });
86 if (
I->mayReadFromMemory())
100 for (
Value *Operand :
I->operands())
105 I->moveBefore(InsertPt);
115 I->dropUnknownNonDebugMetadata();
146 assert(Incoming && Backedge &&
"expected non-null incoming and backedges");
153 BasicBlock *Incoming =
nullptr, *Backedge =
nullptr;
165 if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN)
166 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
176 if (
BranchInst *BI = dyn_cast_or_null<BranchInst>(Latch->getTerminator()))
177 if (BI->isConditional())
178 return dyn_cast<ICmpInst>(BI->getCondition());
186 ICmpInst *LatchCmpInst = L.getLatchCmpInst();
192 if (Op0 == &IndVar || Op0 == &StepInst)
195 if (Op1 == &IndVar || Op1 == &StepInst)
201std::optional<Loop::LoopBounds>
210 if (!InitialIVValue || !StepInst)
216 Value *StepValue =
nullptr;
217 if (SE.
getSCEV(StepInstOp1) == Step)
218 StepValue = StepInstOp1;
219 else if (SE.
getSCEV(StepInstOp0) == Step)
220 StepValue = StepInstOp0;
226 return LoopBounds(L, *InitialIVValue, *StepInst, StepValue, *FinalIVValue,
234 assert(Latch &&
"Expecting valid latch");
241 "Expecting the latch compare instruction to be a CmpInst");
249 if (LatchCmpInst->
getOperand(0) == &getFinalIVValue())
254 if (LatchCmpInst->
getOperand(0) == &getStepInst() ||
255 LatchCmpInst->
getOperand(1) == &getStepInst())
263 if (
D == Direction::Increasing)
266 if (
D == Direction::Decreasing)
276 dyn_cast<SCEVAddRecExpr>(SE.getSCEV(&getStepInst())))
277 if (
const SCEV *StepRecur = StepAddRecExpr->getStepRecurrence(SE)) {
278 if (SE.isKnownPositive(StepRecur))
279 return Direction::Increasing;
280 if (SE.isKnownNegative(StepRecur))
281 return Direction::Decreasing;
284 return Direction::Unknown;
299 assert(Header &&
"Expected a valid loop header");
307 for (
PHINode &IndVar : Header->phis()) {
313 Value *StepInst = IndVar.getIncomingValueForBlock(Latch);
319 if (StepInst == LatchCmpOp0 || StepInst == LatchCmpOp1)
326 if (&IndVar == LatchCmpOp0 || &IndVar == LatchCmpOp1)
373 "Expecting a loop with valid preheader and latch");
424 if (!Step || !Step->
isOne())
437 if (IgnoreTokens &&
I.getType()->isTokenTy())
440 for (
const Use &U :
I.uses()) {
441 const Instruction *UI = cast<Instruction>(U.getUser());
447 if (
const PHINode *
P = dyn_cast<PHINode>(UI))
448 UserBB =
P->getIncomingBlock(U);
454 if (UserBB != &BB && !L.contains(UserBB) &&
470 bool IgnoreTokens)
const {
490 if (isa<IndirectBrInst>(BB->getTerminator()))
494 if (
auto *CB = dyn_cast<CallBase>(&
I))
495 if (CB->cannotDuplicate())
516 else if (MD != LoopID)
527 "Loop ID needs at least one operand");
529 "Loop ID should refer to itself");
534 BB->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
544 Context, LoopID, {
"llvm.loop.unroll."}, {DisableUnrollMD});
567 if (!DesiredLoopIdMetadata)
570 MDNode *ParallelAccesses =
573 ParallelAccessGroups;
574 if (ParallelAccesses) {
576 MDNode *AccGroup = cast<MDNode>(MD.get());
578 "List item must be an access group");
579 ParallelAccessGroups.
insert(AccGroup);
590 if (!
I.mayReadOrWriteMemory())
593 if (
MDNode *AccessGroup =
I.getMetadata(LLVMContext::MD_access_group)) {
594 auto ContainsAccessGroup = [&ParallelAccessGroups](
MDNode *AG) ->
bool {
595 if (AG->getNumOperands() == 0) {
597 return ParallelAccessGroups.
count(AG);
600 for (
const MDOperand &AccessListItem : AG->operands()) {
601 MDNode *AccGroup = cast<MDNode>(AccessListItem.get());
603 "List item must be an access group");
604 if (ParallelAccessGroups.
count(AccGroup))
610 if (ContainsAccessGroup(AccessGroup))
619 I.getMetadata(LLVMContext::MD_mem_parallel_loop_access);
640 for (
unsigned i = 1, ie = LoopID->getNumOperands(); i < ie; ++i) {
641 if (
DILocation *L = dyn_cast<DILocation>(LoopID->getOperand(i))) {
655 if (
DebugLoc DL = PHeadBB->getTerminator()->getDebugLoc())
661 return LocRange(HeadBB->getTerminator()->getDebugLoc());
666#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
695 bool FoundIB =
false;
698 UnloopUpdater(
Loop *UL,
LoopInfo *LInfo) : Unloop(*UL), LI(LInfo), DFS(UL) {}
700 void updateBlockParents();
702 void removeBlocksFromAncestors();
704 void updateSubloopParents();
713void UnloopUpdater::updateBlockParents() {
714 if (Unloop.getNumBlocks()) {
720 Loop *
L = LI->getLoopFor(POI);
721 Loop *
NL = getNearestLoop(POI, L);
725 assert((
NL != &Unloop && (!
NL ||
NL->contains(&Unloop))) &&
726 "uninitialized successor");
727 LI->changeLoopFor(POI,
NL);
731 assert((FoundIB || Unloop.contains(L)) &&
"uninitialized successor");
737 bool Changed = FoundIB;
738 for (
unsigned NIters = 0; Changed; ++NIters) {
739 assert(NIters < Unloop.getNumBlocks() &&
"runaway iterative algorithm");
746 POE = DFS.endPostorder();
749 Loop *
L = LI->getLoopFor(*POI);
750 Loop *
NL = getNearestLoop(*POI, L);
752 assert(
NL != &Unloop && (!
NL ||
NL->contains(&Unloop)) &&
753 "uninitialized successor");
754 LI->changeLoopFor(*POI,
NL);
762void UnloopUpdater::removeBlocksFromAncestors() {
766 Loop *OuterParent = LI->getLoopFor(BB);
767 if (Unloop.contains(OuterParent)) {
770 OuterParent = SubloopParents[OuterParent];
776 assert(OldParent &&
"new loop is not an ancestor of the original");
777 OldParent->removeBlockFromLoop(BB);
783void UnloopUpdater::updateSubloopParents() {
784 while (!Unloop.isInnermost()) {
785 Loop *Subloop = *std::prev(Unloop.end());
786 Unloop.removeChildLoop(std::prev(Unloop.end()));
788 assert(SubloopParents.count(Subloop) &&
"DFS failed to visit subloop");
789 if (
Loop *Parent = SubloopParents[Subloop])
790 Parent->addChildLoop(Subloop);
792 LI->addTopLevelLoop(Subloop);
805 Loop *NearLoop = BBLoop;
807 Loop *Subloop =
nullptr;
808 if (NearLoop != &Unloop && Unloop.contains(NearLoop)) {
813 assert(Subloop &&
"subloop is not an ancestor of the original loop");
816 NearLoop = SubloopParents.insert({Subloop, &Unloop}).first->second;
821 assert(!Subloop &&
"subloop blocks must have a successor");
824 for (;
I !=
E; ++
I) {
828 Loop *
L = LI->getLoopFor(*
I);
832 assert((FoundIB || !DFS.hasPostorder(*
I)) &&
"should have seen IB");
835 if (L != &Unloop && Unloop.contains(L)) {
841 assert(
L->getParentLoop() == &Unloop &&
"cannot skip into nested loops");
844 L = SubloopParents[
L];
851 if (L && !
L->contains(&Unloop)) {
852 L =
L->getParentLoop();
855 if (NearLoop == &Unloop || !NearLoop || NearLoop->
contains(L))
859 SubloopParents[Subloop] = NearLoop;
886 if (getLoopFor(BB) != Unloop)
891 changeLoopFor(BB,
nullptr);
912 UnloopUpdater Updater(Unloop,
this);
913 Updater.updateBlockParents();
916 Updater.removeBlocksFromAncestors();
919 Updater.updateSubloopParents();
924 assert(
I != ParentLoop->
end() &&
"Couldn't find loop");
934 if (V->getType()->isTokenTy())
942 const Loop *L = getLoopFor(
I->getParent());
945 if (L->contains(ExitBB))
980 OS << Banner <<
" (loop: ";
981 L.getHeader()->printAsOperand(
OS,
false);
985 OS << *L.getHeader()->getModule();
991 auto *PreHeader = L.getLoopPreheader();
993 OS <<
"\n; Preheader:";
994 PreHeader->print(
OS);
998 for (
auto *
Block : L.blocks())
1002 OS <<
"Printing <null> block";
1005 L.getExitBlocks(ExitBlocks);
1006 if (!ExitBlocks.
empty()) {
1007 OS <<
"\n; Exit blocks";
1008 for (
auto *
Block : ExitBlocks)
1012 OS <<
"Printing <null> block";
1051std::optional<const MDOperand *>
1055 return std::nullopt;
1070 return std::nullopt;
1077 mdconst::extract_or_null<ConstantInt>(MD->
getOperand(1).
get()))
1078 return IntMD->getZExtValue();
1093 return std::nullopt;
1095 ConstantInt *IntMD = mdconst::extract_or_null<ConstantInt>(AttrMD->get());
1097 return std::nullopt;
1108 return L->getHeader()->getParent()->willReturn();
1118 return L->getHeader()->getParent()->mustProgress() ||
hasMustProgress(L);
1122 return Node->getNumOperands() == 0 && Node->isDistinct();
1138 for (
unsigned i = 1, ie = OrigLoopID->
getNumOperands(); i < ie; ++i) {
1139 bool IsVectorMetadata =
false;
1141 if (
MDNode *MD = dyn_cast<MDNode>(Op)) {
1142 const MDString *S = dyn_cast<MDString>(MD->getOperand(0));
1149 if (!IsVectorMetadata)
1181 LI.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
1192 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1224 POE = Traversal.
end();
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
static bool isBlockInLCSSAForm(const Loop &L, const BasicBlock &BB, const DominatorTree &DT, bool IgnoreTokens)
static const char * LLVMLoopMustProgress
static Value * findFinalIVValue(const Loop &L, const PHINode &IndVar, const Instruction &StepInst)
Return the final value of the loop induction variable if found.
static cl::opt< bool, true > VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo), cl::Hidden, cl::desc("Verify loop info (time consuming)"))
This file defines the interface for the loop nest analysis.
static bool startswith(StringRef Magic, const char(&S)[N])
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This header defines various interfaces for pass management in LLVM.
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the make_scope_exit function, which executes user-defined cleanup logic at scope ex...
This file defines the SmallPtrSet class.
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
AnalysisUsage & addRequiredTransitive()
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
InstListType::iterator iterator
Instruction iterators...
LLVMContext & getContext() const
Get the context in which this basic block lives.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Conditional or Unconditional Branch instruction.
bool isConditional() const
BasicBlock * getSuccessor(unsigned i) const
bool isUnconditional() const
Value * getCondition() const
Represents analyses that only rely on functions' control flow.
This class is the base class for the comparison instructions.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLT
signed less than
@ ICMP_SGT
signed greater than
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Predicate getPredicate() const
Return the predicate for this instruction.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
This is the shared class of boolean and integer constants.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
Analysis pass which computes a DominatorTree.
Core dominator tree base class.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
FunctionPass class - This class is used to implement most global optimizations.
This instruction compares its operands according to the predicate given to the constructor.
A struct for saving information about induction variables.
BinaryOperator * getInductionBinOp() const
const SCEV * getStep() const
static bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr, SmallVectorImpl< Instruction * > *CastsToIgnore=nullptr)
Returns true if Phi is an induction in the loop L.
Instruction::BinaryOps getInductionOpcode() const
Returns binary opcode of the induction operator.
Value * getStartValue() const
ConstantInt * getConstIntStepValue() const
const BasicBlock * getParent() const
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
This is an important class for using LLVM in a threaded context.
Analysis pass that exposes the LoopInfo for a function.
LoopInfo run(Function &F, FunctionAnalysisManager &AM)
Instances of this class are used to represent loops that are detected in the flow graph.
bool contains(const Loop *L) const
Return true if the specified loop is contained within in this loop.
bool isOutermost() const
Return true if the loop does not have a parent (natural) loop.
BasicBlock * getLoopLatch() const
If there is a single latch block for this loop, return it.
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
BasicBlock * getHeader() const
void getLoopLatches(SmallVectorImpl< BasicBlock * > &LoopLatches) const
Return all loop latch blocks of this loop.
void print(raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
Print loop with all the BBs inside it.
std::vector< Loop * >::const_iterator iterator
iterator_range< block_iterator > blocks() const
bool isInvalid() const
Return true if this loop is no longer valid.
BasicBlock * getLoopPreheader() const
If there is a preheader for this loop, return it.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
BasicBlock * getUniqueExitBlock() const
If getUniqueExitBlocks would return exactly one block, return that block.
LoopT * removeChildLoop(iterator I)
This removes the specified child from being a subloop of this loop.
Store the result of a depth first search within basic blocks contained by a single loop.
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
std::vector< BasicBlock * >::const_iterator POIterator
Postorder list iterators.
Traverse the blocks in a loop using a depth-first search.
POTIterator begin()
Postorder traversal over the graph.
This class builds and contains all of the top-level loop structures in the specified function.
void verify(const DominatorTreeBase< BlockT, false > &DomTree) const
void analyze(const DominatorTreeBase< BlockT, false > &DomTree)
Create the loop forest using a stable algorithm.
void print(raw_ostream &OS) const
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
std::vector< Loop * >::const_iterator iterator
iterator/begin/end - The interface to the top-level loops in the current function.
The legacy pass manager's analysis pass to compute loop information.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
void print(raw_ostream &O, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V, const BasicBlock *ExitBB) const
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
void erase(Loop *L)
Update LoopInfo after removing the last backedge from a loop.
static const BasicBlock & skipEmptyBlockUntil(const BasicBlock *From, const BasicBlock *End, bool CheckUniquePred=false)
Recursivelly traverse all empty 'single successor' basic blocks of From (if there are any).
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
A range representing the start and end location of a loop.
const DebugLoc & getStart() const
Represents a single loop in the control flow graph.
bool isCanonical(ScalarEvolution &SE) const
Return true if the loop induction variable starts at zero and increments by one each time through the...
bool isLCSSAForm(const DominatorTree &DT, bool IgnoreTokens=true) const
Return true if the Loop is in LCSSA form.
std::optional< LoopBounds > getBounds(ScalarEvolution &SE) const
Return the struct LoopBounds collected if all struct members are found, else std::nullopt.
bool isSafeToClone() const
Return true if the loop body is safe to clone in practice.
bool hasLoopInvariantOperands(const Instruction *I) const
Return true if all the operands of the specified instruction are loop invariant.
BranchInst * getLoopGuardBranch() const
Return the loop guard branch, if it exists.
bool isAnnotatedParallel() const
Returns true if the loop is annotated parallel.
DebugLoc getStartLoc() const
Return the debug location of the start of this loop.
LocRange getLocRange() const
Return the source code span of the loop.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
ICmpInst * getLatchCmpInst() const
Get the latch condition instruction.
bool getInductionDescriptor(ScalarEvolution &SE, InductionDescriptor &IndDesc) const
Get the loop induction descriptor for the loop induction variable.
bool isRotatedForm() const
Return true if the loop is in rotated form.
void setLoopMustProgress()
Add llvm.loop.mustprogress to this loop's loop id metadata.
PHINode * getInductionVariable(ScalarEvolution &SE) const
Return the loop induction variable if found, else return nullptr.
bool isLoopSimplifyForm() const
Return true if the Loop is in the form that the LoopSimplify form transforms loops to,...
bool isRecursivelyLCSSAForm(const DominatorTree &DT, const LoopInfo &LI, bool IgnoreTokens=true) const
Return true if this Loop and all inner subloops are in LCSSA form.
void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
void setLoopAlreadyUnrolled()
Add llvm.loop.unroll.disable to this loop's loop id metadata.
bool makeLoopInvariant(Value *V, bool &Changed, Instruction *InsertPt=nullptr, MemorySSAUpdater *MSSAU=nullptr, ScalarEvolution *SE=nullptr) const
If the given value is an instruction inside of the loop and it can be hoisted, do so to make it trivi...
PHINode * getCanonicalInductionVariable() const
Check to see if the loop has a canonical induction variable: an integer recurrence that starts at 0 a...
bool getIncomingAndBackEdge(BasicBlock *&Incoming, BasicBlock *&Backedge) const
Obtain the unique incoming and back edge.
MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
bool isAuxiliaryInductionVariable(PHINode &AuxIndVar, ScalarEvolution &SE) const
Return true if the given PHINode AuxIndVar is.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
const MDOperand & getOperand(unsigned I) const
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
Tracking metadata reference owned by Metadata.
StringRef getString() const
static MDString * get(LLVMContext &Context, StringRef Str)
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
void moveToPlace(MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where)
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
A Module instance is used to store all the information related to an LLVM module.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
This node represents a polynomial recurrence on the trip count of the specified loop.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
LLVM Value Representation.
iterator_range< user_iterator > users()
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LocationClass< Ty > location(Ty &L)
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Interval::succ_iterator succ_end(Interval *I)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
bool forcePrintModuleIR()
void initializeLoopInfoWrapperPassPass(PassRegistry &)
detail::scope_exit< std::decay_t< Callable > > make_scope_exit(Callable &&F)
std::optional< bool > getOptionalBoolLoopAttribute(const Loop *TheLoop, StringRef Name)
int getIntLoopAttribute(const Loop *TheLoop, StringRef Name, int Default=0)
Find named metadata for a loop with an integer value.
std::optional< const MDOperand * > findStringMetadataForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for loop.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
MDNode * findOptionMDForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for a loop.
bool hasMustProgress(const Loop *L)
Look for the loop attribute that requires progress within the loop.
Interval::pred_iterator pred_end(Interval *I)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
bool isMustProgress(const Loop *L)
Return true if this loop can be assumed to make progress.
bool isFinite(const Loop *L)
Return true if this loop can be assumed to run for a finite number of iterations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
bool VerifyLoopInfo
Enable verification of loop info.
std::optional< int > getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name)
Find named metadata for a loop with an integer value.
bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
llvm::MDNode * makePostTransformationMetadata(llvm::LLVMContext &Context, MDNode *OrigLoopID, llvm::ArrayRef< llvm::StringRef > RemovePrefixes, llvm::ArrayRef< llvm::MDNode * > AddAttrs)
Create a new LoopID after the loop has been transformed.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
@ Default
The result values are uniform if and only if all operands are uniform.
void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
MDNode * findOptionMDForLoopID(MDNode *LoopID, StringRef Name)
Find and return the loop attribute node for the attribute Name in LoopID.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A special type used by analysis passes to provide an address that identifies that particular analysis...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Below are some utilities to get the loop guard, loop bounds and induction variable,...
static std::optional< Loop::LoopBounds > getBounds(const Loop &L, PHINode &IndVar, ScalarEvolution &SE)
Return the LoopBounds object if.
Direction
An enum for the direction of the loop.
ICmpInst::Predicate getCanonicalPredicate() const
Return the canonical predicate for the latch compare instruction, if able to be calcuated.
Direction getDirection() const
Get the direction of the loop.