13#ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
14#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
32struct AnalysisOptions;
130 assert(Inst &&
"Def requires inst");
134 assert(Inst &&
"Clobber requires inst");
156 bool isDef()
const {
return Value.is<Def>(); }
164 return Value.is<Other>() && Value.cast<Other>() == NonLocal;
170 return Value.is<Other>() && Value.cast<Other>() == NonFuncLocal;
176 return Value.is<Other>() && Value.cast<Other>() == Select;
182 return Value.is<Other>() && Value.cast<Other>() == Unknown;
188 switch (Value.getTag()) {
190 return Value.cast<Invalid>();
192 return Value.cast<Clobber>();
194 return Value.cast<Def>();
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; }
204 bool operator>(
const MemDepResult &M)
const {
return Value > M.Value; }
210 bool isDirty()
const {
return Value.is<Invalid>(); }
226 : BB(BB), Result(Result) {}
252 : Entry(BB, Result), Address(Address) {}
292 const AnalysisOptions &Opts;
296 LocalDepMapType LocalDeps;
314 struct NonLocalPointerInfo {
316 BBSkipFirstBlockPair Pair;
328 NonLocalPointerInfo() =
default;
335 using ReverseNonLocalDefsCacheTy =
337 ReverseNonLocalDefsCacheTy ReverseNonLocalDefsCache;
344 using CachedNonLocalPointerInfo =
346 CachedNonLocalPointerInfo NonLocalPointerDeps;
349 using ReverseNonLocalPtrDepTy =
351 ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
358 using PerInstNLInfo = std::pair<NonLocalDepInfo, bool>;
363 NonLocalDepMapType NonLocalDepsMap;
367 using ReverseDepMapType =
369 ReverseDepMapType ReverseLocalDeps;
372 ReverseDepMapType ReverseNonLocalDeps;
378 unsigned NonLocalPointerDepEpoch = 0;
388 unsigned DefaultBlockScanLimit;
392 ClobberOffsetsMapType ClobberOffsets;
398 unsigned DefaultBlockScanLimit);
402 FunctionAnalysisManager::Invalidator &Inv);
480 unsigned *Limit =
nullptr);
503 const auto Off = ClobberOffsets.find(DepInst);
504 if (
Off != ClobberOffsets.end())
505 return Off->getSecond();
514 bool isNonLocalPointerDepVisited(
BasicBlock *BB)
const;
516 bool getNonLocalPointerDepFromBB(
Instruction *QueryInst,
521 bool SkipFirstBlock =
false,
522 bool IsIncomplete =
false);
526 unsigned NumSortedEntries,
529 void removeCachedNonLocalPointerDependencies(ValueIsLoadPair
P);
544 std::optional<unsigned> DefaultBlockScanLimit;
559 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)
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...
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 MemoryDependenceResults(AAResults &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, DominatorTree &DT, unsigned DefaultBlockScanLimit)
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 instruction together with a pair of addresses f...
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.