#include "llvm/Analysis/LoopInfo.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/IVDescriptors.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/Analysis/LoopNestAnalysis.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PrintPasses.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/GenericLoopInfoImpl.h"
#include "llvm/Support/raw_ostream.h"
usingnamespacellvm;
template class llvm::LoopBase<BasicBlock, Loop>;
template class llvm::LoopInfoBase<BasicBlock, Loop>;
#ifdef EXPENSIVE_CHECKS
bool llvm::VerifyLoopInfo = true;
#else
bool llvm::VerifyLoopInfo = …;
#endif
static cl::opt<bool, true>
VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo),
cl::Hidden, cl::desc("Verify loop info (time consuming)"));
bool Loop::isLoopInvariant(const Value *V) const { … }
bool Loop::hasLoopInvariantOperands(const Instruction *I) const { … }
bool Loop::makeLoopInvariant(Value *V, bool &Changed, Instruction *InsertPt,
MemorySSAUpdater *MSSAU,
ScalarEvolution *SE) const { … }
bool Loop::makeLoopInvariant(Instruction *I, bool &Changed,
Instruction *InsertPt, MemorySSAUpdater *MSSAU,
ScalarEvolution *SE) const { … }
bool Loop::getIncomingAndBackEdge(BasicBlock *&Incoming,
BasicBlock *&Backedge) const { … }
PHINode *Loop::getCanonicalInductionVariable() const { … }
ICmpInst *Loop::getLatchCmpInst() const { … }
static Value *findFinalIVValue(const Loop &L, const PHINode &IndVar,
const Instruction &StepInst) { … }
std::optional<Loop::LoopBounds>
Loop::LoopBounds::getBounds(const Loop &L, PHINode &IndVar,
ScalarEvolution &SE) { … }
Direction;
ICmpInst::Predicate Loop::LoopBounds::getCanonicalPredicate() const { … }
Direction Loop::LoopBounds::getDirection() const { … }
std::optional<Loop::LoopBounds> Loop::getBounds(ScalarEvolution &SE) const { … }
PHINode *Loop::getInductionVariable(ScalarEvolution &SE) const { … }
bool Loop::getInductionDescriptor(ScalarEvolution &SE,
InductionDescriptor &IndDesc) const { … }
bool Loop::isAuxiliaryInductionVariable(PHINode &AuxIndVar,
ScalarEvolution &SE) const { … }
BranchInst *Loop::getLoopGuardBranch() const { … }
bool Loop::isCanonical(ScalarEvolution &SE) const { … }
static bool isBlockInLCSSAForm(const Loop &L, const BasicBlock &BB,
const DominatorTree &DT, bool IgnoreTokens) { … }
bool Loop::isLCSSAForm(const DominatorTree &DT, bool IgnoreTokens) const { … }
bool Loop::isRecursivelyLCSSAForm(const DominatorTree &DT, const LoopInfo &LI,
bool IgnoreTokens) const { … }
bool Loop::isLoopSimplifyForm() const { … }
bool Loop::isSafeToClone() const { … }
MDNode *Loop::getLoopID() const { … }
void Loop::setLoopID(MDNode *LoopID) const { … }
void Loop::setLoopAlreadyUnrolled() { … }
void Loop::setLoopMustProgress() { … }
bool Loop::isAnnotatedParallel() const { … }
DebugLoc Loop::getStartLoc() const { … }
Loop::LocRange Loop::getLocRange() const { … }
std::string Loop::getLocStr() const { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Loop::dump() const { print(dbgs()); }
LLVM_DUMP_METHOD void Loop::dumpVerbose() const {
print(dbgs(), true);
}
#endif
namespace {
class UnloopUpdater { … };
}
void UnloopUpdater::updateBlockParents() { … }
void UnloopUpdater::removeBlocksFromAncestors() { … }
void UnloopUpdater::updateSubloopParents() { … }
Loop *UnloopUpdater::getNearestLoop(BasicBlock *BB, Loop *BBLoop) { … }
LoopInfo::LoopInfo(const DomTreeBase<BasicBlock> &DomTree) { … }
bool LoopInfo::invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &) { … }
void LoopInfo::erase(Loop *Unloop) { … }
bool LoopInfo::wouldBeOutOfLoopUseRequiringLCSSA(
const Value *V, const BasicBlock *ExitBB) const { … }
AnalysisKey LoopAnalysis::Key;
LoopInfo LoopAnalysis::run(Function &F, FunctionAnalysisManager &AM) { … }
PreservedAnalyses LoopPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) { … }
void llvm::printLoop(Loop &L, raw_ostream &OS, const std::string &Banner) { … }
MDNode *llvm::findOptionMDForLoopID(MDNode *LoopID, StringRef Name) { … }
MDNode *llvm::findOptionMDForLoop(const Loop *TheLoop, StringRef Name) { … }
std::optional<const MDOperand *>
llvm::findStringMetadataForLoop(const Loop *TheLoop, StringRef Name) { … }
std::optional<bool> llvm::getOptionalBoolLoopAttribute(const Loop *TheLoop,
StringRef Name) { … }
bool llvm::getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name) { … }
std::optional<int> llvm::getOptionalIntLoopAttribute(const Loop *TheLoop,
StringRef Name) { … }
int llvm::getIntLoopAttribute(const Loop *TheLoop, StringRef Name,
int Default) { … }
CallBase *llvm::getLoopConvergenceHeart(const Loop *TheLoop) { … }
bool llvm::isFinite(const Loop *L) { … }
static const char *LLVMLoopMustProgress = …;
bool llvm::hasMustProgress(const Loop *L) { … }
bool llvm::isMustProgress(const Loop *L) { … }
bool llvm::isValidAsAccessGroup(MDNode *Node) { … }
MDNode *llvm::makePostTransformationMetadata(LLVMContext &Context,
MDNode *OrigLoopID,
ArrayRef<StringRef> RemovePrefixes,
ArrayRef<MDNode *> AddAttrs) { … }
LoopInfoWrapperPass::LoopInfoWrapperPass() : … { … }
char LoopInfoWrapperPass::ID = …;
INITIALIZE_PASS_BEGIN(LoopInfoWrapperPass, "loops", "Natural Loop Information",
true, true)
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
INITIALIZE_PASS_END(LoopInfoWrapperPass, "loops", "Natural Loop Information",
true, true)
bool LoopInfoWrapperPass::runOnFunction(Function &) { … }
void LoopInfoWrapperPass::verifyAnalysis() const { … }
void LoopInfoWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { … }
void LoopInfoWrapperPass::print(raw_ostream &OS, const Module *) const { … }
PreservedAnalyses LoopVerifierPass::run(Function &F,
FunctionAnalysisManager &AM) { … }
void LoopBlocksDFS::perform(const LoopInfo *LI) { … }