LLVM 22.0.0git
|
#include "llvm/Analysis/AliasAnalysis.h"
Classes | |
class | Concept |
A private abstract base class describing the concept of an individual alias analysis implementation. More... |
Public Member Functions | |
LLVM_ABI | AAResults (const TargetLibraryInfo &TLI) |
LLVM_ABI | AAResults (AAResults &&Arg) |
LLVM_ABI | ~AAResults () |
template<typename AAResultT> | |
void | addAAResult (AAResultT &AAResult) |
Register a specific AA result. | |
void | addAADependencyID (AnalysisKey *ID) |
Register a function analysis ID that the results aggregation depends on. | |
LLVM_ABI bool | invalidate (Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv) |
Handle invalidation events in the new pass manager. | |
Alias Queries | |
LLVM_ABI AliasResult | alias (const MemoryLocation &LocA, const MemoryLocation &LocB) |
The main low level interface to the alias analysis implementation. | |
AliasResult | alias (const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size) |
A convenience wrapper around the primary alias interface. | |
AliasResult | alias (const Value *V1, const Value *V2) |
A convenience wrapper around the primary alias interface. | |
bool | isNoAlias (const MemoryLocation &LocA, const MemoryLocation &LocB) |
A trivial helper function to check to see if the specified pointers are no-alias. | |
bool | isNoAlias (const Value *V1, LocationSize V1Size, const Value *V2, LocationSize V2Size) |
A convenience wrapper around the isNoAlias helper interface. | |
bool | isNoAlias (const Value *V1, const Value *V2) |
A convenience wrapper around the isNoAlias helper interface. | |
bool | isMustAlias (const MemoryLocation &LocA, const MemoryLocation &LocB) |
A trivial helper function to check to see if the specified pointers are must-alias. | |
bool | isMustAlias (const Value *V1, const Value *V2) |
A convenience wrapper around the isMustAlias helper interface. | |
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 to a local alloca. | |
bool | pointsToConstantMemory (const Value *P, bool OrLocal=false) |
A convenience wrapper around the primary pointsToConstantMemory interface. | |
Simple mod/ref information | |
LLVM_ABI ModRefInfo | getModRefInfoMask (const MemoryLocation &Loc, bool IgnoreLocals=false) |
Returns a bitmask that should be unconditionally applied to the ModRef info of a memory location. | |
ModRefInfo | getModRefInfoMask (const Value *P, bool IgnoreLocals=false) |
A convenience wrapper around the primary getModRefInfoMask interface. | |
LLVM_ABI ModRefInfo | getArgModRefInfo (const CallBase *Call, unsigned ArgIdx) |
Get the ModRef info associated with a pointer argument of a call. | |
LLVM_ABI MemoryEffects | getMemoryEffects (const CallBase *Call) |
Return the behavior of the given call site. | |
LLVM_ABI MemoryEffects | getMemoryEffects (const Function *F) |
Return the behavior when calling the given function. | |
bool | doesNotAccessMemory (const CallBase *Call) |
Checks if the specified call is known to never read or write memory. | |
bool | doesNotAccessMemory (const Function *F) |
Checks if the specified function is known to never read or write memory. | |
bool | onlyReadsMemory (const CallBase *Call) |
Checks if the specified call is known to only read from non-volatile memory (or not access memory at all). | |
bool | onlyReadsMemory (const Function *F) |
Checks if the specified function is known to only read from non-volatile memory (or not access memory at all). | |
ModRefInfo | getModRefInfo (const Instruction *I, const std::optional< MemoryLocation > &OptLoc) |
Check whether or not an instruction may read or write the optionally specified memory location. | |
ModRefInfo | getModRefInfo (const Instruction *I, const Value *P, LocationSize Size) |
A convenience wrapper for constructing the memory location. | |
LLVM_ABI ModRefInfo | getModRefInfo (const Instruction *I, const CallBase *Call) |
Return information about whether a call and an instruction may refer to the same memory locations. | |
LLVM_ABI ModRefInfo | getModRefInfo (const Instruction *I1, const Instruction *I2) |
Return information about whether two instructions may refer to the same memory locations. | |
ModRefInfo | callCapturesBefore (const Instruction *I, const MemoryLocation &MemLoc, DominatorTree *DT) |
Return information about whether a particular call site modifies or reads the specified memory location MemLoc before instruction I in a BasicBlock. | |
ModRefInfo | callCapturesBefore (const Instruction *I, const Value *P, LocationSize Size, DominatorTree *DT) |
A convenience wrapper to synthesize a memory location. |
Definition at line 318 of file AliasAnalysis.h.
AAResults::AAResults | ( | const TargetLibraryInfo & | TLI | ) |
Definition at line 73 of file AliasAnalysis.cpp.
Referenced by AAResults().
AAResults::AAResults | ( | AAResults && | Arg | ) |
Definition at line 75 of file AliasAnalysis.cpp.
References AAResults(), and llvm::move().
AAResults::~AAResults | ( | ) |
Definition at line 78 of file AliasAnalysis.cpp.
|
inline |
Register a function analysis ID that the results aggregation depends on.
This is used in the new pass manager to implement the invalidation logic where we must invalidate the results aggregation if any of our component analyses become invalid.
Definition at line 339 of file AliasAnalysis.h.
|
inline |
Register a specific AA result.
Definition at line 327 of file AliasAnalysis.h.
Referenced by llvm::AMDGPUPassConfig::addIRPasses().
AliasResult AAResults::alias | ( | const MemoryLocation & | LocA, |
const MemoryLocation & | LocB ) |
The main low level interface to the alias analysis implementation.
Returns an AliasResult indicating whether the two pointers are aliased to each other. This is the interface that must be implemented by specific alias analysis implementations.
Definition at line 104 of file AliasAnalysis.cpp.
References alias().
Referenced by alias(), alias(), alias(), callCapturesBefore(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), llvm::BasicAAResult::getModRefInfo(), isMustAlias(), isMustAlias(), and isNoAlias().
AliasResult AAResults::alias | ( | const MemoryLocation & | LocA, |
const MemoryLocation & | LocB, | ||
AAQueryInfo & | AAQI, | ||
const Instruction * | CtxI = nullptr ) |
Definition at line 110 of file AliasAnalysis.cpp.
References assert(), llvm::dbgs(), llvm::AAQueryInfo::Depth, EnableAATrace, llvm::Value::getType(), I, llvm::Type::isPointerTy(), llvm::AliasResult::MayAlias, llvm::AliasResult::MustAlias, llvm::AliasResult::NoAlias, llvm::MemoryLocation::Ptr, and llvm::MemoryLocation::Size.
|
inline |
A convenience wrapper around the primary alias
interface.
Definition at line 366 of file AliasAnalysis.h.
References alias(), and llvm::MemoryLocation::getBeforeOrAfter().
|
inline |
A convenience wrapper around the primary alias
interface.
Definition at line 360 of file AliasAnalysis.h.
References alias().
AliasResult AAResults::aliasErrno | ( | const MemoryLocation & | Loc, |
const Module * | M ) |
Definition at line 151 of file AliasAnalysis.cpp.
References llvm::AliasResult::MayAlias.
Referenced by llvm::BasicAAResult::getModRefInfo().
|
inline |
Return information about whether a particular call site modifies or reads the specified memory location MemLoc
before instruction I
in a BasicBlock.
Definition at line 537 of file AliasAnalysis.h.
References callCapturesBefore(), and I.
Referenced by callCapturesBefore(), and callCapturesBefore().
ModRefInfo AAResults::callCapturesBefore | ( | const Instruction * | I, |
const MemoryLocation & | MemLoc, | ||
DominatorTree * | DT, | ||
AAQueryInfo & | AAQI ) |
Return information about whether a particular call site modifies or reads the specified memory location MemLoc
before instruction I
in a BasicBlock.
FIXME: this is really just shoring-up a deficiency in alias analysis. BasicAA isn't willing to spend linear time determining whether an alloca was captured before or after this particular call, while we are. However, with a smarter AA in place, this test is just wasting compile time.
Definition at line 613 of file AliasAnalysis.cpp.
References alias(), Call, llvm::capturesAnyProvenance(), llvm::capturesAnything(), llvm::dyn_cast(), llvm::MemoryLocation::getBeforeOrAfter(), llvm::CaptureInfo::getOtherComponents(), llvm::getUnderlyingObject(), I, llvm::isIdentifiedFunctionLocal(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, llvm::PointerMayBeCapturedBefore(), llvm::Provenance, llvm::MemoryLocation::Ptr, and llvm::Ref.
|
inline |
A convenience wrapper to synthesize a memory location.
Definition at line 545 of file AliasAnalysis.h.
References callCapturesBefore(), I, P, and Size.
bool AAResults::canBasicBlockModify | ( | const BasicBlock & | BB, |
const MemoryLocation & | Loc ) |
Check if it is possible for execution of the specified basic block to modify the location Loc.
canBasicBlockModify - Return true if it is possible for execution of the specified basic block to modify the location Loc.
Definition at line 674 of file AliasAnalysis.cpp.
References llvm::BasicBlock::back(), canInstructionRangeModRef(), llvm::BasicBlock::front(), and llvm::Mod.
Referenced by canBasicBlockModify(), and findArgParts().
|
inline |
A convenience wrapper synthesizing a memory location.
Definition at line 561 of file AliasAnalysis.h.
References canBasicBlockModify(), P, and Size.
bool AAResults::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) the location Loc.
canInstructionRangeModRef - Return true if it is possible for the execution of the specified instructions to mod(according to the mode) the location Loc.
The instructions to consider are all of the instructions in the range of [I1,I2] INCLUSIVE. I1 and I2 must be in the same basic block.
Definition at line 684 of file AliasAnalysis.cpp.
References assert(), llvm::ilist_node_impl< OptionsT >::getIterator(), getModRefInfo(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), I, and llvm::isModOrRefSet().
Referenced by canBasicBlockModify(), canInstructionRangeModRef(), and findArgParts().
|
inline |
A convenience wrapper synthesizing a memory location.
Definition at line 577 of file AliasAnalysis.h.
References canInstructionRangeModRef(), Mode, Ptr, and Size.
Checks if the specified call is known to never read or write memory.
Note that if the call only reads from known-constant memory, it is also legal to return true. Also, calls that unwind the stack are legal for this predicate.
Many optimizations (such as CSE and LICM) can be performed on such calls without worrying about aliasing properties, and many calls have this property (e.g. calls to 'sin' and 'cos').
This property corresponds to the GCC 'const' attribute.
Definition at line 458 of file AliasAnalysis.h.
References Call, llvm::MemoryEffectsBase< LocationEnum >::doesNotAccessMemory(), and getMemoryEffects().
Checks if the specified function is known to never read or write memory.
Note that if the function only reads from known-constant memory, it is also legal to return true. Also, function that unwind the stack are legal for this predicate.
Many optimizations (such as CSE and LICM) can be performed on such calls to such functions without worrying about aliasing properties, and many functions have this property (e.g. 'sin' and 'cos').
This property corresponds to the GCC 'const' attribute.
Definition at line 473 of file AliasAnalysis.h.
References llvm::MemoryEffectsBase< LocationEnum >::doesNotAccessMemory(), F, and getMemoryEffects().
ModRefInfo AAResults::getArgModRefInfo | ( | const CallBase * | Call, |
unsigned | ArgIdx ) |
Get the ModRef info associated with a pointer argument of a call.
The result's bits are set to indicate the allowed aliasing ModRef kinds. Note that these bits do not necessarily account for the overall behavior of the function, but rather only provide additional per-argument information.
Definition at line 184 of file AliasAnalysis.cpp.
References Call, llvm::isNoModRef(), llvm::ModRef, and llvm::NoModRef.
Referenced by getModRefInfo(), and llvm::BasicAAResult::getModRefInfo().
MemoryEffects AAResults::getMemoryEffects | ( | const CallBase * | Call | ) |
Return the behavior of the given call site.
Definition at line 389 of file AliasAnalysis.cpp.
References Call, and getMemoryEffects().
Referenced by AddAliasScopeMetadata(), llvm::objcarc::CanAlterRefCount(), checkFunctionMemoryAccess(), doesNotAccessMemory(), doesNotAccessMemory(), getMemoryEffects(), llvm::BasicAAResult::getMemoryEffects(), getModRefInfo(), getModRefInfo(), llvm::BasicAAResult::getModRefInfo(), onlyReadsMemory(), and onlyReadsMemory().
MemoryEffects AAResults::getMemoryEffects | ( | const CallBase * | Call, |
AAQueryInfo & | AAQI ) |
Definition at line 374 of file AliasAnalysis.cpp.
References Call, and llvm::MemoryEffectsBase< IRMemLocation >::unknown().
MemoryEffects AAResults::getMemoryEffects | ( | const Function * | F | ) |
Return the behavior when calling the given function.
Definition at line 394 of file AliasAnalysis.cpp.
References F, and llvm::MemoryEffectsBase< IRMemLocation >::unknown().
ModRefInfo AAResults::getModRefInfo | ( | const AtomicCmpXchgInst * | CX, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 532 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::AtomicCmpXchgInst::getSuccessOrdering(), llvm::isStrongerThanMonotonic(), llvm::ModRef, llvm::AliasResult::NoAlias, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfo | ( | const AtomicRMWInst * | RMW, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 550 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::AtomicRMWInst::getOrdering(), llvm::isStrongerThanMonotonic(), llvm::ModRef, llvm::AliasResult::NoAlias, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfo | ( | const CallBase * | Call, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 225 of file AliasAnalysis.cpp.
References Call, getModRefInfoMask(), llvm::isNoModRef(), llvm::ModRef, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfo | ( | const CallBase * | Call1, |
const CallBase * | Call2, | ||
AAQueryInfo & | AAQI ) |
Definition at line 247 of file AliasAnalysis.cpp.
References llvm::CallBase::arg_begin(), llvm::CallBase::arg_end(), getArgModRefInfo(), llvm::MemoryLocation::getForArgument(), getMemoryEffects(), getModRefInfo(), llvm::Value::getType(), I, llvm::isModOrRefSet(), llvm::isModSet(), llvm::isNoModRef(), llvm::Type::isPointerTy(), llvm::isRefSet(), llvm::Mod, llvm::ModRef, llvm::NoModRef, and llvm::Ref.
ModRefInfo AAResults::getModRefInfo | ( | const CatchPadInst * | I, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 506 of file AliasAnalysis.cpp.
References getModRefInfoMask(), and llvm::ModRef.
ModRefInfo AAResults::getModRefInfo | ( | const CatchReturnInst * | I, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 519 of file AliasAnalysis.cpp.
References getModRefInfoMask(), and llvm::ModRef.
ModRefInfo AAResults::getModRefInfo | ( | const FenceInst * | S, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 476 of file AliasAnalysis.cpp.
References getModRefInfoMask(), and llvm::ModRef.
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I, |
const CallBase * | Call ) |
Return information about whether a call and an instruction may refer to the same memory locations.
Definition at line 198 of file AliasAnalysis.cpp.
References getModRefInfo(), and I.
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I, |
const CallBase * | Call2, | ||
AAQueryInfo & | AAQIP ) |
Definition at line 204 of file AliasAnalysis.cpp.
References llvm::dyn_cast(), llvm::MemoryLocation::get(), getModRefInfo(), I, llvm::isModOrRefSet(), llvm::ModRef, and llvm::NoModRef.
|
inline |
Check whether or not an instruction may read or write the optionally specified memory location.
An instruction that doesn't read or write memory may be trivially LICM'd for example.
For function calls, this delegates to the alias-analysis specific call-site mod-ref behavior queries. Otherwise it delegates to the specific helpers above.
Definition at line 513 of file AliasAnalysis.h.
References getModRefInfo(), and I.
Referenced by canInstructionRangeModRef(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), and isArgUnmodifiedByAllCalls().
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I, |
const std::optional< MemoryLocation > & | OptLoc, | ||
AAQueryInfo & | AAQIP ) |
Definition at line 568 of file AliasAnalysis.cpp.
References assert(), Call, llvm::dyn_cast(), getMemoryEffects(), llvm::MemoryEffectsBase< LocationEnum >::getModRef(), getModRefInfo(), I, and llvm::NoModRef.
|
inline |
A convenience wrapper for constructing the memory location.
Definition at line 520 of file AliasAnalysis.h.
References getModRefInfo(), I, P, and Size.
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I1, |
const Instruction * | I2 ) |
Return information about whether two instructions may refer to the same memory locations.
Definition at line 354 of file AliasAnalysis.cpp.
References getModRefInfo().
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I1, |
const Instruction * | I2, | ||
AAQueryInfo & | AAQI ) |
Definition at line 360 of file AliasAnalysis.cpp.
References llvm::dyn_cast(), getModRefInfo(), llvm::MemoryLocation::getOrNone(), llvm::isModOrRefSet(), llvm::Instruction::mayReadOrWriteMemory(), llvm::ModRef, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfo | ( | const LoadInst * | L, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 432 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::isStrongerThan(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, llvm::Ref, and llvm::Unordered.
ModRefInfo AAResults::getModRefInfo | ( | const StoreInst * | S, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 450 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), getModRefInfoMask(), llvm::StoreInst::getOrdering(), llvm::isModSet(), llvm::isStrongerThan(), llvm::Mod, llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, and llvm::Unordered.
ModRefInfo AAResults::getModRefInfo | ( | const VAArgInst * | V, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI ) |
Definition at line 487 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), getModRefInfoMask(), llvm::ModRef, llvm::AliasResult::NoAlias, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfoMask | ( | const MemoryLocation & | Loc, |
AAQueryInfo & | AAQI, | ||
bool | IgnoreLocals = false ) |
Definition at line 169 of file AliasAnalysis.cpp.
References llvm::isNoModRef(), llvm::ModRef, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfoMask | ( | const MemoryLocation & | Loc, |
bool | IgnoreLocals = false ) |
Returns a bitmask that should be unconditionally applied to the ModRef info of a memory location.
This allows us to eliminate Mod and/or Ref from the ModRef info based on the knowledge that the memory location points to constant and/or locally-invariant memory.
If IgnoreLocals is true, then this method returns NoModRef for memory that points to a local alloca.
Definition at line 163 of file AliasAnalysis.cpp.
References getModRefInfoMask().
Referenced by addLocAccess(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfo(), getModRefInfoMask(), getModRefInfoMask(), and pointsToConstantMemory().
|
inline |
A convenience wrapper around the primary getModRefInfoMask
interface.
Definition at line 430 of file AliasAnalysis.h.
References llvm::MemoryLocation::getBeforeOrAfter(), getModRefInfoMask(), and P.
bool AAResults::invalidate | ( | Function & | F, |
const PreservedAnalyses & | PA, | ||
FunctionAnalysisManager::Invalidator & | Inv ) |
Handle invalidation events in the new pass manager.
The aggregation is invalidated if any of the underlying analyses is invalidated.
Definition at line 80 of file AliasAnalysis.cpp.
References F, and llvm::PreservedAnalyses::getChecker().
|
inline |
A trivial helper function to check to see if the specified pointers are must-alias.
Definition at line 391 of file AliasAnalysis.h.
References alias(), and llvm::AliasResult::MustAlias.
A convenience wrapper around the isMustAlias
helper interface.
Definition at line 396 of file AliasAnalysis.h.
References alias(), llvm::AliasResult::MustAlias, and llvm::LocationSize::precise().
|
inline |
A trivial helper function to check to see if the specified pointers are no-alias.
Definition at line 373 of file AliasAnalysis.h.
References alias(), and llvm::AliasResult::NoAlias.
Referenced by isNoAlias(), and isNoAlias().
A convenience wrapper around the isNoAlias
helper interface.
Definition at line 384 of file AliasAnalysis.h.
References llvm::MemoryLocation::getBeforeOrAfter(), and isNoAlias().
|
inline |
A convenience wrapper around the isNoAlias
helper interface.
Definition at line 378 of file AliasAnalysis.h.
References isNoAlias().
Checks if the specified call is known to only read from non-volatile memory (or not access memory at all).
Calls that unwind the stack are legal for this predicate.
This property allows many common optimizations to be performed in the absence of interfering store instructions, such as CSE of strlen calls.
This property corresponds to the GCC 'pure' attribute.
Definition at line 486 of file AliasAnalysis.h.
References Call, getMemoryEffects(), and llvm::MemoryEffectsBase< LocationEnum >::onlyReadsMemory().
Checks if the specified function is known to only read from non-volatile memory (or not access memory at all).
Functions that unwind the stack are legal for this predicate.
This property allows many common optimizations to be performed in the absence of interfering store instructions, such as CSE of strlen calls.
This property corresponds to the GCC 'pure' attribute.
Definition at line 499 of file AliasAnalysis.h.
References F, getMemoryEffects(), and llvm::MemoryEffectsBase< LocationEnum >::onlyReadsMemory().
|
inline |
Checks whether the given location points to constant memory, or if OrLocal
is true whether it points to a local alloca.
Definition at line 403 of file AliasAnalysis.h.
References getModRefInfoMask(), and llvm::isNoModRef().
Referenced by pointsToConstantMemory().
A convenience wrapper around the primary pointsToConstantMemory
interface.
Definition at line 409 of file AliasAnalysis.h.
References llvm::MemoryLocation::getBeforeOrAfter(), P, and pointsToConstantMemory().
|
friend |
Definition at line 640 of file AliasAnalysis.h.
References AAResultBase.
Referenced by AAResultBase.
|
friend |
Definition at line 648 of file AliasAnalysis.h.
References BatchAAResults.
Referenced by BatchAAResults.