38 #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
39 #define LLVM_ANALYSIS_ALIASANALYSIS_H
55 class MemTransferInst;
58 class OrderedBasicBlock;
193 template <
typename AAResultT>
void addAAResult(AAResultT &AAResult) {
197 AAs.emplace_back(
new Model<AAResultT>(AAResult, *
this));
541 case Instruction::AtomicCmpXchg:
543 case Instruction::AtomicRMW:
547 case Instruction::CatchPad:
549 case Instruction::CatchRet:
625 std::vector<std::unique_ptr<Concept>> AAs;
627 std::vector<AnalysisKey *> AADeps;
678 unsigned ArgIdx) = 0;
710 explicit Model(AAResultT &Result,
AAResults &AAR) : Result(Result) {
711 Result.setAAResults(&AAR);
715 void setAAResults(
AAResults *NewAAR)
override { Result.setAAResults(NewAAR); }
718 const MemoryLocation &LocB)
override {
719 return Result.alias(LocA, LocB);
723 bool OrLocal)
override {
724 return Result.pointsToConstantMemory(Loc, OrLocal);
728 return Result.getArgModRefInfo(CS, ArgIdx);
732 return Result.getModRefBehavior(CS);
736 return Result.getModRefBehavior(F);
740 const MemoryLocation &Loc)
override {
741 return Result.getModRefInfo(CS, Loc);
745 ImmutableCallSite CS2)
override {
746 return Result.getModRefInfo(CS1, CS2);
774 DerivedT &derived() {
return static_cast<DerivedT &
>(*this); }
778 void setAAResults(
AAResults *NewAAR) { AAR = NewAAR; }
786 DerivedT &CurrentResult;
790 : AAR(AAR), CurrentResult(CurrentResult) {}
793 return AAR ? AAR->
alias(LocA, LocB) : CurrentResult.alias(LocA, LocB);
798 : CurrentResult.pointsToConstantMemory(Loc, OrLocal);
802 return AAR ? AAR->
getArgModRefInfo(CS, ArgIdx) : CurrentResult.getArgModRefInfo(CS, ArgIdx);
815 : CurrentResult.getModRefInfo(CS, Loc);
819 return AAR ? AAR->
getModRefInfo(CS1, CS2) : CurrentResult.getModRefInfo(CS1, CS2);
913 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
918 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
923 for (
auto &Getter : ResultGetters)
936 template <
typename AnalysisT>
937 static void getFunctionAAResultImpl(
Function &F,
940 AAResults.
addAAResult(AM.template getResult<AnalysisT>(F));
944 template <
typename AnalysisT>
946 AAResults &AAResults) {
948 auto &MAM = MAMProxy.getManager();
949 if (
auto *R = MAM.template getCachedResult<AnalysisT>(*F.getParent())) {
950 AAResults.addAAResult(*R);
952 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
960 std::unique_ptr<AAResults> AAR;
ModRefInfo getModRefInfo(const LoadInst *L, const Value *P, uint64_t Size)
getModRefInfo (for loads) - A convenience wrapper.
The two locations precisely alias each other.
const AAResults & getAAResults() const
static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
ModRefInfo getModRefInfo(const Instruction *I, const Value *P, uint64_t Size)
A convenience wrapper for constructing the memory location.
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, uint64_t Size, const ModRefInfo Mode)
A convenience wrapper synthesizing a memory location.
ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const Value *P, unsigned Size)
getModRefInfo (for atomicrmws) - A convenience wrapper.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
virtual ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)=0
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
An instruction for ordering other memory operations.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
aarch64 AArch64 CCMP Pass
bool isNoAlias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size)
A convenience wrapper around the isNoAlias helper interface.
The two locations alias, but only due to a partial overlap.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P, uint64_t Size)
getModRefInfo (for catchrets) - A convenience wrapper.
This class represents a function call, abstracting a target machine's calling convention.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
bool doesNotAccessMemory(const Function *F)
Checks if the specified function is known to never read or write memory.
void registerModuleAnalysis()
Register a specific AA result.
bool onlyReadsMemory(ImmutableCallSite CS)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
bool pointsToConstantMemory(const Value *P, bool OrLocal=false)
A convenience wrapper around the primary pointsToConstantMemory interface.
The two locations do not alias at all.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
An instruction for reading from memory.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
ModRefInfo getModRefInfo(const AtomicCmpXchgInst *CX, const Value *P, unsigned Size)
getModRefInfo (for cmpxchges) - A convenience wrapper.
ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P, uint64_t Size)
getModRefInfo (for catchpads) - A convenience wrapper.
The access modifies the value stored in memory.
The two locations may or may not alias. This is the least precise result.
This indicates that the function could not be classified into one of the behaviors above...
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
The only memory references in this function (if it has any) are references of memory that is otherwis...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
FunctionPass * createAAResultsWrapperPass()
static bool doesNotReadMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only write memory (or not access memory ...
bool isNoAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isNoAlias helper interface.
The only memory references in this function (if it has any) are non-volatile loads from objects point...
The access references the value stored in memory.
AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR)
A helper for the legacy pass manager to create a AAResults object populated to the best of our abilit...
The function may perform non-volatile loads and stores of objects pointed to by its pointer-typed arg...
virtual bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)=0
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
AAResults & getAAResults()
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
AliasResult alias(const Value *V1, const Value *V2)
A convenience wrapper around the primary alias interface.
virtual void setAAResults(AAResults *NewAAR)=0
An update API used internally by the AAResults to provide a handle back to the top level aggregation...
AliasResult alias(const Value *V1, uint64_t V1Size, const Value *V2, uint64_t V2Size)
A convenience wrapper around the primary alias interface.
ModRefInfo getModRefInfo(const InvokeInst *I, const Value *P, uint64_t Size)
getModRefInfo (for invokes) - A convenience wrapper.
Access to memory via argument pointers.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
ModRefInfo getModRefInfo(const FenceInst *S, const Value *P, uint64_t Size)
getModRefInfo (for fences) - A convenience wrapper.
AAResultBase(AAResultBase &&Arg)
An instruction for storing to memory.
void registerFunctionAnalysis()
Register a specific AA result.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A private abstract base class describing the concept of an individual alias analysis implementation...
static bool onlyReadsMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only read from non-volatile memory (or n...
ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P, uint64_t Size)
getModRefInfo (for va_args) - A convenience wrapper.
ModRefInfo getModRefInfo(const Instruction *I, const MemoryLocation &Loc)
Check whether or not an instruction may read or write the specified memory location.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events in the new pass manager.
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal=false)
Checks whether the given location points to constant memory, or if OrLocal is true whether it points ...
The access neither references nor modifies the value stored in memory.
ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
bool onlyReadsMemory(const Function *F)
Checks if the specified function is known to only read from non-volatile memory (or not access memory...
AAResultBase(const AAResultBase &Arg)
A set of analyses that are preserved following a run of a transformation pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM Basic Block Representation.
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const MemoryLocation &Loc, const ModRefInfo Mode)
Check if it is possible for the execution of the specified instructions to mod(according to the mode)...
A manager for alias analyses.
ModRefInfo getModRefInfo(const CallInst *C, const Value *P, uint64_t Size)
getModRefInfo (for calls) - A convenience wrapper.
A CRTP mix-in that provides informational APIs needed for analysis passes.
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Result run(Function &F, FunctionAnalysisManager &AM)
AliasResult
The possible results of an alias query.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
Return the behavior of the given call site.
Represent the analysis usage information of a pass.
void addAADependencyID(AnalysisKey *ID)
Register a function analysis ID that the results aggregation depends on.
static bool doesAccessArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from objects p...
The only memory references in this function (if it has any) are non-volatile loads and stores from ob...
FunctionPass class - This class is used to implement most global optimizations.
ModRefInfo getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2)
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
void getAAResultsAnalysisUsage(AnalysisUsage &AU)
A helper for the legacy pass manager to populate AU to add uses to make sure the analyses required by...
ModRefInfo getModRefInfo(const FenceInst *S, const MemoryLocation &Loc)
getModRefInfo (for fences) - Return information about whether a particular store modifies or reads th...
This function does not perform any non-local loads or stores to memory.
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
FunctionModRefLocation
The locations at which a function might access memory.
Representation for a specific memory location.
bool doesNotAccessMemory(ImmutableCallSite CS)
Checks if the specified call is known to never read or write memory.
Memory that is inaccessible via LLVM IR.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const Value *P, uint64_t Size)
getModRefInfo (for call sites) - A convenience wrapper.
ModRefInfo getModRefInfo(const InvokeInst *I, const MemoryLocation &Loc)
getModRefInfo (for invokes) - Return information about whether a particular invoke modifies or reads ...
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.
This function does not perform any non-local stores or volatile loads, but may read from any memory l...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
bool isMustAlias(const Value *V1, const Value *V2)
A convenience wrapper around the isMustAlias helper interface.
This proxy class models a common pattern where we delegate to either the top-level AAResults aggregat...
ModRefInfo callCapturesBefore(const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
Return information about whether a particular call site modifies or reads the specified memory locati...
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
virtual ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)=0
Get the ModRef info associated with a pointer argument of a callsite.
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
AAResults(const TargetLibraryInfo &TLI)
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
ModRefInfo getModRefInfo(const CallInst *C, const MemoryLocation &Loc)
getModRefInfo (for calls) - Return information about whether a particular call modifies or reads the ...
Base case is no access to memory.
This file provides utility analysis objects describing memory locations.
static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from memory th...
ImmutableCallSite - establish a view to a call site for examination.
The access both references and modifies the value stored in memory.
AAResultsProxy getBestAAResults()
Get a proxy for the best AA result set to query at this time.
virtual AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)=0
The main low level interface to the alias analysis implementation.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
ModRefInfo getModRefInfo(const StoreInst *S, const Value *P, uint64_t Size)
getModRefInfo (for stores) - A convenience wrapper.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
API to communicate dependencies between analyses during invalidation.
Analysis pass providing the TargetLibraryInfo.
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, uint64_t Size, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
A convenience wrapper to synthesize a memory location.
LLVM Value Representation.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
print Print MemDeps of function
FunctionModRefBehavior getModRefBehavior(const Function *F)
A container for analyses that lazily runs them and caches their results.
bool isNoAliasArgument(const Value *V)
Return true if this is an argument with the noalias attribute.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
This header defines various interfaces for pass management in LLVM.
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, uint64_t Size)
A convenience wrapper synthesizing a memory location.
bool canBasicBlockModify(const BasicBlock &BB, const MemoryLocation &Loc)
Check if it is possible for execution of the specified basic block to modify the location Loc...
ModRefInfo getModRefInfo(const Instruction *I)
Check whether or not an instruction may read or write memory (without regard to a specific location)...
A special type used by analysis passes to provide an address that identifies that particular analysis...
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a callsite.
ModRefInfo getModRefInfo(ImmutableCallSite CS1, ImmutableCallSite CS2)
virtual FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)=0
Return the behavior of the given call site.
FunctionModRefBehavior getModRefBehavior(const Function *F)