38 #ifndef LLVM_ANALYSIS_ALIASANALYSIS_H 39 #define LLVM_ANALYSIS_ALIASANALYSIS_H 63 class OrderedBasicBlock;
189 return ModRefInfo(static_cast<int>(MRI1) | static_cast<int>(MRI2));
193 return ModRefInfo(static_cast<int>(MRI1) & static_cast<int>(MRI2));
299 template <
typename AAResultT>
void addAAResult(AAResultT &AAResult) {
303 AAs.emplace_back(
new Model<AAResultT>(AAResult, *
this));
345 return alias(LocA, LocB) ==
NoAlias;
372 bool pointsToConstantMemory(
const MemoryLocation &Loc,
bool OrLocal =
false);
438 return onlyReadsMemory(getModRefBehavior(CS));
451 return onlyReadsMemory(getModRefBehavior(F));
628 if (OptLoc ==
None) {
637 case Instruction::VAArg:
return getModRefInfo((
const VAArgInst*)I, Loc);
640 case Instruction::Fence:
return getModRefInfo((
const FenceInst*)I, Loc);
641 case Instruction::AtomicCmpXchg:
643 case Instruction::AtomicRMW:
646 case Instruction::Invoke:
return getModRefInfo((
const InvokeInst*)I,Loc);
647 case Instruction::CatchPad:
649 case Instruction::CatchRet:
716 return canInstructionRangeModRef(I1, I2,
MemoryLocation(Ptr, Size), Mode);
728 std::vector<std::unique_ptr<Concept>> AAs;
730 std::vector<AnalysisKey *> AADeps;
752 virtual void setAAResults(
AAResults *NewAAR) = 0;
781 unsigned ArgIdx) = 0;
813 explicit Model(AAResultT &Result,
AAResults &AAR) : Result(Result) {
814 Result.setAAResults(&AAR);
816 ~
Model()
override =
default;
818 void setAAResults(
AAResults *NewAAR)
override { Result.setAAResults(NewAAR); }
822 return Result.alias(LocA, LocB);
826 bool OrLocal)
override {
827 return Result.pointsToConstantMemory(Loc, OrLocal);
831 return Result.getArgModRefInfo(CS, ArgIdx);
835 return Result.getModRefBehavior(CS);
839 return Result.getModRefBehavior(F);
844 return Result.getModRefInfo(CS, Loc);
849 return Result.getModRefInfo(CS1, CS2);
877 DerivedT &derived() {
return static_cast<DerivedT &
>(*this); }
881 void setAAResults(
AAResults *NewAAR) { AAR = NewAAR; }
889 DerivedT &CurrentResult;
893 : AAR(AAR), CurrentResult(CurrentResult) {}
896 return AAR ? AAR->
alias(LocA, LocB) : CurrentResult.alias(LocA, LocB);
901 : CurrentResult.pointsToConstantMemory(Loc, OrLocal);
905 return AAR ? AAR->
getArgModRefInfo(CS, ArgIdx) : CurrentResult.getArgModRefInfo(CS, ArgIdx);
918 : CurrentResult.getModRefInfo(CS, Loc);
922 return AAR ? AAR->
getModRefInfo(CS1, CS2) : CurrentResult.getModRefInfo(CS1, CS2);
1015 ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
1020 ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
1025 for (
auto &Getter : ResultGetters)
1026 (*Getter)(
F, AM, R);
1039 template <
typename AnalysisT>
1040 static void getFunctionAAResultImpl(
Function &F,
1043 AAResults.
addAAResult(AM.template getResult<AnalysisT>(F));
1047 template <
typename AnalysisT>
1049 AAResults &AAResults) {
1051 auto &MAM = MAMProxy.getManager();
1052 if (
auto *R = MAM.template getCachedResult<AnalysisT>(*F.
getParent())) {
1055 .template registerOuterAnalysisInvalidation<AnalysisT, AAManager>();
1063 std::unique_ptr<AAResults> AAR;
1105 #endif // LLVM_ANALYSIS_ALIASANALYSIS_H The access may reference and may modify the value stored in memory.
Pass interface - Implemented by all 'passes'.
LLVM_NODISCARD ModRefInfo unionModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P, LocationSize Size)
getModRefInfo (for catchrets) - A convenience wrapper.
static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
The access neither references nor modifies the value stored in memory.
LLVM_NODISCARD ModRefInfo clearMust(const ModRefInfo MRI)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Compute iterated dominance frontiers using a linear time algorithm.
ModRefInfo getModRefInfo(const AtomicRMWInst *RMW, const Value *P, unsigned Size)
getModRefInfo (for atomicrmws) - A convenience wrapper.
ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P, LocationSize Size)
getModRefInfo (for catchpads) - A convenience wrapper.
AAResultsProxy(AAResults *AAR, DerivedT &CurrentResult)
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.
ModRefInfo callCapturesBefore(const Instruction *I, const Value *P, LocationSize Size, DominatorTree *DT, OrderedBasicBlock *OBB=nullptr)
A convenience wrapper to synthesize a memory location.
ModRefInfo getModRefInfo(const FenceInst *S, const Value *P, LocationSize Size)
getModRefInfo (for fences) - A convenience wrapper.
ModRefInfo getModRefInfo(const StoreInst *S, const Value *P, LocationSize Size)
getModRefInfo (for stores) - A convenience wrapper.
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)
bool canInstructionRangeModRef(const Instruction &I1, const Instruction &I2, const Value *Ptr, LocationSize Size, const ModRefInfo Mode)
A convenience wrapper synthesizing a memory location.
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
This class represents a function call, abstracting a target machine's calling convention.
The two locations do not alias at all.
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.
const AAResults & getAAResults() const
This is the AA result object for the basic, local, and stateless alias analysis.
bool onlyReadsMemory(ImmutableCallSite CS)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
#define LLVM_NODISCARD
LLVM_NODISCARD - Warn if a type or return value is discarded.
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.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
An instruction for reading from memory.
bool canBasicBlockModify(const BasicBlock &BB, const Value *P, LocationSize Size)
A convenience wrapper synthesizing a memory location.
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.
LLVM_NODISCARD bool isModAndRefSet(const ModRefInfo MRI)
ModRefInfo getModRefInfo(const Instruction *I, const Optional< MemoryLocation > &OptLoc)
Check whether or not an instruction may read or write the optionally specified memory location...
This indicates that the function could not be classified into one of the behaviors above...
LLVM_NODISCARD ModRefInfo clearMod(const ModRefInfo MRI)
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...
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.
LLVM_NODISCARD ModRefInfo clearRef(const ModRefInfo MRI)
Must is provided for completeness, but no routines will return only Must today.
The access may reference the value stored in memory, a mustAlias relation was found, and no mayAlias or partialAlias found.
The access may reference the value stored in memory.
The only memory references in this function (if it has any) are non-volatile loads from objects point...
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...
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.
LLVM_NODISCARD ModRefInfo setRef(const ModRefInfo MRI)
LLVM_NODISCARD bool isMustSet(const ModRefInfo MRI)
ModRefInfo getModRefInfo(const LoadInst *L, const Value *P, LocationSize Size)
getModRefInfo (for loads) - A convenience wrapper.
Access to memory via argument pointers.
The access may reference, modify or both the value stored in memory, a mustAlias relation was found...
FunctionModRefBehavior
Summary of how a function affects memory in the program.
The access may modify the value stored in memory, a mustAlias relation was found, and no mayAlias or ...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
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...
AliasResult
The possible results of an alias query.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
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 ...
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...
static bool runOnFunction(Function &F, bool PostInlining)
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)
LLVM_NODISCARD ModRefInfo setMust(const ModRefInfo MRI)
A set of analyses that are preserved following a run of a transformation pass.
unsigned const MachineRegisterInfo * MRI
LLVM Basic Block Representation.
AliasResult alias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the primary alias interface.
A manager for alias analyses.
A CRTP mix-in that provides informational APIs needed for analysis passes.
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
ModRefInfo getModRefInfo(const VAArgInst *I, const Value *P, LocationSize Size)
getModRefInfo (for va_args) - A convenience wrapper.
Result run(Function &F, FunctionAnalysisManager &AM)
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(const InvokeInst *I, const Value *P, LocationSize Size)
getModRefInfo (for invokes) - A convenience wrapper.
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...
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.
The two locations may or may not alias. This is the least precise result.
FunctionModRefLocation
The locations at which a function might access memory.
Representation for a specific memory location.
The two locations precisely alias each other.
bool doesNotAccessMemory(ImmutableCallSite CS)
Checks if the specified call is known to never read or write memory.
ImmutablePass class - This class is used to provide information that does not need to be run...
Memory that is inaccessible via LLVM IR.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
LLVM_NODISCARD ModRefInfo setMod(const ModRefInfo MRI)
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...
ModRefInfo getModRefInfo(const CallInst *C, const Value *P, LocationSize Size)
getModRefInfo (for calls) - A convenience wrapper.
The access may modify the value stored in memory.
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 getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
LLVM_NODISCARD bool isNoModRef(const ModRefInfo MRI)
bool isMustAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are must-alias.
amdgpu Simplify well known AMD library false Value Value * Arg
AAResults(const TargetLibraryInfo &TLI)
LLVM_NODISCARD bool isModSet(const ModRefInfo MRI)
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...
Establish a view to a call site for examination.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const Value *P, LocationSize Size)
getModRefInfo (for call sites) - A convenience wrapper.
LLVM_NODISCARD ModRefInfo intersectModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
AAResultsProxy getBestAAResults()
Get a proxy for the best AA result set to query at this time.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
API to communicate dependencies between analyses during invalidation.
Analysis pass providing the TargetLibraryInfo.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
LLVM_NODISCARD ModRefInfo createModRefInfo(const FunctionModRefBehavior FMRB)
This class implements an extremely fast bulk output stream that can only output to a stream...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
LLVM_NODISCARD ModRefInfo setModAndRef(const ModRefInfo MRI)
print Print MemDeps of function
FunctionModRefBehavior getModRefBehavior(const Function *F)
bool isNoAlias(const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size)
A convenience wrapper around the isNoAlias helper interface.
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.
LLVM_NODISCARD bool isModOrRefSet(const ModRefInfo MRI)
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.
The two locations alias, but only due to a partial overlap.
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)
FunctionModRefBehavior getModRefBehavior(const Function *F)
ModRefInfo getModRefInfo(const Instruction *I, const Value *P, LocationSize Size)
A convenience wrapper for constructing the memory location.
LLVM_NODISCARD bool isRefSet(const ModRefInfo MRI)