LLVM 17.0.0git
|
Summary of how a function affects memory in the program. More...
#include "llvm/Support/ModRef.h"
Public Types | |
enum | Location { ArgMem = 0 , InaccessibleMem = 1 , Other = 2 } |
The locations at which a function might access memory. More... | |
Public Member Functions | |
MemoryEffects (Location Loc, ModRefInfo MR) | |
Create MemoryEffects that can access only the given location with the given ModRefInfo. | |
MemoryEffects (ModRefInfo MR) | |
Create MemoryEffects that can access any location with the given ModRefInfo. | |
uint32_t | toIntValue () const |
Convert MemoryEffects into an encoded integer value (used by memory attribute). | |
ModRefInfo | getModRef (Location Loc) const |
Get ModRefInfo for the given Location. | |
MemoryEffects | getWithModRef (Location Loc, ModRefInfo MR) const |
Get new MemoryEffects with modified ModRefInfo for Loc. | |
MemoryEffects | getWithoutLoc (Location Loc) const |
Get new MemoryEffects with NoModRef on the given Loc. | |
ModRefInfo | getModRef () const |
Get ModRefInfo for any location. | |
bool | doesNotAccessMemory () const |
Whether this function accesses no memory. | |
bool | onlyReadsMemory () const |
Whether this function only (at most) reads memory. | |
bool | onlyWritesMemory () const |
Whether this function only (at most) writes memory. | |
bool | onlyAccessesArgPointees () const |
Whether this function only (at most) accesses argument memory. | |
bool | doesAccessArgPointees () const |
Whether this function may access argument memory. | |
bool | onlyAccessesInaccessibleMem () const |
Whether this function only (at most) accesses inaccessible memory. | |
bool | onlyAccessesInaccessibleOrArgMem () const |
Whether this function only (at most) accesses argument and inaccessible memory. | |
MemoryEffects | operator& (MemoryEffects Other) const |
Intersect with other MemoryEffects. | |
MemoryEffects & | operator&= (MemoryEffects Other) |
Intersect (in-place) with other MemoryEffects. | |
MemoryEffects | operator| (MemoryEffects Other) const |
Union with other MemoryEffects. | |
MemoryEffects & | operator|= (MemoryEffects Other) |
Union (in-place) with other MemoryEffects. | |
bool | operator== (MemoryEffects Other) const |
Check whether this is the same as other MemoryEffects. | |
bool | operator!= (MemoryEffects Other) const |
Check whether this is different from other MemoryEffects. | |
Static Public Member Functions | |
static auto | locations () |
Returns iterator over all supported location kinds. | |
static MemoryEffects | unknown () |
Create MemoryEffects that can read and write any memory. | |
static MemoryEffects | none () |
Create MemoryEffects that cannot read or write any memory. | |
static MemoryEffects | readOnly () |
Create MemoryEffects that can read any memory. | |
static MemoryEffects | writeOnly () |
Create MemoryEffects that can write any memory. | |
static MemoryEffects | argMemOnly (ModRefInfo MR=ModRefInfo::ModRef) |
Create MemoryEffects that can only access argument memory. | |
static MemoryEffects | inaccessibleMemOnly (ModRefInfo MR=ModRefInfo::ModRef) |
Create MemoryEffects that can only access inaccessible memory. | |
static MemoryEffects | inaccessibleOrArgMemOnly (ModRefInfo MR=ModRefInfo::ModRef) |
Create MemoryEffects that can only access inaccessible or argument memory. | |
static MemoryEffects | createFromIntValue (uint32_t Data) |
Create MemoryEffects from an encoded integer value (used by memory attribute). | |
Friends | |
raw_ostream & | operator<< (raw_ostream &OS, MemoryEffects RMRB) |
Debug print MemoryEffects. | |
Summary of how a function affects memory in the program.
Loads from constant globals are not considered memory accesses for this interface. Also, functions may freely modify stack space local to their invocation without having to report it through these interfaces.
|
inline |
Create MemoryEffects that can access only the given location with the given ModRefInfo.
|
inlineexplicit |
Create MemoryEffects that can access any location with the given ModRefInfo.
Definition at line 107 of file ModRef.h.
References locations().
|
inlinestatic |
Create MemoryEffects that can only access argument memory.
Definition at line 133 of file ModRef.h.
References ArgMem.
Referenced by checkFunctionMemoryAccess(), llvm::Function::setOnlyAccessesArgMemory(), llvm::CallBase::setOnlyAccessesArgMemory(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
inlinestatic |
Create MemoryEffects from an encoded integer value (used by memory attribute).
Definition at line 153 of file ModRef.h.
References llvm::Data.
Referenced by llvm::Attribute::getMemoryEffects().
|
inline |
Whether this function may access argument memory.
Definition at line 205 of file ModRef.h.
References ArgMem, getModRef(), and llvm::isModOrRefSet().
|
inline |
Whether this function accesses no memory.
Definition at line 191 of file ModRef.h.
References llvm::Data.
Referenced by llvm::canSinkOrHoistInst(), checkFunctionMemoryAccess(), llvm::Function::doesNotAccessMemory(), llvm::CallBase::doesNotAccessMemory(), llvm::AAResults::doesNotAccessMemory(), getFunctionControl(), llvm::SITargetLowering::getTgtMemIntrinsic(), onlyAccessesArgPointees(), and onlyAccessesInaccessibleMem().
|
inline |
Get ModRefInfo for any location.
Definition at line 183 of file ModRef.h.
References getModRef(), locations(), and llvm::NoModRef.
Referenced by doesAccessArgPointees(), getModRef(), onlyAccessesInaccessibleOrArgMem(), onlyReadsMemory(), and onlyWritesMemory().
|
inline |
Get ModRefInfo for the given Location.
Definition at line 164 of file ModRef.h.
References llvm::Data.
Referenced by llvm::AliasSetTracker::add(), checkFunctionMemoryAccess(), llvm::Attribute::getAsString(), llvm::AAResults::getModRefInfo(), llvm::operator<<(), and runIPSCCP().
|
inline |
Get new MemoryEffects with modified ModRefInfo for Loc.
|
inline |
Get new MemoryEffects with NoModRef on the given Loc.
Definition at line 176 of file ModRef.h.
References llvm::NoModRef.
Referenced by checkFunctionMemoryAccess(), llvm::AAResults::getModRefInfo(), onlyAccessesArgPointees(), and onlyAccessesInaccessibleMem().
|
inlinestatic |
Create MemoryEffects that can only access inaccessible memory.
Definition at line 138 of file ModRef.h.
References InaccessibleMem.
Referenced by checkFunctionMemoryAccess(), decodeLLVMAttributesForBitcode(), llvm::BasicAAResult::getMemoryEffects(), llvm::Function::setOnlyAccessesInaccessibleMemory(), llvm::CallBase::setOnlyAccessesInaccessibleMemory(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
inlinestatic |
Create MemoryEffects that can only access inaccessible or argument memory.
Definition at line 144 of file ModRef.h.
References ArgMem, InaccessibleMem, and none().
Referenced by decodeLLVMAttributesForBitcode(), llvm::Function::setOnlyAccessesInaccessibleMemOrArgMem(), llvm::CallBase::setOnlyAccessesInaccessibleMemOrArgMem(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
inlinestatic |
Returns iterator over all supported location kinds.
Definition at line 96 of file ModRef.h.
References ArgMem, llvm::enum_seq_inclusive(), llvm::force_iteration_on_noniterable_enum, and Other.
Referenced by llvm::Attribute::getAsString(), getModRef(), MemoryEffects(), and llvm::operator<<().
|
inlinestatic |
Create MemoryEffects that cannot read or write any memory.
Definition at line 118 of file ModRef.h.
References llvm::NoModRef.
Referenced by addMemoryAttrs(), checkFunctionMemoryAccess(), decodeLLVMAttributesForBitcode(), fixupFPReturnAndCall(), llvm::TypeBasedAAResult::getMemoryEffects(), llvm::objcarc::ObjCARCAAResult::getMemoryEffects(), inaccessibleOrArgMemOnly(), llvm::Function::setDoesNotAccessMemory(), llvm::CallBase::setDoesNotAccessMemory(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
inline |
Whether this function only (at most) accesses argument memory.
Definition at line 200 of file ModRef.h.
References ArgMem, doesNotAccessMemory(), and getWithoutLoc().
Referenced by AddAliasScopeMetadata(), llvm::objcarc::CanAlterRefCount(), llvm::canSinkOrHoistInst(), llvm::Function::onlyAccessesArgMemory(), and llvm::CallBase::onlyAccessesArgMemory().
|
inline |
Whether this function only (at most) accesses inaccessible memory.
Definition at line 210 of file ModRef.h.
References doesNotAccessMemory(), getWithoutLoc(), and InaccessibleMem.
Referenced by AddAliasScopeMetadata(), llvm::Function::onlyAccessesInaccessibleMemory(), and llvm::CallBase::onlyAccessesInaccessibleMemory().
|
inline |
Whether this function only (at most) accesses argument and inaccessible memory.
Definition at line 216 of file ModRef.h.
References getModRef(), llvm::isNoModRef(), and Other.
Referenced by llvm::Function::onlyAccessesInaccessibleMemOrArgMem(), and llvm::CallBase::onlyAccessesInaccessibleMemOrArgMem().
|
inline |
Whether this function only (at most) reads memory.
Definition at line 194 of file ModRef.h.
References getModRef(), and llvm::isModSet().
Referenced by llvm::objcarc::CanAlterRefCount(), llvm::canSinkOrHoistInst(), getFunctionControl(), llvm::SITargetLowering::getTgtMemIntrinsic(), llvm::Function::onlyReadsMemory(), llvm::CallBase::onlyReadsMemory(), and llvm::AAResults::onlyReadsMemory().
|
inline |
Whether this function only (at most) writes memory.
Definition at line 197 of file ModRef.h.
References getModRef(), and llvm::isRefSet().
Referenced by llvm::SITargetLowering::getTgtMemIntrinsic(), llvm::Function::onlyWritesMemory(), and llvm::CallBase::onlyWritesMemory().
|
inline |
Check whether this is different from other MemoryEffects.
Definition at line 248 of file ModRef.h.
References operator==(), and Other.
|
inline |
Intersect with other MemoryEffects.
Definition at line 221 of file ModRef.h.
References llvm::Data, and Other.
|
inline |
Intersect (in-place) with other MemoryEffects.
Definition at line 226 of file ModRef.h.
References llvm::Data, and Other.
|
inline |
Check whether this is the same as other MemoryEffects.
Definition at line 243 of file ModRef.h.
References llvm::Data, and Other.
Referenced by operator!=().
|
inline |
Union with other MemoryEffects.
Definition at line 232 of file ModRef.h.
References llvm::Data, and Other.
|
inline |
Union (in-place) with other MemoryEffects.
Definition at line 237 of file ModRef.h.
References llvm::Data, and Other.
|
inlinestatic |
Create MemoryEffects that can read any memory.
Definition at line 123 of file ModRef.h.
References llvm::Ref.
Referenced by decodeLLVMAttributesForBitcode(), llvm::CallBase::getMemoryEffects(), llvm::BasicAAResult::getMemoryEffects(), llvm::AMDGPULibFunc::getOrInsertFunction(), llvm::Function::setOnlyReadsMemory(), llvm::CallBase::setOnlyReadsMemory(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
inline |
Convert MemoryEffects into an encoded integer value (used by memory attribute).
Definition at line 159 of file ModRef.h.
References llvm::Data.
Referenced by llvm::AttrBuilder::addMemoryAttr(), and llvm::Attribute::getWithMemoryEffects().
|
inlinestatic |
Create MemoryEffects that can read and write any memory.
Definition at line 113 of file ModRef.h.
References llvm::ModRef.
Referenced by addMemoryAttrs(), decodeLLVMAttributesForBitcode(), llvm::AttributeSet::getMemoryEffects(), llvm::AttributeSetNode::getMemoryEffects(), llvm::AAResults::getMemoryEffects(), llvm::AAResultBase::getMemoryEffects(), and runIPSCCP().
|
inlinestatic |
Create MemoryEffects that can write any memory.
Definition at line 128 of file ModRef.h.
References llvm::Mod.
Referenced by decodeLLVMAttributesForBitcode(), llvm::CallBase::getMemoryEffects(), llvm::BasicAAResult::getMemoryEffects(), llvm::Function::setOnlyWritesMemory(), llvm::CallBase::setOnlyWritesMemory(), upgradeMemoryAttr(), and upgradeOldMemoryAttribute().
|
friend |
Debug print MemoryEffects.