18#include "llvm/IR/IntrinsicsAMDGPU.h"
21#define DEBUG_TYPE "amdgpu-memory-utils"
71 if (isa<FenceInst>(DefInst))
74 if (
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(DefInst)) {
75 switch (II->getIntrinsicID()) {
76 case Intrinsic::amdgcn_s_barrier:
77 case Intrinsic::amdgcn_wave_barrier:
78 case Intrinsic::amdgcn_sched_barrier:
79 case Intrinsic::amdgcn_sched_group_barrier:
88 const auto checkNoAlias = [AA,
Ptr](
auto I) ->
bool {
92 if (checkNoAlias(dyn_cast<AtomicCmpXchgInst>(DefInst)) ||
93 checkNoAlias(dyn_cast<AtomicRMWInst>(DefInst)))
106 LLVM_DEBUG(
dbgs() <<
"Checking clobbering of: " << *Load <<
'\n');
116 while (!WorkList.empty()) {
118 if (!Visited.
insert(MA).second)
124 if (
MemoryDef *Def = dyn_cast<MemoryDef>(MA)) {
137 const MemoryPhi *Phi = cast<MemoryPhi>(MA);
139 WorkList.push_back(cast<MemoryAccess>(&
Use));
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This file defines the SmallSet class.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias.
A parsed version of the target data layout string in and methods for querying it.
bool hasExternalLinkage() const
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
Represents a read-write access to memory, whether it is a must-alias, or a may-alias.
Representation for a specific memory location.
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
Represents phi nodes for memory accesses.
op_range incoming_values()
This is the generic walker interface for walkers of MemorySSA.
MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
Encapsulates MemorySSA, including all data associated with memory accesses.
MemorySSAWalker * getWalker()
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
A Module instance is used to store all the information related to an LLVM module.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
@ LOCAL_ADDRESS
Address space for local memory.
bool isDynamicLDS(const GlobalVariable &GV)
Align getAlign(DataLayout const &DL, const GlobalVariable *GV)
bool isReallyAClobber(const Value *Ptr, MemoryDef *Def, AAResults *AA)
Given a Def clobbering a load from Ptr according to the MSSA check if this is actually a memory updat...
bool isLDSVariableToLower(const GlobalVariable &GV)
bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, AAResults *AA)
Check is a Load is clobbered in its function.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
This struct is a compact representation of a valid (non-zero power of two) alignment.