LLVM 20.0.0git
|
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PriorityWorklist.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/InstSimplifyFolder.h"
#include "llvm/Analysis/LoopAccessAnalysis.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/IR/ProfDataUtils.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
Go to the source code of this file.
Classes | |
struct | RewritePhi |
struct | PointerBounds |
IR Values for the lower and upper bounds of a pointer evolution. More... | |
Macros | |
#define | DEBUG_TYPE "loop-utils" |
Functions | |
static MDNode * | createStringMetadata (Loop *TheLoop, StringRef Name, unsigned V) |
Create MDNode for input string. | |
static BranchInst * | getExpectedExitLoopLatchBranch (Loop *L) |
Checks if L has an exiting latch branch. | |
static std::optional< uint64_t > | getEstimatedTripCount (BranchInst *ExitingBranch, Loop *L, uint64_t &OrigExitWeight) |
Return the estimated trip count for any exiting branch which dominates the loop latch. | |
static bool | hasHardUserWithinLoop (const Loop *L, const Instruction *I) |
static bool | canLoopBeDeleted (Loop *L, SmallVector< RewritePhi, 8 > &RewritePhiSet) |
static bool | checkIsIndPhi (PHINode *Phi, Loop *L, ScalarEvolution *SE, InductionDescriptor &ID) |
Checks if it is safe to call InductionDescriptor::isInductionPHI for Phi , and returns true if this Phi is an induction phi in the loop. | |
static PointerBounds | expandBounds (const RuntimeCheckingPtrGroup *CG, Loop *TheLoop, Instruction *Loc, SCEVExpander &Exp, bool HoistRuntimeChecks) |
Expand code for the lower and upper bound of the pointer group CG in TheLoop . | |
static SmallVector< std::pair< PointerBounds, PointerBounds >, 4 > | expandBounds (const SmallVectorImpl< RuntimePointerCheck > &PointerChecks, Loop *L, Instruction *Loc, SCEVExpander &Exp, bool HoistRuntimeChecks) |
Turns a collection of checks into a collection of expanded upper and lower bounds for both pointers in the check. | |
Variables | |
static const char * | LLVMLoopDisableNonforced = "llvm.loop.disable_nonforced" |
static const char * | LLVMLoopDisableLICM = "llvm.licm.disable" |
#define DEBUG_TYPE "loop-utils" |
Definition at line 52 of file LoopUtils.cpp.
|
static |
Definition at line 1484 of file LoopUtils.cpp.
References llvm::any_of(), llvm::BasicBlock::begin(), I, P, and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::rewriteLoopExitValues().
|
static |
Checks if it is safe to call InductionDescriptor::isInductionPHI for Phi
, and returns true if this Phi is an induction phi in the loop.
When isInductionPHI returns true, ID
will be also be set by isInductionPHI.
Definition at line 1538 of file LoopUtils.cpp.
References llvm::InductionDescriptor::isInductionPHI().
Referenced by llvm::rewriteLoopExitValues().
Create MDNode for input string.
Definition at line 203 of file LoopUtils.cpp.
References llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::MDString::get(), llvm::BasicBlock::getContext(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::Type::getInt32Ty(), and Name.
Referenced by llvm::addStringMetadataToLoop().
|
static |
Expand code for the lower and upper bound of the pointer group CG
in TheLoop
.
Definition at line 1866 of file LoopUtils.cpp.
References llvm::RuntimeCheckingPtrGroup::AddressSpace, llvm::ScalarEvolution::applyLoopGuards(), llvm::IRBuilderBase::CreateFreeze(), llvm::dbgs(), End, llvm::Value::getContext(), llvm::ScalarEvolution::getExitCount(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::SCEV::getType(), llvm::RuntimeCheckingPtrGroup::High, High, HoistRuntimeChecks, llvm::Type::isIntegerTy(), llvm::ScalarEvolution::isKnownNonNegative(), LLVM_DEBUG, llvm::RuntimeCheckingPtrGroup::Low, llvm::Low, and llvm::RuntimeCheckingPtrGroup::NeedsFreeze.
Referenced by llvm::addRuntimeChecks(), and expandBounds().
|
static |
Turns a collection of checks into a collection of expanded upper and lower bounds for both pointers in the check.
Definition at line 1936 of file LoopUtils.cpp.
References Check, expandBounds(), llvm::First, HoistRuntimeChecks, and llvm::transform().
|
static |
Return the estimated trip count for any exiting branch which dominates the loop latch.
Definition at line 823 of file LoopUtils.cpp.
References llvm::divideNearest(), llvm::extractBranchWeights(), llvm::BranchInst::getSuccessor(), and std::swap().
Referenced by llvm::getLoopEstimatedTripCount().
|
static |
Checks if L
has an exiting latch branch.
There may also be other exiting blocks. Returns branch instruction terminating the loop latch if above check is successful, nullptr otherwise.
Definition at line 805 of file LoopUtils.cpp.
References assert(), llvm::BranchInst::getNumSuccessors(), llvm::BranchInst::getSuccessor(), and llvm::BasicBlock::getTerminator().
Referenced by llvm::getLoopEstimatedTripCount(), and llvm::setLoopEstimatedTripCount().
|
static |
Definition at line 1443 of file LoopUtils.cpp.
References llvm::SmallVectorBase< Size_T >::empty(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Instruction::mayHaveSideEffects(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::Value::users().
Referenced by llvm::rewriteLoopExitValues().
Definition at line 55 of file LoopUtils.cpp.
Referenced by llvm::hasDisableLICMTransformsHint().
Definition at line 54 of file LoopUtils.cpp.
Referenced by llvm::hasDisableAllTransformsHint().