Go to the documentation of this file.
19 #include "llvm/IR/IntrinsicsAMDGPU.h"
22 #define DEBUG_TYPE "amdgpu-memory-utils"
39 while (!Stack.empty()) {
40 U = Stack.pop_back_val();
42 if (
auto *
I = dyn_cast<Instruction>(U)) {
43 if (
I->getFunction() ==
F)
48 if (!isa<ConstantExpr>(U))
67 if (
F && GV.
getName() ==
"llvm.amdgcn.module.lds")
76 while (!Stack.empty()) {
77 const User *V = Stack.pop_back_val();
80 if (isa<GlobalValue>(V)) {
87 if (
auto *
I = dyn_cast<Instruction>(V)) {
101 assert(isa<Constant>(V) &&
"Expected a constant.");
110 std::vector<llvm::GlobalVariable *> LocalVars;
111 for (
auto &GV :
M.globals()) {
115 if (!GV.hasInitializer()) {
122 if (!isa<UndefValue>(GV.getInitializer())) {
127 if (GV.isConstant()) {
136 LocalVars.push_back(&GV);
144 if (isa<FenceInst>(DefInst))
147 if (
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(DefInst)) {
148 switch (II->getIntrinsicID()) {
149 case Intrinsic::amdgcn_s_barrier:
150 case Intrinsic::amdgcn_wave_barrier:
151 case Intrinsic::amdgcn_sched_barrier:
160 const auto checkNoAlias = [
AA, Ptr](
auto I) ->
bool {
161 return I &&
AA->isNoAlias(
I->getPointerOperand(), Ptr);
164 if (checkNoAlias(dyn_cast<AtomicCmpXchgInst>(DefInst)) ||
165 checkNoAlias(dyn_cast<AtomicRMWInst>(DefInst)))
188 while (!WorkList.empty()) {
190 if (!Visited.
insert(MA).second)
209 const MemoryPhi *Phi = cast<MemoryPhi>(MA);
211 WorkList.push_back(cast<MemoryAccess>(&
Use));
std::vector< GlobalVariable * > findVariablesToLower(Module &M, const Function *F)
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
(vector float) vec_cmpeq(*A, *B) C
void convertConstantExprsToInstructions(Instruction *I, ConstantExpr *CE, SmallPtrSetImpl< Instruction * > *Insts=nullptr)
The given instruction I contains given constant expression CE as one of its operands,...
@ LOCAL_ADDRESS
Address space for local memory.
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.
static void collectFunctionUses(User *U, const Function *F, SetVector< Instruction * > &InstUsers)
MemoryAccess * getClobberingMemoryAccess(const Instruction *I)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
void replaceConstantUsesInFunction(ConstantExpr *C, const Function *F)
Replace all uses of constant C with instructions in F.
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())
op_range incoming_values()
A Module instance is used to store all the information related to an LLVM module.
MemorySSAWalker * getWalker()
bool insert(const value_type &X)
Insert a new element into the SetVector.
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...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
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)
A constant value that is initialized with an expression using other constant values.
A wrapper class for inspecting calls to intrinsic functions.
Type * getValueType() const
This is the generic walker interface for walkers of MemorySSA.
A vector that has set insertion semantics.
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.