LLVM 17.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::MemoryEffects Class Reference

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.
 
MemoryEffectsoperator&= (MemoryEffects Other)
 Intersect (in-place) with other MemoryEffects.
 
MemoryEffects operator| (MemoryEffects Other) const
 Union with other MemoryEffects.
 
MemoryEffectsoperator|= (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_ostreamoperator<< (raw_ostream &OS, MemoryEffects RMRB)
 Debug print MemoryEffects.
 

Detailed Description

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.

Definition at line 63 of file ModRef.h.

Member Enumeration Documentation

◆ Location

The locations at which a function might access memory.

Enumerator
ArgMem 

Access to memory via argument pointers.

InaccessibleMem 

Memory that is inaccessible via LLVM IR.

Other 

Any other memory.

Definition at line 66 of file ModRef.h.

Constructor & Destructor Documentation

◆ MemoryEffects() [1/2]

llvm::MemoryEffects::MemoryEffects ( Location  Loc,
ModRefInfo  MR 
)
inline

Create MemoryEffects that can access only the given location with the given ModRefInfo.

Definition at line 103 of file ModRef.h.

◆ MemoryEffects() [2/2]

llvm::MemoryEffects::MemoryEffects ( ModRefInfo  MR)
inlineexplicit

Create MemoryEffects that can access any location with the given ModRefInfo.

Definition at line 107 of file ModRef.h.

References locations().

Member Function Documentation

◆ argMemOnly()

static MemoryEffects llvm::MemoryEffects::argMemOnly ( ModRefInfo  MR = ModRefInfo::ModRef)
inlinestatic

◆ createFromIntValue()

static MemoryEffects llvm::MemoryEffects::createFromIntValue ( uint32_t  Data)
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().

◆ doesAccessArgPointees()

bool llvm::MemoryEffects::doesAccessArgPointees ( ) const
inline

Whether this function may access argument memory.

Definition at line 205 of file ModRef.h.

References ArgMem, getModRef(), and llvm::isModOrRefSet().

◆ doesNotAccessMemory()

bool llvm::MemoryEffects::doesNotAccessMemory ( ) const
inline

◆ getModRef() [1/2]

ModRefInfo llvm::MemoryEffects::getModRef ( ) const
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().

◆ getModRef() [2/2]

ModRefInfo llvm::MemoryEffects::getModRef ( Location  Loc) const
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().

◆ getWithModRef()

MemoryEffects llvm::MemoryEffects::getWithModRef ( Location  Loc,
ModRefInfo  MR 
) const
inline

Get new MemoryEffects with modified ModRefInfo for Loc.

Definition at line 169 of file ModRef.h.

◆ getWithoutLoc()

MemoryEffects llvm::MemoryEffects::getWithoutLoc ( Location  Loc) const
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().

◆ inaccessibleMemOnly()

static MemoryEffects llvm::MemoryEffects::inaccessibleMemOnly ( ModRefInfo  MR = ModRefInfo::ModRef)
inlinestatic

◆ inaccessibleOrArgMemOnly()

static MemoryEffects llvm::MemoryEffects::inaccessibleOrArgMemOnly ( ModRefInfo  MR = ModRefInfo::ModRef)
inlinestatic

◆ locations()

static auto llvm::MemoryEffects::locations ( )
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<<().

◆ none()

static MemoryEffects llvm::MemoryEffects::none ( )
inlinestatic

◆ onlyAccessesArgPointees()

bool llvm::MemoryEffects::onlyAccessesArgPointees ( ) const
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().

◆ onlyAccessesInaccessibleMem()

bool llvm::MemoryEffects::onlyAccessesInaccessibleMem ( ) const
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().

◆ onlyAccessesInaccessibleOrArgMem()

bool llvm::MemoryEffects::onlyAccessesInaccessibleOrArgMem ( ) const
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().

◆ onlyReadsMemory()

bool llvm::MemoryEffects::onlyReadsMemory ( ) const
inline

◆ onlyWritesMemory()

bool llvm::MemoryEffects::onlyWritesMemory ( ) const
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().

◆ operator!=()

bool llvm::MemoryEffects::operator!= ( MemoryEffects  Other) const
inline

Check whether this is different from other MemoryEffects.

Definition at line 248 of file ModRef.h.

References operator==(), and Other.

◆ operator&()

MemoryEffects llvm::MemoryEffects::operator& ( MemoryEffects  Other) const
inline

Intersect with other MemoryEffects.

Definition at line 221 of file ModRef.h.

References llvm::Data, and Other.

◆ operator&=()

MemoryEffects & llvm::MemoryEffects::operator&= ( MemoryEffects  Other)
inline

Intersect (in-place) with other MemoryEffects.

Definition at line 226 of file ModRef.h.

References llvm::Data, and Other.

◆ operator==()

bool llvm::MemoryEffects::operator== ( MemoryEffects  Other) const
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!=().

◆ operator|()

MemoryEffects llvm::MemoryEffects::operator| ( MemoryEffects  Other) const
inline

Union with other MemoryEffects.

Definition at line 232 of file ModRef.h.

References llvm::Data, and Other.

◆ operator|=()

MemoryEffects & llvm::MemoryEffects::operator|= ( MemoryEffects  Other)
inline

Union (in-place) with other MemoryEffects.

Definition at line 237 of file ModRef.h.

References llvm::Data, and Other.

◆ readOnly()

static MemoryEffects llvm::MemoryEffects::readOnly ( )
inlinestatic

◆ toIntValue()

uint32_t llvm::MemoryEffects::toIntValue ( ) const
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().

◆ unknown()

static MemoryEffects llvm::MemoryEffects::unknown ( )
inlinestatic

◆ writeOnly()

static MemoryEffects llvm::MemoryEffects::writeOnly ( )
inlinestatic

Friends And Related Function Documentation

◆ operator<<

raw_ostream & operator<< ( raw_ostream OS,
MemoryEffects  RMRB 
)
friend

Debug print MemoryEffects.


The documentation for this class was generated from the following file: