13#ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
14#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
124 assert(Inst &&
"Def requires inst");
128 assert(Inst &&
"Clobber requires inst");
135 return MemDepResult(ValueTy::create<Other>(NonFuncLocal));
155 return Value.is<Other>() &&
Value.cast<Other>() == NonLocal;
161 return Value.is<Other>() &&
Value.cast<Other>() == NonFuncLocal;
167 return Value.is<Other>() &&
Value.cast<Other>() == Unknown;
173 switch (
Value.getTag()) {
175 return Value.cast<Invalid>();
177 return Value.cast<Clobber>();
179 return Value.cast<Def>();
195 bool isDirty()
const {
return Value.is<Invalid>(); }
211 : BB(BB), Result(Result) {}
236 : Entry(BB, Result), Address(Address) {}
292 struct NonLocalPointerInfo {
306 NonLocalPointerInfo() =
default;
313 using ReverseNonLocalDefsCacheTy =
315 ReverseNonLocalDefsCacheTy ReverseNonLocalDefsCache;
322 using CachedNonLocalPointerInfo =
324 CachedNonLocalPointerInfo NonLocalPointerDeps;
327 using ReverseNonLocalPtrDepTy =
329 ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
336 using PerInstNLInfo = std::pair<NonLocalDepInfo, bool>;
341 NonLocalDepMapType NonLocalDepsMap;
345 using ReverseDepMapType =
347 ReverseDepMapType ReverseLocalDeps;
350 ReverseDepMapType ReverseNonLocalDeps;
360 unsigned DefaultBlockScanLimit;
364 ClobberOffsetsMapType ClobberOffsets;
369 unsigned DefaultBlockScanLimit)
370 : AA(AA), AC(AC), TLI(TLI), DT(DT), EII(DT),
371 DefaultBlockScanLimit(DefaultBlockScanLimit) {}
452 unsigned *Limit =
nullptr);
480 const auto Off = ClobberOffsets.find(DepInst);
481 if (Off != ClobberOffsets.end())
482 return Off->getSecond();
490 bool getNonLocalPointerDepFromBB(
Instruction *QueryInst,
496 bool SkipFirstBlock =
false,
497 bool IsIncomplete =
false);
501 unsigned NumSortedEntries,
504 void removeCachedNonLocalPointerDependencies(ValueIsLoadPair
P);
519 unsigned DefaultBlockScanLimit;
533 std::optional<MemoryDependenceResults> MemDep;
static bool isLoad(int Opcode)
This file defines the DenseMap class.
This file provides utility analysis objects describing memory locations.
This header defines various interfaces for pass management in LLVM.
This file defines the PointerIntPair class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallPtrSet class.
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
Represent the analysis usage information of a pass.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Context-sensitive CaptureInfo provider, which computes and caches the earliest common dominator closu...
FunctionPass class - This class is used to implement most global optimizations.
An instruction for reading from memory.
static constexpr LocationSize afterPointer()
Any location after the base pointer (but still within the underlying object).
A memory dependence query can return one of three different answers.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
bool operator!=(const MemDepResult &M) const
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block,...
static MemDepResult getNonLocal()
bool isNonFuncLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the function.
bool operator>(const MemDepResult &M) const
static MemDepResult getClobber(Instruction *Inst)
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
bool operator==(const MemDepResult &M) const
static MemDepResult getUnknown()
bool operator<(const MemDepResult &M) const
bool isLocal() const
Tests if this MemDepResult represents a valid local query (Clobber/Def).
bool isUnknown() const
Tests if this MemDepResult represents a query which cannot and/or will not be computed.
static MemDepResult getNonFuncLocal()
static MemDepResult getDef(Instruction *Inst)
get methods: These are static ctor methods for creating various MemDepResult kinds.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
An analysis that produces MemoryDependenceResults for a function.
MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM)
MemoryDependenceAnalysis(unsigned DefaultBlockScanLimit)
MemoryDependenceAnalysis()
Provides a lazy, caching interface for making common memory aliasing information queries,...
MemDepResult getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst, unsigned *Limit, BatchAAResults &BatchAA)
std::vector< NonLocalDepEntry > NonLocalDepInfo
void invalidateCachedPredecessors()
Clears the PredIteratorCache info.
void invalidateCachedPointerInfo(Value *Ptr)
Invalidates cached information about the specified pointer, because it may be too conservative in mem...
MemoryDependenceResults(AAResults &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, DominatorTree &DT, unsigned DefaultBlockScanLimit)
MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst=nullptr, unsigned *Limit=nullptr)
Returns the instruction on which a memory location depends.
std::optional< int32_t > getClobberOffset(LoadInst *DepInst) const
Return the clobber offset to dependent instruction.
void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB)
This analysis looks for other loads and stores with invariant.group metadata and the same pointer ope...
unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.
const NonLocalDepInfo & getNonLocalCallDependency(CallBase *QueryCall)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location,...
void releaseMemory()
Release memory in caches.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation in the new PM.
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance.
bool runOnFunction(Function &) override
Pass Implementation stuff. This doesn't do any analysis eagerly.
~MemoryDependenceWrapperPass() override
void getAnalysisUsage(AnalysisUsage &AU) const override
Does not modify anything. It uses Value Numbering and Alias Analysis.
MemoryDependenceResults & getMemDep()
void releaseMemory() override
Clean up memory in between runs.
MemoryDependenceWrapperPass()
Representation for a specific memory location.
This is an entry in the NonLocalDepInfo cache.
void setResult(const MemDepResult &R)
NonLocalDepEntry(BasicBlock *BB, MemDepResult Result)
BasicBlock * getBB() const
bool operator<(const NonLocalDepEntry &RHS) const
NonLocalDepEntry(BasicBlock *BB)
const MemDepResult & getResult() const
This is a result from a NonLocal dependence query.
NonLocalDepResult(BasicBlock *BB, MemDepResult Result, Value *Address)
BasicBlock * getBB() const
const MemDepResult & getResult() const
Value * getAddress() const
Returns the address of this pointer in this block.
void setResult(const MemDepResult &R, Value *Addr)
PHITransAddr - An address value which tracks and handles phi translation.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
A set of analyses that are preserved following a run of a transformation pass.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Provides information about what library functions are available for the current target.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
A compile time pair of an integer tag and the pointer-like type which it indexes within a sum type.