57 : TLI(Arg.TLI), AAs(std::move(Arg.AAs)), AADeps(std::move(Arg.AADeps)) {
59 AA->setAAResults(
this);
69 AA->setAAResults(
nullptr);
95 for (
const auto &AA : AAs) {
96 auto Result = AA->alias(LocA, LocB);
105 for (
const auto &AA : AAs)
106 if (AA->pointsToConstantMemory(Loc, OrLocal))
115 for (
const auto &AA : AAs) {
116 Result =
ModRefInfo(Result & AA->getArgModRefInfo(CS, ArgIdx));
150 for (
const auto &AA : AAs) {
151 Result =
ModRefInfo(Result & AA->getModRefInfo(CS, Loc));
171 bool DoesAlias =
false;
175 const Value *Arg = *AI;
178 unsigned ArgIdx = std::distance(CS.
arg_begin(), AI);
184 AllArgsMask =
ModRefInfo(AllArgsMask | ArgMask);
195 if ((Result & MRI_Mod) &&
206 for (
const auto &AA : AAs) {
207 Result =
ModRefInfo(Result & AA->getModRefInfo(CS1, CS2));
247 unsigned CS2ArgIdx = std::distance(CS2.
arg_begin(),
I);
253 if (ArgMask == MRI_Mod)
255 else if (ArgMask == MRI_Ref)
277 unsigned CS1ArgIdx = std::distance(CS1.
arg_begin(),
I);
304 for (
const auto &AA : AAs) {
318 for (
const auto &AA : AAs) {
456 const Value *Object =
459 isa<Constant>(Object))
475 CI != CE; ++CI, ++ArgNo) {
479 if (!(*CI)->getType()->isPointerTy() ||
519 "Instructions not in same basic block!");
540 typedef std::function<void(Pass &, Function &, AAResults &)> CallbackT;
549 explicit ExternalAAWrapperPass(CallbackT CB)
566 return new ExternalAAWrapperPass(std::move(Callback));
576 "Function Alias Analysis Results",
false,
true)
590 return new AAResultsWrapperPass();
609 new AAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI()));
616 AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
619 if (
auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
620 AAR->addAAResult(WrapperPass->getResult());
621 if (
auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
622 AAR->addAAResult(WrapperPass->getResult());
623 if (
auto *WrapperPass =
624 getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
625 AAR->addAAResult(WrapperPass->getResult());
626 if (
auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
627 AAR->addAAResult(WrapperPass->getResult());
628 if (
auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
629 AAR->addAAResult(WrapperPass->getResult());
630 if (
auto *WrapperPass = getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
631 AAR->addAAResult(WrapperPass->getResult());
632 if (
auto *WrapperPass = getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
633 AAR->addAAResult(WrapperPass->getResult());
637 if (
auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
639 WrapperPass->CB(*
this, F, *AAR);
672 if (
auto *WrapperPass =
674 AAR.addAAResult(WrapperPass->getResult());
676 AAR.addAAResult(WrapperPass->getResult());
677 if (
auto *WrapperPass =
679 AAR.addAAResult(WrapperPass->getResult());
681 AAR.addAAResult(WrapperPass->getResult());
683 AAR.addAAResult(WrapperPass->getResult());
685 AAR.addAAResult(WrapperPass->getResult());
697 if (
const Argument *
A = dyn_cast<Argument>(V))
698 return A->hasNoAliasAttr();
703 if (isa<AllocaInst>(V))
705 if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
709 if (
const Argument *
A = dyn_cast<Argument>(V))
710 return A->hasNoAliasAttr() ||
A->hasByValAttr();
Legacy wrapper pass to provide the GlobalsAAResult object.
Pass interface - Implemented by all 'passes'.
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM Argument representation.
const Instruction & back() const
bool isFenceLike() const
Return true if this instruction behaves like a memory fence: it can load or store to memory location ...
This is the interface for LLVM's inclusion-based alias analysis implemented with CFL graph reachabili...
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
This is the interface for a simple mod/ref and alias analysis over globals.
AtomicOrdering getSuccessOrdering() const
Returns the ordering constraint on this cmpxchg.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias. ...
This is the interface for a metadata-based scoped no-alias analysis.
Function Alias Analysis Results
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 ...
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
INITIALIZE_PASS_BEGIN(AAResultsWrapperPass,"aa","Function Alias Analysis Results", false, true) INITIALIZE_PASS_END(AAResultsWrapperPass
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
const Instruction & front() const
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.
void initializeExternalAAWrapperPassPass(PassRegistry &)
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...
Legacy wrapper pass to provide the TypeBasedAAResult object.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
AnalysisUsage & addRequired()
The only memory references in this function (if it has any) are references of memory that is otherwis...
#define INITIALIZE_PASS_DEPENDENCY(depName)
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
This is the interface for a SCEV-based alias analysis.
FunctionPass * createAAResultsWrapperPass()
static bool doesNotReadMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only write memory (or not access memory ...
TargetLibraryInfo & getTLI()
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
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...
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
void initializeAAResultsWrapperPassPass(PassRegistry &)
IterTy data_operands_begin() const
data_operands_begin/data_operands_end - Return iterators iterating over the call / invoke argument li...
AtomicOrdering getOrdering() const
Returns the ordering constraint on this RMW.
FunctionModRefBehavior
Summary of how a function affects memory in the program.
Function Alias Analysis false
bool runOnFunction(Function &F) override
Run the wrapper pass to rebuild an aggregation over known AA passes.
Legacy wrapper pass to provide the CFLSteensAAResult object.
An instruction for storing to memory.
static cl::opt< bool > DisableBasicAA("disable-basicaa", cl::Hidden, cl::init(false))
Allow disabling BasicAA from the AA results.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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...
Legacy wrapper pass to provide the ScopedNoAliasAAResult object.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
This is the interface for LLVM's unification-based alias analysis implemented with CFL graph reachabi...
initializer< Ty > init(const Ty &Val)
A set of analyses that are preserved following a run of a transformation pass.
This is the interface for a metadata-based TBAA.
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.
Legacy wrapper pass to provide the CFLAndersAAResult object.
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.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
static bool doesAccessArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from objects p...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
bool isPointerTy() const
True if this is an instance of PointerType.
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...
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value...
This file declares a simple ARC-aware AliasAnalysis using special knowledge of Objective C to enhance...
This function does not perform any non-local loads or stores to memory.
static MemoryLocation getForArgument(ImmutableCallSite CS, unsigned ArgIdx, const TargetLibraryInfo &TLI)
Return a location representing a particular argument of a call.
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
bool doesNotAccessMemory() const
Determine if the call does not access memory.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
Iterator for intrusive lists based on ilist_node.
Legacy wrapper pass to provide the SCEVAAResult object.
ImmutablePass class - This class is used to provide information that does not need to be run...
InstrTy * getInstruction() const
static bool isStrongerThanMonotonic(AtomicOrdering ao)
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Type * getType() const
All values are typed, get the type of this value.
unsigned getNumArgOperands() const
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 ...
void setPreservesAll()
Set by analyses that do not transform their input at all.
AAResults(const TargetLibraryInfo &TLI)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from objects poin...
block Block Frequency Analysis
INITIALIZE_PASS(ExternalAAWrapperPass,"external-aa","External Alias Analysis", false, true) ImmutablePass *llvm
ImmutableCallSite - establish a view to a call site for examination.
The access both references and modifies the value stored in memory.
API to communicate dependencies between analyses during invalidation.
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, DominatorTree *DT, bool IncludeI=false, OrderedBasicBlock *OBB=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This templated class represents "all analyses that operate over \<a particular IR unit\>" (e...
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
LLVM Value Representation.
Legacy wrapper pass to provide the ObjCARCAAResult object.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This is the interface for LLVM's primary stateless and local alias analysis.
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...
IterTy data_operands_end() const
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
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...
A special type used by analysis passes to provide an address that identifies that particular analysis...
const BasicBlock * getParent() const
ModRefInfo getArgModRefInfo(ImmutableCallSite CS, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a callsite.
Legacy wrapper pass to provide the BasicAAResult object.