LLVM 20.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 | |
AAResults (const TargetLibraryInfo &TLI) | |
AAResults (AAResults &&Arg) | |
~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. | |
bool | invalidate (Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv) |
Handle invalidation events in the new pass manager. | |
Alias Queries | |
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 | |
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. | |
ModRefInfo | getArgModRefInfo (const CallBase *Call, unsigned ArgIdx) |
Get the ModRef info associated with a pointer argument of a call. | |
MemoryEffects | getMemoryEffects (const CallBase *Call) |
Return the behavior of the given call site. | |
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. | |
ModRefInfo | getModRefInfo (const Instruction *I, const CallBase *Call) |
Return information about whether a call and an instruction 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 314 of file AliasAnalysis.h.
|
inline |
Definition at line 318 of file AliasAnalysis.h.
AAResults::AAResults | ( | AAResults && | Arg | ) |
Definition at line 76 of file AliasAnalysis.cpp.
AAResults::~AAResults | ( | ) |
Definition at line 79 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 335 of file AliasAnalysis.h.
|
inline |
Register a specific AA result.
Definition at line 323 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 105 of file AliasAnalysis.cpp.
References alias().
Referenced by llvm::BatchAAResults::alias(), alias(), callCapturesBefore(), getModRefInfo(), llvm::BasicAAResult::getModRefInfo(), isMustAlias(), and isNoAlias().
AliasResult AAResults::alias | ( | const MemoryLocation & | LocA, |
const MemoryLocation & | LocB, | ||
AAQueryInfo & | AAQI, | ||
const Instruction * | CtxI = nullptr |
||
) |
Definition at line 111 of file AliasAnalysis.cpp.
References llvm::dbgs(), llvm::AAQueryInfo::Depth, EnableAATrace, I, 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 361 of file AliasAnalysis.h.
References alias(), and llvm::MemoryLocation::getBeforeOrAfter().
|
inline |
A convenience wrapper around the primary alias
interface.
Definition at line 355 of file AliasAnalysis.h.
References alias().
|
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 527 of file AliasAnalysis.h.
References callCapturesBefore(), and I.
Referenced by callCapturesBefore(), and llvm::BatchAAResults::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 647 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::getBeforeOrAfter(), llvm::getUnderlyingObject(), I, llvm::isIdentifiedFunctionLocal(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, llvm::PointerMayBeCapturedBefore(), llvm::MemoryLocation::Ptr, and llvm::Ref.
|
inline |
A convenience wrapper to synthesize a memory location.
Definition at line 535 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 703 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 550 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 713 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 565 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 453 of file AliasAnalysis.h.
References 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 468 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 170 of file AliasAnalysis.cpp.
References llvm::isNoModRef(), llvm::ModRef, and llvm::NoModRef.
Referenced by llvm::BatchAAResults::getArgModRefInfo(), and getModRefInfo().
MemoryEffects AAResults::getMemoryEffects | ( | const CallBase * | Call | ) |
Return the behavior of the given call site.
Definition at line 387 of file AliasAnalysis.cpp.
References getMemoryEffects().
Referenced by AddAliasScopeMetadata(), llvm::objcarc::CanAlterRefCount(), llvm::canSinkOrHoistInst(), checkFunctionMemoryAccess(), doesNotAccessMemory(), getMemoryEffects(), llvm::BatchAAResults::getMemoryEffects(), llvm::BasicAAResult::getMemoryEffects(), getModRefInfo(), and onlyReadsMemory().
MemoryEffects AAResults::getMemoryEffects | ( | const CallBase * | Call, |
AAQueryInfo & | AAQI | ||
) |
Definition at line 372 of file AliasAnalysis.cpp.
References llvm::MemoryEffectsBase< LocationEnum >::unknown().
MemoryEffects AAResults::getMemoryEffects | ( | const Function * | F | ) |
Return the behavior when calling the given function.
Definition at line 392 of file AliasAnalysis.cpp.
References F, and llvm::MemoryEffectsBase< LocationEnum >::unknown().
ModRefInfo AAResults::getModRefInfo | ( | const AtomicCmpXchgInst * | CX, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 566 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::AtomicCmpXchgInst::getSuccessOrdering(), llvm::isStrongerThanMonotonic(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, and llvm::MemoryLocation::Ptr.
ModRefInfo AAResults::getModRefInfo | ( | const AtomicRMWInst * | RMW, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 584 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::AtomicRMWInst::getOrdering(), llvm::isStrongerThanMonotonic(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, and llvm::MemoryLocation::Ptr.
ModRefInfo AAResults::getModRefInfo | ( | const CallBase * | Call, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 211 of file AliasAnalysis.cpp.
References alias(), llvm::ArgMem, llvm::enumerate(), getArgModRefInfo(), llvm::MemoryLocation::getForArgument(), getMemoryEffects(), getModRefInfoMask(), llvm::Value::getType(), llvm::MemoryEffectsBase< LocationEnum >::getWithoutLoc(), I, llvm::InaccessibleMem, llvm::isNoModRef(), llvm::Type::isPointerTy(), llvm::ModRef, llvm::AliasResult::NoAlias, and llvm::NoModRef.
ModRefInfo AAResults::getModRefInfo | ( | const CallBase * | Call1, |
const CallBase * | Call2, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 265 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 540 of file AliasAnalysis.cpp.
References getModRefInfoMask(), llvm::ModRef, and llvm::MemoryLocation::Ptr.
ModRefInfo AAResults::getModRefInfo | ( | const CatchReturnInst * | I, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 553 of file AliasAnalysis.cpp.
References getModRefInfoMask(), llvm::ModRef, and llvm::MemoryLocation::Ptr.
ModRefInfo AAResults::getModRefInfo | ( | const FenceInst * | S, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 510 of file AliasAnalysis.cpp.
References getModRefInfoMask(), llvm::ModRef, and llvm::MemoryLocation::Ptr.
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 184 of file AliasAnalysis.cpp.
References getModRefInfo(), and I.
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I, |
const CallBase * | Call2, | ||
AAQueryInfo & | AAQIP | ||
) |
Definition at line 190 of file AliasAnalysis.cpp.
References 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 508 of file AliasAnalysis.h.
References getModRefInfo(), and I.
Referenced by canInstructionRangeModRef(), canMoveAboveCall(), findSafeStoreForStoreStrongContraction(), foldLoadsRecursive(), getModRefInfo(), llvm::BatchAAResults::getModRefInfo(), llvm::hasPartialIVCondition(), isMemModifiedBetween(), isSafeToMove(), and mayLoopAccessLocation().
ModRefInfo AAResults::getModRefInfo | ( | const Instruction * | I, |
const std::optional< MemoryLocation > & | OptLoc, | ||
AAQueryInfo & | AAQIP | ||
) |
Definition at line 602 of file AliasAnalysis.cpp.
References assert(), getMemoryEffects(), llvm::MemoryEffectsBase< LocationEnum >::getModRef(), getModRefInfo(), I, and llvm::NoModRef.
|
inline |
A convenience wrapper for constructing the memory location.
Definition at line 515 of file AliasAnalysis.h.
References getModRefInfo(), I, P, and Size.
ModRefInfo AAResults::getModRefInfo | ( | const LoadInst * | L, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 466 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), llvm::isStrongerThan(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, llvm::MemoryLocation::Ptr, llvm::Ref, and llvm::Unordered.
ModRefInfo AAResults::getModRefInfo | ( | const StoreInst * | S, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 484 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, llvm::MemoryLocation::Ptr, and llvm::Unordered.
ModRefInfo AAResults::getModRefInfo | ( | const VAArgInst * | V, |
const MemoryLocation & | Loc, | ||
AAQueryInfo & | AAQI | ||
) |
Definition at line 521 of file AliasAnalysis.cpp.
References alias(), llvm::MemoryLocation::get(), getModRefInfoMask(), llvm::ModRef, llvm::AliasResult::NoAlias, llvm::NoModRef, and llvm::MemoryLocation::Ptr.
ModRefInfo AAResults::getModRefInfoMask | ( | const MemoryLocation & | Loc, |
AAQueryInfo & | AAQI, | ||
bool | IgnoreLocals = false |
||
) |
Definition at line 155 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 149 of file AliasAnalysis.cpp.
References getModRefInfoMask().
Referenced by addLocAccess(), llvm::canSinkOrHoistInst(), getModRefInfo(), llvm::BatchAAResults::getModRefInfoMask(), getModRefInfoMask(), isOnlyCopiedFromConstantMemory(), pointsToConstantMemory(), llvm::BatchAAResults::pointsToConstantMemory(), llvm::InstCombinerImpl::SimplifyAnyMemSet(), llvm::InstCombinerImpl::SimplifyAnyMemTransfer(), and llvm::InstCombinerImpl::visitStoreInst().
|
inline |
A convenience wrapper around the primary getModRefInfoMask
interface.
Definition at line 425 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 81 of file AliasAnalysis.cpp.
References F, llvm::PreservedAnalyses::getChecker(), and llvm::AnalysisManager< IRUnitT, ExtraArgTs >::Invalidator::invalidate().
|
inline |
A trivial helper function to check to see if the specified pointers are must-alias.
Definition at line 386 of file AliasAnalysis.h.
References alias(), and llvm::AliasResult::MustAlias.
A convenience wrapper around the isMustAlias
helper interface.
Definition at line 391 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 368 of file AliasAnalysis.h.
References alias(), and llvm::AliasResult::NoAlias.
Referenced by llvm::GISelAddressing::instMayAlias(), isNoAlias(), llvm::AMDGPU::isReallyAClobber(), MemOperandsHaveAlias(), operandReferences(), and underlyingObjectsAlias().
A convenience wrapper around the isNoAlias
helper interface.
Definition at line 379 of file AliasAnalysis.h.
References llvm::MemoryLocation::getBeforeOrAfter(), and isNoAlias().
|
inline |
A convenience wrapper around the isNoAlias
helper interface.
Definition at line 373 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 481 of file AliasAnalysis.h.
References getMemoryEffects(), and llvm::MemoryEffectsBase< LocationEnum >::onlyReadsMemory().
Referenced by llvm::MemoryDependenceResults::getDependency(), and llvm::MemoryDependenceResults::getNonLocalCallDependency().
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 494 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 398 of file AliasAnalysis.h.
References getModRefInfoMask(), and llvm::isNoModRef().
Referenced by getMemCmpLoad(), getMemcpyLoadsAndStores(), llvm::objcarc::IsPotentialRetainableObjPtr(), and pointsToConstantMemory().
A convenience wrapper around the primary pointsToConstantMemory
interface.
Definition at line 404 of file AliasAnalysis.h.
References llvm::MemoryLocation::getBeforeOrAfter(), P, and pointsToConstantMemory().
|
friend |
Definition at line 613 of file AliasAnalysis.h.
|
friend |
Definition at line 621 of file AliasAnalysis.h.