Go to the documentation of this file.
18 #include "llvm/IR/IntrinsicsAMDGPU.h"
21 #define DEBUG_TYPE "amdgpu-memory-utils"
37 if (
F && GV.
getName() ==
"llvm.amdgcn.module.lds")
46 while (!Stack.empty()) {
47 const User *V = Stack.pop_back_val();
50 if (isa<GlobalValue>(V)) {
57 if (
auto *
I = dyn_cast<Instruction>(V)) {
71 assert(isa<Constant>(V) &&
"Expected a constant.");
105 std::vector<llvm::GlobalVariable *> LocalVars;
106 for (
auto &GV :
M.globals()) {
113 LocalVars.push_back(&GV);
121 if (isa<FenceInst>(DefInst))
124 if (
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(DefInst)) {
125 switch (II->getIntrinsicID()) {
126 case Intrinsic::amdgcn_s_barrier:
127 case Intrinsic::amdgcn_wave_barrier:
128 case Intrinsic::amdgcn_sched_barrier:
129 case Intrinsic::amdgcn_sched_group_barrier:
138 const auto checkNoAlias = [AA,
Ptr](
auto I) ->
bool {
142 if (checkNoAlias(dyn_cast<AtomicCmpXchgInst>(DefInst)) ||
143 checkNoAlias(dyn_cast<AtomicRMWInst>(DefInst)))
166 while (!WorkList.empty()) {
168 if (!Visited.
insert(MA).second)
187 const MemoryPhi *Phi = cast<MemoryPhi>(MA);
189 WorkList.push_back(cast<MemoryAccess>(&
Use));
static MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
A parsed version of the target data layout string in and methods for querying it.
@ LOCAL_ADDRESS
Address space for local memory.
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.
bool isNoAlias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A trivial helper function to check to see if the specified pointers are no-alias.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
static bool shouldLowerLDSToStruct(const GlobalVariable &GV, const Function *F)
Represents phi nodes for memory accesses.
bool hasInitializer() const
Definitions have initializers, declarations don't.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
std::vector< GlobalVariable * > findLDSVariablesToLower(Module &M, const Function *F)
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, AAResults *AA)
Check is a Load is clobbered in its function.
This struct is a compact representation of a valid (non-zero power of two) alignment.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Encapsulates MemorySSA, including all data associated with memory accesses.
Represents a read-write access to memory, whether it is a must-alias, or a may-alias.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isLDSVariableToLower(const GlobalVariable &GV)
op_range incoming_values()
A Module instance is used to store all the information related to an LLVM module.
MemorySSAWalker * getWalker()
MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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...
StringRef getName() const
Return a constant reference to the value's name.
An instruction for reading from memory.
Align getAlign(DataLayout const &DL, const GlobalVariable *GV)
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
A wrapper class for inspecting calls to intrinsic functions.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
PointerType * getType() const
Global values are always pointers.
Type * getValueType() const
This is the generic walker interface for walkers of MemorySSA.
bool isKernelCC(const Function *Func)
LLVM Value Representation.
iterator_range< user_iterator > users()
Representation for a specific memory location.
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.