13#ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
14#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
129 assert(Inst &&
"Def requires inst");
133 assert(Inst &&
"Clobber requires inst");
155 bool isDef()
const {
return Value.is<Def>(); }
163 return Value.is<Other>() && Value.cast<Other>() == NonLocal;
169 return Value.is<Other>() && Value.cast<Other>() == NonFuncLocal;
175 return Value.is<Other>() && Value.cast<Other>() == Select;
181 return Value.is<Other>() && Value.cast<Other>() == Unknown;
187 switch (Value.getTag()) {
189 return Value.cast<Invalid>();
191 return Value.cast<Clobber>();
193 return Value.cast<Def>();
200 bool operator==(
const MemDepResult &M)
const {
return Value == M.Value; }
201 bool operator!=(
const MemDepResult &M)
const {
return Value != M.Value; }
202 bool operator<(
const MemDepResult &M)
const {
return Value < M.Value; }
203 bool operator>(
const MemDepResult &M)
const {
return Value > M.Value; }
209 bool isDirty()
const {
return Value.is<Invalid>(); }
225 : BB(BB), Result(Result) {}
251 : Entry(BB, Result), Address(Address) {}
293 LocalDepMapType LocalDeps;
311 struct NonLocalPointerInfo {
313 BBSkipFirstBlockPair Pair;
325 NonLocalPointerInfo() =
default;
332 using ReverseNonLocalDefsCacheTy =
334 ReverseNonLocalDefsCacheTy ReverseNonLocalDefsCache;
341 using CachedNonLocalPointerInfo =
343 CachedNonLocalPointerInfo NonLocalPointerDeps;
346 using ReverseNonLocalPtrDepTy =
348 ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
355 using PerInstNLInfo = std::pair<NonLocalDepInfo, bool>;
360 NonLocalDepMapType NonLocalDepsMap;
364 using ReverseDepMapType =
366 ReverseDepMapType ReverseLocalDeps;
369 ReverseDepMapType ReverseNonLocalDeps;
375 unsigned NonLocalPointerDepEpoch = 0;
385 unsigned DefaultBlockScanLimit;
389 ClobberOffsetsMapType ClobberOffsets;
394 unsigned DefaultBlockScanLimit)
395 : AA(AA), AC(AC), TLI(TLI), DT(DT), EEA(DT),
396 DefaultBlockScanLimit(DefaultBlockScanLimit) {}
400 FunctionAnalysisManager::Invalidator &Inv);
478 unsigned *Limit =
nullptr);
504 const auto Off = ClobberOffsets.find(DepInst);
505 if (Off != ClobberOffsets.end())
506 return Off->getSecond();
515 bool isNonLocalPointerDepVisited(
BasicBlock *BB)
const;
517 bool getNonLocalPointerDepFromBB(
Instruction *QueryInst,
522 bool SkipFirstBlock =
false,
523 bool IsIncomplete =
false);
527 unsigned NumSortedEntries,
530 void removeCachedNonLocalPointerDependencies(ValueIsLoadPair
P);
545 unsigned DefaultBlockScanLimit;
560 std::optional<MemoryDependenceResults> MemDep;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isLoad(int Opcode)
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
This file provides utility analysis objects describing memory locations.
This file defines the PointerIntPair class.
This file defines the SmallPtrSet class.
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 CaptureAnalysis provider, which computes and caches the earliest common dominator c...
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.
static MemDepResult getSelect()
friend class MemoryDependenceResults
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 isSelect() const
Tests if this MemDepResult represents a query that depends on a select instruction whose two sides ea...
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.
LLVM_ABI MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM)
MemoryDependenceResults Result
MemoryDependenceAnalysis(unsigned DefaultBlockScanLimit)
LLVM_ABI MemoryDependenceAnalysis()
Provides a lazy, caching interface for making common memory aliasing information queries,...
LLVM_ABI MemDepResult getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst, unsigned *Limit, BatchAAResults &BatchAA)
LLVM_ABI void releaseMemory()
Release memory in caches.
std::vector< NonLocalDepEntry > NonLocalDepInfo
LLVM_ABI void invalidateCachedPredecessors()
Clears the PredIteratorCache info.
LLVM_ABI 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)
LLVM_ABI 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.
LLVM_ABI void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
LLVM_ABI MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB)
This analysis looks for other loads and stores with invariant.group metadata and the same pointer ope...
LLVM_ABI unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
LLVM_ABI MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.
LLVM_ABI const NonLocalDepInfo & getNonLocalCallDependency(CallBase *QueryCall)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
LLVM_ABI void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location,...
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation in the new PM.
~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.
BasicBlock * getBB() const
void setResult(const MemDepResult &R, const SelectAddr &Addr)
const MemDepResult & getResult() const
NonLocalDepResult(BasicBlock *BB, MemDepResult Result, const SelectAddr &Address)
SelectAddr getAddress() const
Returns the address of this pointer in this block.
PHITransAddr - An address value which tracks and handles phi translation.
PointerIntPair - This class implements a pair of a pointer and small integer.
A sum type over pointer-like types.
static PointerSumType create(typename HelperT::template Lookup< N >::PointerT Pointer)
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.
Storage of either a normal Value address, or a select condition together with a pair of addresses for...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
Abstract Attribute helper functions.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
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.