72#define LDIST_NAME "loop-distribute"
73#define DEBUG_TYPE LDIST_NAME
78 "llvm.loop.distribute.followup_all";
80 "llvm.loop.distribute.followup_coincident";
82 "llvm.loop.distribute.followup_sequential";
84 "llvm.loop.distribute.followup_fallback";
89 cl::desc(
"Turn on DominatorTree and LoopInfo verification "
90 "after Loop Distribution"),
94 "loop-distribute-non-if-convertible",
cl::Hidden,
95 cl::desc(
"Whether to distribute into a loop that may not be "
96 "if-convertible by the loop vectorizer"),
101 cl::desc(
"The maximum number of SCEV checks allowed for Loop "
105 "loop-distribute-scev-check-threshold-with-pragma",
cl::init(128),
107 cl::desc(
"The maximum number of SCEV checks allowed for Loop "
108 "Distribution for loop marked with #pragma clang loop "
109 "distribute(enable)"));
113 cl::desc(
"Enable the new, experimental LoopDistribution Pass"),
118STATISTIC(NumLoopsDistributed,
"Number of loops distributed");
129 : DepCycle(DepCycle), OrigLoop(L) {
134 bool hasDepCycle()
const {
return DepCycle; }
137 void add(Instruction *
I) { Set.insert(
I); }
144 bool empty()
const {
return Set.empty(); }
148 void moveTo(InstPartition &
Other) {
149 Other.Set.insert_range(Set);
151 Other.DepCycle |= DepCycle;
156 void populateUsedSet() {
160 for (
auto *
B : OrigLoop->getBlocks())
161 Set.insert(
B->getTerminator());
165 SmallVector<Instruction *, 8> Worklist(Set.begin(), Set.end());
166 while (!Worklist.empty()) {
169 for (
Value *V :
I->operand_values()) {
171 if (
I && OrigLoop->contains(
I->getParent()) && Set.insert(
I))
172 Worklist.push_back(
I);
182 unsigned Index, LoopInfo *LI,
185 VMap, Twine(
".ldist") + Twine(Index),
186 LI, DT, ClonedLoopBlocks);
192 const Loop *getClonedLoop()
const {
return ClonedLoop; }
197 Loop *getDistributedLoop()
const {
198 return ClonedLoop ? ClonedLoop : OrigLoop;
206 void remapInstructions() {
212 void removeUnusedInsts() {
213 SmallVector<Instruction *, 8>
Unused;
215 for (
auto *
Block : OrigLoop->getBlocks())
216 for (
auto &Inst : *
Block)
217 if (!Set.count(&Inst)) {
223 "Branches are marked used early on");
224 Unused.push_back(NewInst);
229 for (
auto *Inst :
reverse(Unused)) {
231 if (!Inst->use_empty())
233 Inst->eraseFromParent();
237 void print(raw_ostream &OS)
const {
238 OS << (DepCycle ?
" (cycle)\n" :
"\n");
241 OS <<
" " <<
I->getParent()->getName() <<
":" << *
I <<
"\n";
244 void printBlocks(raw_ostream &OS)
const {
245 for (
auto *BB : getDistributedLoop()->getBlocks())
261 Loop *ClonedLoop =
nullptr;
265 SmallVector<BasicBlock *, 8> ClonedLoopBlocks;
275class InstPartitionContainer {
276 using InstToPartitionIdT = DenseMap<Instruction *, int>;
279 InstPartitionContainer(Loop *L, LoopInfo *LI, DominatorTree *DT)
280 : L(L), LI(LI), DT(DT) {}
283 unsigned getSize()
const {
return PartitionContainer.size(); }
287 void addToCyclicPartition(Instruction *Inst) {
289 if (PartitionContainer.empty() || !PartitionContainer.back().hasDepCycle())
290 PartitionContainer.emplace_back(Inst, L,
true);
292 PartitionContainer.back().add(Inst);
300 void addToNewNonCyclicPartition(Instruction *Inst) {
301 PartitionContainer.emplace_back(Inst, L);
309 void mergeAdjacentNonCyclic() {
310 mergeAdjacentPartitionsIf(
311 [](
const InstPartition *
P) {
return !
P->hasDepCycle(); });
316 void mergeNonIfConvertible() {
317 mergeAdjacentPartitionsIf([&](
const InstPartition *Partition) {
318 if (Partition->hasDepCycle())
322 bool seenStore =
false;
324 for (
auto *Inst : *Partition)
335 void mergeBeforePopulating() {
336 mergeAdjacentNonCyclic();
338 mergeNonIfConvertible();
348 bool mergeToAvoidDuplicatedLoads() {
349 using LoadToPartitionT = DenseMap<Instruction *, InstPartition *>;
350 using ToBeMergedT = EquivalenceClasses<InstPartition *>;
352 LoadToPartitionT LoadToPartition;
353 ToBeMergedT ToBeMerged;
358 for (PartitionContainerT::iterator
I = PartitionContainer.begin(),
359 E = PartitionContainer.end();
365 for (Instruction *Inst : *PartI)
368 LoadToPartitionT::iterator LoadToPart;
370 std::tie(LoadToPart, NewElt) =
371 LoadToPartition.insert(std::make_pair(Inst, PartI));
375 <<
"LDist: Merging partitions due to this load in multiple "
376 <<
"partitions: " << PartI <<
", " << LoadToPart->second <<
"\n"
382 ToBeMerged.unionSets(PartI, &*PartJ);
383 }
while (&*PartJ != LoadToPart->second);
387 if (ToBeMerged.empty())
392 for (
const auto &
C : ToBeMerged) {
396 auto PartI =
C->getData();
397 for (
auto *PartJ :
make_range(std::next(ToBeMerged.member_begin(*
C)),
398 ToBeMerged.member_end())) {
399 PartJ->moveTo(*PartI);
404 PartitionContainer.remove_if(
405 [](
const InstPartition &
P) {
return P.empty(); });
412 void setupPartitionIdOnInstructions() {
414 for (
const auto &Partition : PartitionContainer) {
415 for (Instruction *Inst : Partition) {
419 std::tie(Iter, NewElt) =
420 InstToPartitionId.insert(std::make_pair(Inst, PartitionID));
430 void populateUsedSet() {
431 for (
auto &
P : PartitionContainer)
442 assert(Pred &&
"Preheader does not have a single predecessor");
444 assert(ExitBlock &&
"No single exit block");
447 assert(!PartitionContainer.empty() &&
"at least two partitions expected");
451 "preheader not empty");
454 MDNode *OrigLoopID = L->getLoopID();
462 NewLoop = Part.cloneLoopWithPreheader(TopPH, Pred, Index, LI, DT);
464 Part.getVMap()[ExitBlock] = TopPH;
465 Part.remapInstructions();
466 setNewLoopID(OrigLoopID, &Part);
473 setNewLoopID(OrigLoopID, &PartitionContainer.back());
478 for (
auto Curr = PartitionContainer.cbegin(),
479 Next = std::next(PartitionContainer.cbegin()),
480 E = PartitionContainer.cend();
482 DT->changeImmediateDominator(
483 Next->getDistributedLoop()->getLoopPreheader(),
484 Curr->getDistributedLoop()->getExitingBlock());
488 void removeUnusedInsts() {
489 for (
auto &Partition : PartitionContainer)
490 Partition.removeUnusedInsts();
500 computePartitionSetForPointers(
const LoopAccessInfo &LAI) {
503 unsigned N = RtPtrCheck->
Pointers.size();
504 SmallVector<int, 8> PtrToPartitions(
N);
505 for (
unsigned I = 0;
I <
N; ++
I) {
508 auto ReadInstructions =
510 Instructions.append(ReadInstructions.begin(), ReadInstructions.end());
512 int &Partition = PtrToPartitions[
I];
515 for (Instruction *Inst : Instructions) {
518 int ThisPartition = this->InstToPartitionId[Inst];
520 Partition = ThisPartition;
522 else if (Partition == -1)
524 else if (Partition != (
int)ThisPartition)
527 assert(Partition != -2 &&
"Pointer not belonging to any partition");
530 return PtrToPartitions;
533 void print(raw_ostream &OS)
const {
535 for (
const auto &
P : PartitionContainer) {
536 OS <<
"LDist: Partition " <<
Index++ <<
":";
544 friend raw_ostream &
operator<<(raw_ostream &OS,
545 const InstPartitionContainer &Partitions) {
546 Partitions.print(OS);
551 void printBlocks(raw_ostream &OS)
const {
553 for (
const auto &
P : PartitionContainer) {
554 OS <<
"LDist: Partition " <<
Index++ <<
":";
560 using PartitionContainerT = std::list<InstPartition>;
563 PartitionContainerT PartitionContainer;
567 InstToPartitionIdT InstToPartitionId;
575 template <
class UnaryPredicate>
576 void mergeAdjacentPartitionsIf(UnaryPredicate Predicate) {
577 InstPartition *PrevMatch =
nullptr;
578 for (
auto I = PartitionContainer.begin();
I != PartitionContainer.end();) {
580 if (PrevMatch ==
nullptr && DoesMatch) {
583 }
else if (PrevMatch !=
nullptr && DoesMatch) {
584 I->moveTo(*PrevMatch);
585 I = PartitionContainer.erase(
I);
594 void setNewLoopID(MDNode *OrigLoopID, InstPartition *Part) {
601 Loop *NewLoop = Part->getDistributedLoop();
613class MemoryInstructionDependences {
614 using Dependence = MemoryDepChecker::Dependence;
619 unsigned NumUnsafeDependencesStartOrEnd = 0;
621 Entry(Instruction *Inst) : Inst(Inst) {}
624 using AccessesType = SmallVector<Entry, 8>;
629 MemoryInstructionDependences(
630 const SmallVectorImpl<Instruction *> &Instructions,
631 const SmallVectorImpl<Dependence> &Dependences) {
635 for (
const auto &Dep : Dependences)
636 if (Dep.isPossiblyBackward()) {
640 ++Accesses[Dep.Source].NumUnsafeDependencesStartOrEnd;
641 --Accesses[Dep.Destination].NumUnsafeDependencesStartOrEnd;
648 AccessesType Accesses;
652class LoopDistributeForLoop {
654 LoopDistributeForLoop(Loop *L, Function *F, LoopInfo *LI, DominatorTree *DT,
655 ScalarEvolution *SE, LoopAccessInfoManager &LAIs,
656 OptimizationRemarkEmitter *ORE)
657 : L(L), F(F), LI(LI), DT(DT), SE(SE), LAIs(LAIs), ORE(ORE) {
663 assert(L->isInnermost() &&
"Only process inner loops.");
666 << L->getHeader()->getParent()->getName() <<
"' from "
667 << L->getLocStr() <<
"\n");
670 if (!L->getExitBlock())
671 return fail(
"MultipleExitBlocks",
"multiple exit blocks");
672 if (!L->isLoopSimplifyForm())
673 return fail(
"NotLoopSimplifyForm",
674 "loop is not in loop-simplify form");
675 if (!L->isRotatedForm())
676 return fail(
"NotBottomTested",
"loop is not bottom tested");
680 LAI = &LAIs.getInfo(*L);
684 if (LAI->canVectorizeMemory())
685 return fail(
"MemOpsCanBeVectorized",
686 "memory operations are safe for vectorization");
688 auto *Dependences = LAI->getDepChecker().getDependences();
689 if (!Dependences || Dependences->empty())
690 return fail(
"NoUnsafeDeps",
"no unsafe dependences to isolate");
693 << L->getHeader()->getName() <<
"\n");
695 InstPartitionContainer Partitions(L, LI, DT);
716 const MemoryDepChecker &DepChecker = LAI->getDepChecker();
720 int NumUnsafeDependencesActive = 0;
721 for (
const auto &InstDep : MID) {
725 if (NumUnsafeDependencesActive ||
726 InstDep.NumUnsafeDependencesStartOrEnd > 0)
727 Partitions.addToCyclicPartition(
I);
729 Partitions.addToNewNonCyclicPartition(
I);
730 NumUnsafeDependencesActive += InstDep.NumUnsafeDependencesStartOrEnd;
731 assert(NumUnsafeDependencesActive >= 0 &&
732 "Negative number of dependences active");
741 for (
auto *Inst : DefsUsedOutside)
742 Partitions.addToNewNonCyclicPartition(Inst);
744 LLVM_DEBUG(
dbgs() <<
"LDist: Seeded partitions:\n" << Partitions);
745 if (Partitions.getSize() < 2)
746 return fail(
"CantIsolateUnsafeDeps",
747 "cannot isolate unsafe dependencies");
751 Partitions.mergeBeforePopulating();
752 LLVM_DEBUG(
dbgs() <<
"LDist: Merged partitions:\n" << Partitions);
753 if (Partitions.getSize() < 2)
754 return fail(
"CantIsolateUnsafeDeps",
755 "cannot isolate unsafe dependencies");
758 Partitions.populateUsedSet();
759 LLVM_DEBUG(
dbgs() <<
"LDist: Populated partitions:\n" << Partitions);
763 if (Partitions.mergeToAvoidDuplicatedLoads()) {
764 LLVM_DEBUG(
dbgs() <<
"LDist: Partitions merged to ensure unique loads:\n"
766 if (Partitions.getSize() < 2)
767 return fail(
"CantIsolateUnsafeDeps",
768 "cannot isolate unsafe dependencies");
773 const SCEVPredicate &Pred = LAI->getPSE().getPredicate();
775 return fail(
"RuntimeCheckWithConvergent",
776 "may not insert runtime check with convergent operation");
782 return fail(
"TooManySCEVRuntimeChecks",
783 "too many SCEV run-time checks needed.\n");
786 return fail(
"HeuristicDisabled",
"distribution heuristic disabled");
789 << L->getHeader()->getName() <<
"\n");
792 Partitions.setupPartitionIdOnInstructions();
795 auto PtrToPartition = Partitions.computePartitionSetForPointers(*LAI);
796 const auto *RtPtrChecking = LAI->getRuntimePointerChecking();
797 const auto &AllChecks = RtPtrChecking->getChecks();
798 auto Checks = includeOnlyCrossPartitionChecks(AllChecks, PtrToPartition,
801 if (LAI->hasConvergentOp() && !Checks.empty()) {
802 return fail(
"RuntimeCheckWithConvergent",
803 "may not insert runtime check with convergent operation");
813 assert(!LAI->hasConvergentOp() &&
"inserting illegal loop versioning");
815 MDNode *OrigLoopID = L->getLoopID();
818 LLVM_DEBUG(LAI->getRuntimePointerChecking()->printChecks(
dbgs(), Checks));
819 LoopVersioning LVer(*LAI, Checks, L, LI, DT, SE);
820 LVer.versionLoop(DefsUsedOutside);
821 LVer.annotateLoopWithNoAlias();
829 "llvm.loop.distribute.",
true);
830 LVer.getNonVersionedLoop()->setLoopID(UnversionedLoopID);
837 Partitions.cloneLoops();
841 Partitions.removeUnusedInsts();
847 assert(DT->verify(DominatorTree::VerificationLevel::Fast));
850 ++NumLoopsDistributed;
853 return OptimizationRemark(
LDIST_NAME,
"Distribute", L->getStartLoc(),
855 <<
"distributed loop";
861 bool fail(StringRef RemarkName, StringRef Message) {
862 LLVMContext &Ctx = F->getContext();
863 bool Forced = isForced().value_or(
false);
869 return OptimizationRemarkMissed(
LDIST_NAME,
"NotDistributed",
870 L->getStartLoc(), L->getHeader())
871 <<
"loop not distributed: use -Rpass-analysis=loop-distribute for "
878 ORE->emit(OptimizationRemarkAnalysis(
880 RemarkName, L->getStartLoc(), L->getHeader())
881 <<
"loop not distributed: " << Message);
886 Ctx.
diagnose(DiagnosticInfoOptimizationFailure(
887 *F, L->getStartLoc(),
"loop not distributed: failed "
888 "explicitly specified loop distribution"));
898 const std::optional<bool> &isForced()
const {
return IsForced; }
906 SmallVector<RuntimePointerCheck, 4> includeOnlyCrossPartitionChecks(
907 const SmallVectorImpl<RuntimePointerCheck> &AllChecks,
908 const SmallVectorImpl<int> &PtrToPartition,
909 const RuntimePointerChecking *RtPtrChecking) {
910 SmallVector<RuntimePointerCheck, 4> Checks;
912 copy_if(AllChecks, std::back_inserter(Checks),
914 for (
unsigned PtrIdx1 :
Check.first->Members)
915 for (
unsigned PtrIdx2 :
Check.second->Members)
931 PtrToPartition, PtrIdx1, PtrIdx2))
942 std::optional<const MDOperand *>
Value =
957 const LoopAccessInfo *LAI =
nullptr;
960 LoopAccessInfoManager &LAIs;
961 OptimizationRemarkEmitter *ORE;
969 std::optional<bool> IsForced;
982 for (
Loop *TopLevelLoop : *LI)
985 if (L->isInnermost())
990 for (
Loop *L : Worklist) {
991 LoopDistributeForLoop LDL(L, &
F, LI, DT, SE, LAIs, ORE);
996 dbgs() <<
"LDist: Distributed loop guarded for reprocessing\n");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void fail(const SDLoc &DL, SelectionDAG &DAG, const Twine &Msg, SDValue Val={})
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
This file builds on the ADT/GraphTraits.h file to build generic depth first graph iterator.
Generic implementation of equivalence classes through the use Tarjan's efficient union-find algorithm...
static bool runImpl(Function &F, const TargetLowering &TLI, AssumptionCache *AC)
This is the interface for a simple mod/ref and alias analysis over globals.
This header defines various interfaces for pass management in LLVM.
This header provides classes for managing per-loop analyses.
static const char *const LLVMLoopDistributeFollowupCoincident
static cl::opt< bool > DistributeNonIfConvertible("loop-distribute-non-if-convertible", cl::Hidden, cl::desc("Whether to distribute into a loop that may not be " "if-convertible by the loop vectorizer"), cl::init(false))
static cl::opt< bool > EnableLoopDistribute("enable-loop-distribute", cl::Hidden, cl::desc("Enable the new, experimental LoopDistribution Pass"), cl::init(false))
static cl::opt< unsigned > DistributeSCEVCheckThreshold("loop-distribute-scev-check-threshold", cl::init(8), cl::Hidden, cl::desc("The maximum number of SCEV checks allowed for Loop " "Distribution"))
static const char *const LLVMLoopDistributeFollowupSequential
static const char *const LLVMLoopDistributeFollowupAll
static const char * DistributedMetaData
static cl::opt< unsigned > PragmaDistributeSCEVCheckThreshold("loop-distribute-scev-check-threshold-with-pragma", cl::init(128), cl::Hidden, cl::desc("The maximum number of SCEV checks allowed for Loop " "Distribution for loop marked with #pragma clang loop " "distribute(enable)"))
static const char *const LLVMLoopDistributeFollowupFallback
static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE, LoopAccessInfoManager &LAIs)
static cl::opt< bool > LDistVerify("loop-distribute-verify", cl::Hidden, cl::desc("Turn on DominatorTree and LoopInfo verification " "after Loop Distribution"), cl::init(false))
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
static unsigned getSize(unsigned Kind)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
iterator begin()
Instruction iterator methods.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
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...
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
This analysis provides dependence information for the memory accesses of a loop.
const RuntimePointerChecking * getRuntimePointerChecking() const
static LLVM_ABI bool blockNeedsPredication(BasicBlock *BB, Loop *TheLoop, DominatorTree *DT)
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
SmallVector< Instruction *, 4 > getInstructionsForAccess(Value *Ptr, bool isWrite) const
Return the list of instructions that use Ptr to read or write memory.
Analysis pass that exposes the LoopInfo for a function.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Represents a single loop in the control flow graph.
void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
const SmallVectorImpl< Instruction * > & getMemoryInstructions() const
The vector of memory access instructions.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
LLVM_ABI bool needsChecking(const RuntimeCheckingPtrGroup &M, const RuntimeCheckingPtrGroup &N) const
Decide if we need to add a check between two groups of pointers, according to needsChecking.
static LLVM_ABI bool arePointersInSamePartition(const SmallVectorImpl< int > &PtrToPartition, unsigned PtrIdx1, unsigned PtrIdx2)
Check if pointers are in the same partition.
SmallVector< PointerInfo, 2 > Pointers
Information about the pointers that may require checking.
virtual unsigned getComplexity() const
Returns the estimated complexity of this predicate.
virtual bool isAlwaysTrue() const =0
Returns true if the predicate is always true.
Analysis pass that exposes the ScalarEvolution for a function.
The main scalar evolution driver.
typename vector_type::const_iterator iterator
typename vector_type::const_iterator const_iterator
A SetVector that performs no allocations if smaller than a certain size.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI bool replaceUsesOfWith(Value *From, Value *To)
Replace uses of one Value with another.
const ParentTy * getParent() const
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
initializer< Ty > init(const Ty &Val)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, bool > hasa(Y &&MD)
Check whether Metadata has a Value.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
LLVM_ABI iterator begin() const
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.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
FunctionAddr VTableAddr Value
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
std::pair< const RuntimeCheckingPtrGroup *, const RuntimeCheckingPtrGroup * > RuntimePointerCheck
A memcheck which made up of a pair of grouped pointers.
LLVM_ABI std::optional< bool > getOptionalBoolLoopAttribute(const Loop *TheLoop, StringRef Name)
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.
LLVM_ABI void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI std::optional< MDNode * > makeFollowupLoopID(MDNode *OrigLoopID, ArrayRef< StringRef > FollowupAttrs, const char *InheritOptionsAttrsPrefix="", bool AlwaysNew=false)
Create a new loop identifier for a loop created from a loop transformation.
OutputIt copy_if(R &&Range, OutputIt Out, UnaryPredicate P)
Provide wrappers to std::copy_if which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void addStringMetadataToLoop(Loop *TheLoop, const char *MDString, unsigned V=0)
Set input string into loop metadata by keeping other values intact.
LLVM_ABI SmallVector< Instruction *, 8 > findDefsUsedOutsideOfLoop(Loop *L)
Returns the instructions that use values defined in the loop.
auto reverse(ContainerTy &&C)
LLVM_ABI Loop * cloneLoopWithPreheader(BasicBlock *Before, BasicBlock *LoopDomBB, Loop *OrigLoop, ValueToValueMapTy &VMap, const Twine &NameSuffix, LoopInfo *LI, DominatorTree *DT, SmallVectorImpl< BasicBlock * > &Blocks)
Clones a loop OrigLoop.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI bool hasDisableAllTransformsHint(const Loop *L)
Look for the loop attribute that disables all transformation heuristic.
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...
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
LLVM_ABI void remapInstructionsInBlocks(ArrayRef< BasicBlock * > Blocks, ValueToValueMapTy &VMap)
Remaps instructions in Blocks using the mapping in VMap.
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI BasicBlock * SplitBlock(BasicBlock *Old, BasicBlock::iterator SplitPt, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, const Twine &BBName="", bool Before=false)
Split the specified block at the specified instruction.
iterator_range< df_iterator< T > > depth_first(const T &G)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.