14 #ifndef LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
15 #define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
33 class AssumptionCache;
34 class MemoryDependenceResults;
35 class PredIteratorCache;
123 assert(Inst &&
"Def requires inst");
127 assert(Inst &&
"Clobber requires inst");
134 return MemDepResult(ValueTy::create<Other>(NonFuncLocal));
151 return Value.is<Other>() &&
Value.cast<Other>() == NonLocal;
157 return Value.is<Other>() &&
Value.cast<Other>() == NonFuncLocal;
163 return Value.is<Other>() &&
Value.cast<Other>() == Unknown;
169 switch (
Value.getTag()) {
171 return Value.cast<Invalid>();
173 return Value.cast<Clobber>();
175 return Value.cast<Def>();
207 : BB(bb), Result(result) {}
232 : Entry(bb, result), Address(address) {}
288 struct NonLocalPointerInfo {
315 CachedNonLocalPointerInfo;
316 CachedNonLocalPointerInfo NonLocalPointerDeps;
320 ReverseNonLocalPtrDepTy;
321 ReverseNonLocalPtrDepTy ReverseNonLocalPtrDeps;
328 typedef std::pair<NonLocalDepInfo, bool> PerInstNLInfo;
333 NonLocalDepMapType NonLocalDeps;
339 ReverseDepMapType ReverseLocalDeps;
342 ReverseDepMapType ReverseNonLocalDeps;
355 : AA(AA), AC(AC), TLI(TLI), DT(DT) {}
436 unsigned *Limit =
nullptr);
443 unsigned *Limit =
nullptr);
472 bool getNonLocalPointerDepFromBB(
Instruction *QueryInst,
478 bool SkipFirstBlock =
false);
482 unsigned NumSortedEntries);
484 void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair
P);
void invalidateCachedPointerInfo(Value *Ptr)
Invalidates cached information about the specified pointer, because it may be too conservative in mem...
void invalidateCachedPredecessors()
Clears the PredIteratorCache info.
MemoryDependenceResults(AliasAnalysis &AA, AssumptionCache &AC, const TargetLibraryInfo &TLI, DominatorTree &DT)
Provides a lazy, caching interface for making common memory aliasing information queries, backed by LLVM's alias analysis passes.
bool isDef() const
Tests if this MemDepResult represents a query that is an instruction definition dependency.
A compile time pair of an integer tag and the pointer-like type which it indexes within a sum type...
MemDepResult getInvariantGroupPointerDependency(LoadInst *LI, BasicBlock *BB)
This analysis looks for other loads and stores with invariant.group metadata and the same pointer ope...
BasicBlock * getBB() const
bool operator<(const MemDepResult &M) const
A cache of .assume calls within a function.
void releaseMemory()
Release memory in caches.
An instruction for reading from memory.
void setResult(const MemDepResult &R, Value *Addr)
bool isUnknown() const
Tests if this MemDepResult represents a query which cannot and/or will not be computed.
bool isClobber() const
Tests if this MemDepResult represents a query that is an instruction clobber dependency.
static unsigned getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs, unsigned MemLocSize, const LoadInst *LI)
Looks at a memory location for a load (specified by MemLocBase, Offs, and Size) and compares it again...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void getNonLocalPointerDependency(Instruction *QueryInst, SmallVectorImpl< NonLocalDepResult > &Result)
Perform a full dependency query for an access to the QueryInst's specified memory location...
static MemDepResult getDef(Instruction *Inst)
get methods: These are static ctor methods for creating various MemDepResult kinds.
An analysis that produces MemoryDependenceResults for a function.
MemoryDependenceWrapperPass()
std::vector< NonLocalDepEntry > NonLocalDepInfo
Value * getAddress() const
Returns the address of this pointer in this block.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries...
bool operator==(const MemDepResult &M) const
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
~MemoryDependenceWrapperPass() override
static MemDepResult getUnknown()
const NonLocalDepInfo & getNonLocalCallDependency(CallSite QueryCS)
Perform a full dependency query for the specified call, returning the set of blocks that the value is...
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
PointerIntPair - This class implements a pair of a pointer and small integer.
PHITransAddr - An address value which tracks and handles phi translation.
bool operator>(const MemDepResult &M) const
This is a result from a NonLocal dependence query.
A CRTP mix-in that provides informational APIs needed for analysis passes.
NonLocalDepResult(BasicBlock *bb, MemDepResult result, Value *address)
MemDepResult getSimplePointerDependencyFrom(const MemoryLocation &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB, Instruction *QueryInst, unsigned *Limit=nullptr)
Represent the analysis usage information of a pass.
static MemDepResult getNonFuncLocal()
BasicBlock * getBB() const
FunctionPass class - This class is used to implement most global optimizations.
const MemDepResult & getResult() const
void setResult(const MemDepResult &R)
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
A memory dependence query can return one of three different answers.
unsigned getDefaultBlockScanLimit() const
Some methods limit the number of instructions they will examine.
Representation for a specific memory location.
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.
NonLocalDepEntry(BasicBlock *bb, MemDepResult result)
Iterator for intrusive lists based on ilist_node.
MemoryDependenceResults Result
Provides information about what library functions are available for the current target.
static MemDepResult getClobber(Instruction *Inst)
MemoryDependenceResults run(Function &F, FunctionAnalysisManager &AM)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool isNonLocal() const
Tests if this MemDepResult represents a query that is transparent to the start of the block...
void getAnalysisUsage(AnalysisUsage &AU) const override
Does not modify anything. It uses Value Numbering and Alias Analysis.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void releaseMemory() override
Clean up memory in between runs.
bool operator<(const NonLocalDepEntry &RHS) const
bool runOnFunction(Function &) override
Pass Implementation stuff. This doesn't do any analysis eagerly.
A sum type over pointer-like types.
Instruction * getInst() const
If this is a normal dependency, returns the instruction that is depended on.
NonLocalDepEntry(BasicBlock *bb)
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation in the new PM.
API to communicate dependencies between analyses during invalidation.
MemoryDependenceResults & getMemDep()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void removeInstruction(Instruction *InstToRemove)
Removes an instruction from the dependence analysis, updating the dependence of instructions that pre...
const MemDepResult & getResult() const
This is an entry in the NonLocalDepInfo cache.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
static MemDepResult getNonLocal()
A special type used by analysis passes to provide an address that identifies that particular analysis...
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
MemDepResult getDependency(Instruction *QueryInst)
Returns the instruction on which a memory operation depends.