27#include "llvm/Config/llvm-config.h"
51#ifdef EXPENSIVE_CHECKS
75 return all_of(
I->operands(), [&](
Value *V) { return isLoopInvariant(V); });
95 if (
I->mayReadFromMemory())
109 for (
Value *Operand :
I->operands())
131 ProfileMetadataToPreserve.
push_back(LLVMContext::MD_prof);
137 I->dropUBImplyingAttrsAndUnknownMetadata(ProfileMetadataToPreserve);
171 assert(Incoming && Backedge &&
"expected non-null incoming and backedges");
178 BasicBlock *Incoming =
nullptr, *Backedge =
nullptr;
190 if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN)
210 ICmpInst *LatchCmpInst = L.getLatchCmpInst();
216 if (Op0 == &IndVar || Op0 == &StepInst)
219 if (Op1 == &IndVar || Op1 == &StepInst)
225std::optional<Loop::LoopBounds>
234 if (!InitialIVValue || !StepInst)
238 Value *StepInstOp1 = StepInst->getOperand(1);
239 Value *StepInstOp0 = StepInst->getOperand(0);
240 Value *StepValue =
nullptr;
241 if (SE.getSCEV(StepInstOp1) == Step)
242 StepValue = StepInstOp1;
243 else if (SE.getSCEV(StepInstOp0) == Step)
244 StepValue = StepInstOp0;
250 return LoopBounds(L, *InitialIVValue, *StepInst, StepValue, *FinalIVValue,
258 assert(Latch &&
"Expecting valid latch");
264 "Expecting the latch compare instruction to be a CmpInst");
286 if (
D == Direction::Increasing)
289 if (
D == Direction::Decreasing)
300 if (
const SCEV *StepRecur = StepAddRecExpr->getStepRecurrence(SE)) {
301 if (SE.isKnownPositive(StepRecur))
302 return Direction::Increasing;
303 if (SE.isKnownNegative(StepRecur))
304 return Direction::Decreasing;
307 return Direction::Unknown;
322 assert(Header &&
"Expected a valid loop header");
330 for (
PHINode &IndVar : Header->phis()) {
336 Value *StepInst = IndVar.getIncomingValueForBlock(Latch);
342 if (StepInst == LatchCmpOp0 || StepInst == LatchCmpOp1)
349 if (&IndVar == LatchCmpOp0 || &IndVar == LatchCmpOp1)
396 "Expecting a loop with valid preheader and latch");
447 if (!Step || !Step->
isOne())
465 UserBB =
P->getIncomingBlock(U);
484 if (IgnoreTokens &&
I.getType()->isTokenLikeTy())
487 for (
const Use &U :
I.uses()) {
503 bool IgnoreTokens)
const {
528 if (CB->cannotDuplicate())
544 if (
I.getType()->isTokenLikeTy()) {
545 for (
const Use &U :
I.uses()) {
551 assert(!CB->cannotDuplicate() &&
"Checked by isSafeToClone().");
552 if (CB->isConvergent())
575 else if (MD != LoopID)
586 "Loop ID needs at least one operand");
588 "Loop ID should refer to itself");
593 BB->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
632 if (!DesiredLoopIdMetadata)
635 MDNode *ParallelAccesses =
638 ParallelAccessGroups;
639 if (ParallelAccesses) {
643 "List item must be an access group");
644 ParallelAccessGroups.
insert(AccGroup);
655 if (!
I.mayReadOrWriteMemory())
658 if (
MDNode *AccessGroup =
I.getMetadata(LLVMContext::MD_access_group)) {
659 auto ContainsAccessGroup = [&ParallelAccessGroups](
MDNode *AG) ->
bool {
660 if (AG->getNumOperands() == 0) {
662 return ParallelAccessGroups.
count(AG);
665 for (
const MDOperand &AccessListItem : AG->operands()) {
668 "List item must be an access group");
669 if (ParallelAccessGroups.
count(AccGroup))
675 if (ContainsAccessGroup(AccessGroup))
684 I.getMetadata(LLVMContext::MD_mem_parallel_loop_access);
720 if (
DebugLoc DL = PHeadBB->getTerminator()->getDebugLoc())
726 return LocRange(HeadBB->getTerminator()->getDebugLoc());
735 LoopDbgLoc.print(OS);
742#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
771 bool FoundIB =
false;
774 UnloopUpdater(
Loop *UL,
LoopInfo *LInfo) : Unloop(*UL), LI(LInfo), DFS(UL) {}
776 void updateBlockParents();
778 void removeBlocksFromAncestors();
780 void updateSubloopParents();
789void UnloopUpdater::updateBlockParents() {
790 if (Unloop.getNumBlocks()) {
793 LoopBlocksTraversal Traversal(DFS, LI);
794 for (BasicBlock *POI : Traversal) {
796 Loop *
L = LI->getLoopFor(POI);
797 Loop *NL = getNearestLoop(POI, L);
802 "uninitialized successor");
803 LI->changeLoopFor(POI, NL);
807 assert((FoundIB || Unloop.contains(L)) &&
"uninitialized successor");
814 for (
unsigned NIters = 0;
Changed; ++NIters) {
815 assert(NIters < Unloop.getNumBlocks() &&
"runaway iterative algorithm");
822 POE = DFS.endPostorder();
825 Loop *
L = LI->getLoopFor(*POI);
826 Loop *NL = getNearestLoop(*POI, L);
829 "uninitialized successor");
830 LI->changeLoopFor(*POI, NL);
838void UnloopUpdater::removeBlocksFromAncestors() {
841 for (BasicBlock *BB : Unloop.blocks()) {
842 Loop *OuterParent = LI->getLoopFor(BB);
843 if (Unloop.contains(OuterParent)) {
846 OuterParent = SubloopParents[OuterParent];
850 for (Loop *OldParent = Unloop.getParentLoop(); OldParent != OuterParent;
851 OldParent = OldParent->getParentLoop()) {
852 assert(OldParent &&
"new loop is not an ancestor of the original");
853 OldParent->removeBlockFromLoop(BB);
859void UnloopUpdater::updateSubloopParents() {
860 while (!Unloop.isInnermost()) {
861 Loop *Subloop = *std::prev(Unloop.end());
862 Unloop.removeChildLoop(std::prev(Unloop.end()));
864 assert(SubloopParents.count(Subloop) &&
"DFS failed to visit subloop");
865 if (Loop *Parent = SubloopParents[Subloop])
866 Parent->addChildLoop(Subloop);
868 LI->addTopLevelLoop(Subloop);
877Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) {
881 Loop *NearLoop = BBLoop;
883 Loop *Subloop =
nullptr;
884 if (NearLoop != &Unloop && Unloop.contains(NearLoop)) {
889 assert(Subloop &&
"subloop is not an ancestor of the original loop");
892 NearLoop = SubloopParents.insert({Subloop, &Unloop}).first->second;
896 assert(!Subloop &&
"subloop blocks must have a successor");
903 Loop *
L = LI->getLoopFor(Succ);
907 assert((FoundIB || !DFS.hasPostorder(Succ)) &&
"should have seen IB");
910 if (L != &Unloop && Unloop.contains(L)) {
916 assert(
L->getParentLoop() == &Unloop &&
"cannot skip into nested loops");
919 L = SubloopParents[
L];
926 if (L && !
L->contains(&Unloop)) {
927 L =
L->getParentLoop();
930 if (NearLoop == &Unloop || !NearLoop || NearLoop->
contains(L))
934 SubloopParents[Subloop] = NearLoop;
943 FunctionAnalysisManager::Invalidator &) {
987 UnloopUpdater Updater(Unloop,
this);
988 Updater.updateBlockParents();
991 Updater.removeBlocksFromAncestors();
994 Updater.updateSubloopParents();
999 assert(
I != ParentLoop->
end() &&
"Couldn't find loop");
1009 if (V->getType()->isTokenLikeTy())
1020 if (L->contains(ExitBB))
1051 OS <<
"Loop info for function '" <<
F.getName() <<
"':\n";
1057 const std::string &Banner) {
1060 OS << Banner <<
" (loop: ";
1061 L.getHeader()->printAsOperand(OS,
false);
1065 OS << *L.getHeader()->getModule();
1072 OS << Banner <<
" (loop: ";
1073 L.getHeader()->printAsOperand(OS,
false);
1077 OS << *L.getHeader()->getParent();
1083 auto *PreHeader = L.getLoopPreheader();
1085 OS <<
"\n; Preheader:";
1086 PreHeader->print(OS);
1090 for (
auto *
Block : L.blocks())
1094 OS <<
"Printing <null> block";
1097 L.getExitBlocks(ExitBlocks);
1098 if (!ExitBlocks.
empty()) {
1099 OS <<
"\n; Exit blocks";
1100 for (
auto *
Block : ExitBlocks)
1104 OS <<
"Printing <null> block";
1143std::optional<const MDOperand *>
1147 return std::nullopt;
1162 return std::nullopt;
1170 return IntMD->getZExtValue();
1185 return std::nullopt;
1189 return std::nullopt;
1203 if (!CB->isConvergent())
1208 if (
auto *Token = CB->getConvergenceControlToken()) {
1210 if (!TheLoop->
contains(TokenDef->getParent()))
1220 return L->getHeader()->getParent()->willReturn();
1238 while (!WorkList.
empty()) {
1257 return L->getHeader()->getParent()->mustProgress() ||
hasMustProgress(L);
1261 return Node->getNumOperands() == 0 &&
Node->isDistinct();
1278 bool IsVectorMetadata =
false;
1288 if (!IsVectorMetadata)
1357 for ([[maybe_unused]]
BasicBlock *BB : Traversal)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
#define LLVM_EXPORT_TEMPLATE
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
static bool isBlockInLCSSAForm(const Loop &L, const BasicBlock &BB, const DominatorTree &DT, bool IgnoreTokens)
static bool loopContainsUser(const Loop &L, const BasicBlock &BB, const Use &U, const DominatorTree &DT)
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.
Loop::LoopBounds::Direction Direction
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.
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file contains the declarations for profiling metadata utility functions.
static DominatorTree getDomTree(Function &F)
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
This file defines the SmallPtrSet class.
Class for arbitrary precision integers.
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
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()
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Represents analyses that only rely on functions' control flow.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
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".
Conditional Branch instruction.
Value * getCondition() const
BasicBlock * getSuccessor(unsigned i) const
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.
Legacy analysis pass which computes a DominatorTree.
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Module * getParent()
Get the module that this global value is contained inside of...
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 LLVM_ABI bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, ArrayRef< const SCEVPredicate * > NoWrapPreds={}, 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
LLVM_ABI ConstantInt * getConstIntStepValue() const
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
iterator_range< user_iterator > users()
This is an important class for using LLVM in a threaded context.
Analysis pass that exposes the LoopInfo for a function.
LLVM_ABI 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
typename std::vector< Loop * >::const_iterator iterator
bool isOutermost() const
Return true if the loop does not have a parent (natural) loop.
BasicBlock * getLoopLatch() const
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
BasicBlock * getHeader() const
void getLoopLatches(SmallVectorImpl< BasicBlock * > &LoopLatches) const
void print(raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
iterator_range< block_iterator > blocks() const
bool isInvalid() const
Return true if this loop is no longer valid.
BasicBlock * getLoopPreheader() const
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
bool hasDedicatedExits() const
BasicBlock * getUniqueExitBlock() const
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.
friend class LoopBlocksTraversal
std::vector< BasicBlock * >::const_iterator POIterator
Postorder list iterators.
LLVM_ABI void perform(const LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
Wrapper class to LoopBlocksDFS that provides a standard begin()/end() interface for the DFS reverse p...
void perform(const LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
This class builds and contains all of the top-level loop structures in the specified function.
void addTopLevelLoop(Loop *New)
Loop * removeLoop(iterator I)
typename std::vector< Loop * >::const_iterator iterator
void analyze(ParentT F)
Create the loop forest for a function.
Loop * getLoopFor(const BasicBlock *BB) const
void changeLoopFor(const BasicBlock *BB, Loop *L)
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 releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnFunction(Function &F) override
Calculate the natural loop information for a given function.
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.
LLVM_ABI bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V, const BasicBlock *ExitBB) const
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
LLVM_ABI 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).
LLVM_ABI 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.
std::string getLocStr() const
Return a string containing the debug location of the loop (file name + line number if present,...
bool hasLoopInvariantOperands(const Instruction *I) const
Return true if all the operands of the specified instruction are loop invariant.
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 isSafeToCloneConditionally(const DominatorTree &DT) const
Like isSafeToClone, but for transformations where the cloned loop bodies may run conditionally.
bool getInductionDescriptor(ScalarEvolution &SE, InductionDescriptor &IndDesc) const
Get the loop induction descriptor for the loop induction variable.
CondBrInst * getLoopGuardBranch() const
Return the loop guard branch, if it exists.
void addIntLoopAttribute(StringRef Name, unsigned Value, ArrayRef< StringRef > RemovePrefixes={}) const
Add an integer metadata attribute to this loop's loop-ID node.
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,...
void addStringLoopAttribute(StringRef Name, ArrayRef< StringRef > RemovePrefixes={}) const
Add a string-only metadata attribute to this loop's loop-ID node.
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.
LLVM_ABI 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.
LLVM_ABI StringRef getString() const
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
LLVM_ABI 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.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
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 * getConstantMaxBackedgeTakenCount(const Loop *L)
When successful, this returns a SCEVConstant that is greater than or equal to (i.e.
LLVM_ABI bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
LLVM_ABI void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
LLVM_ABI bool loopIsFiniteByAssumption(const Loop *L)
Return true if this loop is finite by assumption.
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.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
LLVM Value Representation.
const ParentTy * getParent() const
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LocationClass< Ty > location(Ty &L)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
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.
LLVM_ABI cl::opt< bool > ProfcheckDisableMetadataFixes
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
bool succ_empty(const Instruction *I)
LLVM_ABI bool forcePrintModuleIR()
LLVM_ABI std::optional< bool > getOptionalBoolLoopAttribute(const Loop *TheLoop, StringRef Name)
LLVM_ABI int getIntLoopAttribute(const Loop *TheLoop, StringRef Name, int Default=0)
Find named metadata for a loop with an integer value.
auto pred_end(const MachineBasicBlock *BB)
LLVM_ABI void setExplicitlyUnknownBranchWeightsIfProfiled(Instruction &I, StringRef PassName, const Function *F=nullptr)
Like setExplicitlyUnknownBranchWeights(...), but only sets unknown branch weights in the new instruct...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI std::optional< const MDOperand * > findStringMetadataForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for loop.
auto successors(const MachineBasicBlock *BB)
LLVM_ABI MDNode * findOptionMDForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for a loop.
LLVM_ABI bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true, bool IgnoreUBImplyingAttrs=true)
Return true if the instruction does not have any effects besides calculating the result and does not ...
LLVM_ABI bool hasMustProgress(const Loop *L)
Look for the loop attribute that requires progress within the loop.
auto dyn_cast_or_null(const Y &Val)
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 containsIrreducibleCFG(RPOTraversalT &RPOTraversal, const LoopInfoT &LI)
Return true if the control flow in RPOTraversal is irreducible.
LLVM_ABI bool isMustProgress(const Loop *L)
Return true if this loop can be assumed to make progress.
LLVM_ABI CallBase * getLoopConvergenceHeart(const Loop *TheLoop)
Find the convergence heart of the loop.
LLVM_ABI bool isFinite(const Loop *L)
Return true if this loop can be assumed to run for a finite number of iterations.
DominatorTreeBase< T, false > DomTreeBase
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI bool VerifyLoopInfo
Enable verification of loop info.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI bool isLoopNestFinite(Loop *L, ScalarEvolution &SE, const LoopInfo &LI)
Return true if every cycle in the loop nest rooted at L is finite.
LLVM_ABI std::optional< int > getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name)
Find named metadata for a loop with an integer value.
LLVM_ABI bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
LLVM_ABI void printLoop(const Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
DWARFExpression::Operation Op
PredIterator< BasicBlock, Value::user_iterator > pred_iterator
auto pred_begin(const MachineBasicBlock *BB)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI 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.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI MDNode * findOptionMDForLoopID(MDNode *LoopID, StringRef Name)
Find and return the loop attribute node for the attribute Name in LoopID.
LLVM_ABI bool forcePrintFuncIR()
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...
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static LLVM_ABI 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.
Value & getFinalIVValue() const
Get the final value of the loop induction variable.
Instruction & getStepInst() const
Get the instruction that updates the loop induction variable.
LLVM_ABI ICmpInst::Predicate getCanonicalPredicate() const
Return the canonical predicate for the latch compare instruction, if able to be calcuated.
LLVM_ABI Direction getDirection() const
Get the direction of the loop.