65 : TLI(
Arg.TLI), AAs(
std::move(
Arg.AAs)), AADeps(
std::move(
Arg.AADeps)) {
67 AA->setAAResults(
this);
77 AA->setAAResults(
nullptr);
103 for (
const auto &AA : AAs) {
104 auto Result = AA->alias(LocA, LocB);
113 for (
const auto &AA : AAs)
114 if (AA->pointsToConstantMemory(Loc, OrLocal))
123 for (
const auto &AA : AAs) {
136 if (
const auto *Call1 = dyn_cast<CallBase>(I)) {
159 for (
const auto &AA : AAs) {
180 bool IsMustAlias =
true;
187 unsigned ArgIdx = std::distance(Call->
arg_begin(), AI);
220 for (
const auto &AA : AAs) {
258 bool IsMustAlias =
true;
263 unsigned Call2ArgIdx = std::distance(Call2->
arg_begin(),
I);
309 bool IsMustAlias =
true;
314 unsigned Call1ArgIdx = std::distance(Call1->
arg_begin(),
I);
351 for (
const auto &AA : AAs) {
365 for (
const auto &AA : AAs) {
388 OS <<
"PartialAlias";
558 const Value *Object =
561 isa<Constant>(Object))
565 if (!Call || Call == Object)
576 bool IsMustAlias =
true;
578 for (
auto CI = Call->data_operands_begin(), CE = Call->data_operands_end();
579 CI != CE; ++CI, ++ArgNo) {
583 if (!(*CI)->getType()->isPointerTy() ||
584 (!Call->doesNotCapture(ArgNo) && ArgNo < Call->getNumArgOperands() &&
585 !Call->isByValArgument(ArgNo)))
597 if (Call->doesNotAccessMemory(ArgNo))
599 if (Call->onlyReadsMemory(ArgNo)) {
627 "Instructions not in same basic block!");
666 "Function Alias Analysis Results",
false,
true)
699 new AAResults(getAnalysis<TargetLibraryInfoWrapperPass>().getTLI()));
706 AAR->addAAResult(getAnalysis<BasicAAWrapperPass>().getResult());
709 if (
auto *WrapperPass = getAnalysisIfAvailable<ScopedNoAliasAAWrapperPass>())
710 AAR->addAAResult(WrapperPass->getResult());
711 if (
auto *WrapperPass = getAnalysisIfAvailable<TypeBasedAAWrapperPass>())
712 AAR->addAAResult(WrapperPass->getResult());
713 if (
auto *WrapperPass =
714 getAnalysisIfAvailable<objcarc::ObjCARCAAWrapperPass>())
715 AAR->addAAResult(WrapperPass->getResult());
716 if (
auto *WrapperPass = getAnalysisIfAvailable<GlobalsAAWrapperPass>())
717 AAR->addAAResult(WrapperPass->getResult());
718 if (
auto *WrapperPass = getAnalysisIfAvailable<SCEVAAWrapperPass>())
719 AAR->addAAResult(WrapperPass->getResult());
720 if (
auto *WrapperPass = getAnalysisIfAvailable<CFLAndersAAWrapperPass>())
721 AAR->addAAResult(WrapperPass->getResult());
722 if (
auto *WrapperPass = getAnalysisIfAvailable<CFLSteensAAWrapperPass>())
723 AAR->addAAResult(WrapperPass->getResult());
727 if (
auto *WrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>())
729 WrapperPass->CB(*
this, F, *AAR);
759 AAR.addAAResult(BAR);
762 if (
auto *WrapperPass =
764 AAR.addAAResult(WrapperPass->getResult());
766 AAR.addAAResult(WrapperPass->getResult());
767 if (
auto *WrapperPass =
769 AAR.addAAResult(WrapperPass->getResult());
771 AAR.addAAResult(WrapperPass->getResult());
773 AAR.addAAResult(WrapperPass->getResult());
775 AAR.addAAResult(WrapperPass->getResult());
781 if (
const auto *Call = dyn_cast<CallBase>(V))
787 if (
const Argument *A = dyn_cast<Argument>(V))
788 return A->hasNoAliasAttr();
793 if (isa<AllocaInst>(V))
795 if (isa<GlobalValue>(V) && !isa<GlobalAlias>(V))
799 if (
const Argument *A = dyn_cast<Argument>(V))
800 return A->hasNoAliasAttr() || A->hasByValAttr();
Legacy wrapper pass to provide the GlobalsAAResult object.
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)
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
The access neither references nor modifies the value stored in memory.
LLVM_NODISCARD ModRefInfo clearMust(const ModRefInfo MRI)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents an incoming formal argument to a Function.
Atomic ordering constants.
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...
This class represents lattice values for constants.
This is the interface for a simple mod/ref and alias analysis over globals.
An instruction for ordering other memory operations.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
This is the interface for a metadata-based scoped no-alias analysis.
The two locations do not alias at all.
INITIALIZE_PASS(ExternalAAWrapperPass, "external-aa", "External Alias Analysis", false, true) ImmutablePass *llvm
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Function Alias Analysis Results
This is the AA result object for the basic, local, and stateless alias analysis.
static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to read and write at most from memory that ...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
block Block Frequency true
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.
This indicates that the function could not be classified into one of the behaviors above...
Legacy wrapper pass to provide the TypeBasedAAResult object.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
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.
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)
This is the interface for a SCEV-based alias analysis.
FunctionPass * createAAResultsWrapperPass()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static bool doesNotReadMemory(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to only write memory (or not access memory ...
TargetLibraryInfo & getTLI()
bool isStrongerThan(AtomicOrdering ao, AtomicOrdering other)
Returns true if ao is stronger than other as defined by the AtomicOrdering lattice, which is based on C++'s definition.
LLVM_NODISCARD ModRefInfo clearRef(const ModRefInfo MRI)
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.
This file contains the simple types necessary to represent the attributes associated with functions a...
static MemoryLocation getForArgument(const CallBase *Call, unsigned ArgIdx, const TargetLibraryInfo *TLI)
Return a location representing a particular argument of a call.
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 &)
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Return the behavior of the given call site.
LLVM_NODISCARD bool isMustSet(const ModRefInfo MRI)
Type * getType() const
All values are typed, get the type of this value.
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
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 ...
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.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, OrderedBasicBlock *OBB=nullptr, unsigned MaxUsesToExplore=DefaultMaxUsesToExplore)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
static cl::opt< bool > DisableBasicAA("disable-basicaa", cl::Hidden, cl::init(false))
Allow disabling BasicAA from the AA results.
bool isStrongerThanMonotonic(AtomicOrdering ao)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
AliasResult
The possible results of an alias query.
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 ...
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)
LLVM_NODISCARD ModRefInfo setMust(const ModRefInfo MRI)
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)...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isPointerTy() const
True if this is an instance of PointerType.
const Instruction & front() const
A manager for alias analyses.
Legacy wrapper pass to provide the CFLAndersAAResult object.
Represent the analysis usage information of a pass.
const Instruction & back() const
static bool doesAccessArgPointees(FunctionModRefBehavior MRB)
Checks if functions with the specified behavior are known to potentially read or write from objects p...
FunctionPass class - This class is used to implement most global optimizations.
self_iterator getIterator()
bool onlyReadsMemory(const CallBase *Call)
Checks if the specified call is known to only read from non-volatile memory (or not access memory at ...
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
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...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
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.
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.
const Value * Ptr
The address of the start of the location.
Representation for a specific memory location.
The two locations precisely alias each other.
Iterator for intrusive lists based on ilist_node.
INITIALIZE_PASS_BEGIN(AAResultsWrapperPass, "aa", "Function Alias Analysis Results", false, true) INITIALIZE_PASS_END(AAResultsWrapperPass
Legacy wrapper pass to provide the SCEVAAResult object.
ImmutablePass class - This class is used to provide information that does not need to be run...
Module.h This file contains the declarations for the Module class.
The access may modify the value stored in memory.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
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...
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM_NODISCARD bool isNoModRef(const ModRefInfo MRI)
amdgpu Simplify well known AMD library false Value Value * Arg
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
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...
block Block Frequency Analysis
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
This file provides utility analysis objects describing memory locations.
LLVM_NODISCARD ModRefInfo intersectModRef(const ModRefInfo MRI1, const ModRefInfo MRI2)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
API to communicate dependencies between analyses during invalidation.
ModRefInfo getArgModRefInfo(const CallBase *Call, unsigned ArgIdx)
Get the ModRef info associated with a pointer argument of a call.
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.
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This class implements an extremely fast bulk output stream that can only output to a stream...
A wrapper pass for external alias analyses.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
LLVM_NODISCARD ModRefInfo setModAndRef(const ModRefInfo MRI)
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.
LLVM_NODISCARD bool isModOrRefSet(const ModRefInfo MRI)
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
getModRefInfo (for call sites) - Return information about whether a particular call site modifies or ...
The two locations alias, but only due to a partial overlap.
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
Legacy wrapper pass to provide the BasicAAResult object.
LLVM_NODISCARD bool isRefSet(const ModRefInfo MRI)