LLVM 24.0.0git
AMDGPUMemoryUtils.cpp
Go to the documentation of this file.
1//===-- AMDGPUMemoryUtils.cpp - -------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "AMDGPUMemoryUtils.h"
12#include "llvm/ADT/StringRef.h"
16#include "llvm/IR/DataLayout.h"
20#include "llvm/IR/IntrinsicsAMDGPU.h"
21#include "llvm/IR/LLVMContext.h"
26
27#define DEBUG_TYPE "amdgpu-memory-utils"
28
29using namespace llvm;
30
31namespace llvm::AMDGPU {
32
34 return DL.getValueOrABITypeAlignment(GV->getPointerAlignment(DL),
35 GV->getValueType());
36}
37
38unsigned getSyntheticApertureNumber(unsigned AS) {
39 switch (AS) {
42 case AMDGPUAS::VGPR:
44 default:
46 }
47}
48
49void copyMetadataForWidenedLoad(LoadInst &Dest, const LoadInst &Source) {
51 Source.getAllMetadata(MD);
52 for (const auto &[ID, N] : MD) {
53 switch (ID) {
54 case LLVMContext::MD_dbg:
55 case LLVMContext::MD_invariant_load:
56 case LLVMContext::MD_nontemporal:
57 Dest.setMetadata(ID, N);
58 break;
59 default:
60 break;
61 }
62 }
63}
64
65// Returns the target extension type of a global variable,
66// which can only be a TargetExtType, an array or single-element struct of it,
67// or their nesting combination.
68// TODO: allow struct of multiple TargetExtType elements of the same type.
69// TODO: Disallow other uses of target("amdgcn.named.barrier") including:
70// - Structs containing barriers in different scope/rank
71// - Structs containing a mixture of barriers and other data.
72// - Globals in other address spaces.
73// - Allocas.
75 Type *Ty = GV.getValueType();
76 while (true) {
77 if (auto *TTy = dyn_cast<TargetExtType>(Ty))
78 return TTy;
79 if (auto *STy = dyn_cast<StructType>(Ty)) {
80 if (STy->getNumElements() != 1)
81 return nullptr;
82 Ty = STy->getElementType(0);
83 continue;
84 }
85 if (auto *ATy = dyn_cast<ArrayType>(Ty)) {
86 Ty = ATy->getElementType();
87 continue;
88 }
89 return nullptr;
90 }
91}
92
95 return nullptr;
96 if (TargetExtType *Ty = getTargetExtType(GV))
97 return Ty->getName() == "amdgcn.named.barrier" ? Ty : nullptr;
98 return nullptr;
99}
100
102 const GlobalVariable &GV) {
104 unsigned GVSize = GV.getGlobalSize(DL);
105 assert(GVSize && (GVSize % NamedBarrierTypeSizeInBytes == 0));
106 return GVSize / NamedBarrierTypeSizeInBytes;
107}
108
110 // external zero size addrspace(3) without initializer is dynlds.
111 const Module *M = GV.getParent();
112 const DataLayout &DL = M->getDataLayout();
114 return false;
115 return GV.getGlobalSize(DL) == 0;
116}
117
120 return false;
121 }
122 if (isDynamicLDS(GV)) {
123 return true;
124 }
125 if (GV.isConstant()) {
126 // A constant undef variable can't be written to, and any load is
127 // undef, so it should be eliminated by the optimizer. It could be
128 // dropped by the back end if not. This pass skips over it.
129 return false;
130 }
131 if (GV.hasInitializer() && !isa<UndefValue>(GV.getInitializer())) {
132 // Initializers are unimplemented for LDS address space.
133 // Leave such variables in place for consistent error reporting.
134 return false;
135 }
136 return true;
137}
138
140 Module &M, function_ref<bool(const GlobalVariable &)> Filter) {
142 for (auto &GV : M.globals())
143 if (Filter(GV))
144 Worklist.push_back(&GV);
146}
147
149 function_ref<bool(const GlobalVariable &)> Filter,
150 FunctionVariableMap &Kernels,
151 FunctionVariableMap &Functions) {
152 // Get uses from the current function, excluding uses by called Functions
153 // Two output variables to avoid walking the globals list twice
154 for (auto &GV : M.globals()) {
155 if (!Filter(GV))
156 continue;
157 for (User *V : GV.users()) {
158 if (auto *I = dyn_cast<Instruction>(V)) {
159 Function *F = I->getFunction();
160 if (isKernel(*F))
161 Kernels[F].insert(&GV);
162 else
163 Functions[F].insert(&GV);
164 }
165 }
166 }
167}
168
169GVUsesInfoTy
171 function_ref<bool(const GlobalVariable &)> Filter) {
172
173 FunctionVariableMap DirectMapKernel;
174 FunctionVariableMap DirectMapFunction;
175 getUsesOfGVByFunction(CG, M, Filter, DirectMapKernel, DirectMapFunction);
176
177 // Collect functions whose address has escaped
178 DenseSet<Function *> AddressTakenFuncs;
179 for (Function &F : M.functions()) {
180 if (!isKernel(F))
181 if (F.hasAddressTaken(nullptr,
182 /* IgnoreCallbackUses */ false,
183 /* IgnoreAssumeLikeCalls */ false,
184 /* IgnoreLLVMUsed */ true,
185 /* IgnoreArcAttachedCall */ false)) {
186 AddressTakenFuncs.insert(&F);
187 }
188 }
189
190 // Collect variables that are used by functions whose address has escaped
191 DenseSet<GlobalVariable *> VariablesReachableThroughFunctionPointer;
192 for (Function *F : AddressTakenFuncs) {
193 set_union(VariablesReachableThroughFunctionPointer, DirectMapFunction[F]);
194 }
195
196 auto FunctionMakesUnknownCall = [&](const Function *F) -> bool {
197 assert(!F->isDeclaration());
198 for (const CallGraphNode::CallRecord &R : *CG[F]) {
199 if (!R.second->getFunction())
200 return true;
201 }
202 return false;
203 };
204
205 // Work out which variables are reachable through function calls
206 FunctionVariableMap TransitiveMapFunction = DirectMapFunction;
207
208 // If the function makes any unknown call, assume the worst case that it can
209 // access all variables accessed by functions whose address escaped
210 for (Function &F : M.functions()) {
211 if (!F.isDeclaration() && FunctionMakesUnknownCall(&F)) {
212 if (!isKernel(F)) {
213 set_union(TransitiveMapFunction[&F],
214 VariablesReachableThroughFunctionPointer);
215 }
216 }
217 }
218
219 // Direct implementation of collecting all variables reachable from each
220 // function
221 for (Function &Func : M.functions()) {
222 if (Func.isDeclaration() || isKernel(Func))
223 continue;
224
225 DenseSet<Function *> seen; // catches cycles
226 SmallVector<Function *, 4> wip = {&Func};
227
228 while (!wip.empty()) {
229 Function *F = wip.pop_back_val();
230
231 // Can accelerate this by referring to transitive map for functions that
232 // have already been computed, with more care than this
233 set_union(TransitiveMapFunction[&Func], DirectMapFunction[F]);
234
235 for (const CallGraphNode::CallRecord &R : *CG[F]) {
236 Function *Ith = R.second->getFunction();
237 if (Ith) {
238 if (!seen.contains(Ith)) {
239 seen.insert(Ith);
240 wip.push_back(Ith);
241 }
242 }
243 }
244 }
245 }
246
247 // Collect variables that are transitively used by functions whose address has
248 // escaped
249 for (Function *F : AddressTakenFuncs) {
250 set_union(VariablesReachableThroughFunctionPointer,
251 TransitiveMapFunction[F]);
252 }
253
254 // DirectMapKernel lists which variables are used by the kernel
255 // find the variables which are used through a function call
256 FunctionVariableMap IndirectMapKernel;
257
258 for (Function &Func : M.functions()) {
259 if (Func.isDeclaration() || !isKernel(Func))
260 continue;
261
262 for (const CallGraphNode::CallRecord &R : *CG[&Func]) {
263 Function *Ith = R.second->getFunction();
264 if (Ith) {
265 set_union(IndirectMapKernel[&Func], TransitiveMapFunction[Ith]);
266 }
267 }
268
269 // Check if the kernel encounters unknows calls, wheher directly or
270 // indirectly.
271 bool SeesUnknownCalls = [&]() {
272 SmallVector<Function *> WorkList = {CG[&Func]->getFunction()};
274
275 while (!WorkList.empty()) {
276 Function *F = WorkList.pop_back_val();
277
278 for (const CallGraphNode::CallRecord &CallRecord : *CG[F]) {
279 if (!CallRecord.second)
280 continue;
281
282 Function *Callee = CallRecord.second->getFunction();
283 if (!Callee)
284 return true;
285
286 if (Visited.insert(Callee).second)
287 WorkList.push_back(Callee);
288 }
289 }
290 return false;
291 }();
292
293 if (SeesUnknownCalls) {
294 set_union(IndirectMapKernel[&Func],
295 VariablesReachableThroughFunctionPointer);
296 }
297 }
298
299 return {std::move(DirectMapKernel), std::move(IndirectMapKernel)};
300}
301
304 // Verify that we fall into one of 2 cases:
305 // - All variables are either absolute
306 // or direct mapped dynamic LDS that is not lowered.
307 // - No variables are absolute.
308 // Named-barriers which are absolute symbols are removed
309 // from the maps.
310 std::optional<bool> HasAbsoluteGVs;
311 for (auto &Map : {UsesInfo.DirectAccess, UsesInfo.IndirectAccess}) {
312 for (auto &[Fn, GVs] : Map) {
313 for (auto *GV : GVs) {
314 bool IsAbsolute = GV->isAbsoluteSymbolRef();
315 bool IsDirectMapDynLDSGV =
316 AMDGPU::isDynamicLDS(*GV) && UsesInfo.DirectAccess.contains(Fn);
317 if (IsDirectMapDynLDSGV)
318 continue;
319
320 if (HasAbsoluteGVs.has_value()) {
321 if (*HasAbsoluteGVs != IsAbsolute) {
323 "module cannot mix absolute and non-absolute LDS GVs");
324 }
325 } else
326 HasAbsoluteGVs = IsAbsolute;
327 }
328 }
329 }
330
331 // If we only had absolute GVs, we have nothing to do, return an empty
332 // result.
333 if (HasAbsoluteGVs && *HasAbsoluteGVs)
334 return GVUsesInfoTy();
335
336 return UsesInfo;
337}
338
340 ArrayRef<StringRef> FnAttrs) {
341 for (StringRef Attr : FnAttrs)
342 KernelRoot->removeFnAttr(Attr);
343
344 SmallVector<Function *> WorkList = {CG[KernelRoot]->getFunction()};
346 bool SeenUnknownCall = false;
347
348 while (!WorkList.empty()) {
349 Function *F = WorkList.pop_back_val();
350
351 for (auto &CallRecord : *CG[F]) {
352 if (!CallRecord.second)
353 continue;
354
355 Function *Callee = CallRecord.second->getFunction();
356 if (!Callee) {
357 if (!SeenUnknownCall) {
358 SeenUnknownCall = true;
359
360 // If we see any indirect calls, assume nothing about potential
361 // targets.
362 // TODO: This could be refined to possible LDS global users.
363 for (auto &ExternalCallRecord : *CG.getExternalCallingNode()) {
364 Function *PotentialCallee =
365 ExternalCallRecord.second->getFunction();
366 assert(PotentialCallee);
367 if (!isKernel(*PotentialCallee)) {
368 for (StringRef Attr : FnAttrs)
369 PotentialCallee->removeFnAttr(Attr);
370 }
371 }
372 }
373 } else {
374 for (StringRef Attr : FnAttrs)
375 Callee->removeFnAttr(Attr);
376 if (Visited.insert(Callee).second)
377 WorkList.push_back(Callee);
378 }
379 }
380 }
381}
382
384 Instruction *DefInst = Def->getMemoryInst();
385
386 if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(DefInst)) {
387 switch (II->getIntrinsicID()) {
388 case Intrinsic::amdgcn_s_barrier:
389 case Intrinsic::amdgcn_s_cluster_barrier:
390 case Intrinsic::amdgcn_s_barrier_signal:
391 case Intrinsic::amdgcn_s_barrier_signal_var:
392 case Intrinsic::amdgcn_s_barrier_signal_isfirst:
393 case Intrinsic::amdgcn_s_barrier_init:
394 case Intrinsic::amdgcn_s_barrier_join:
395 case Intrinsic::amdgcn_s_barrier_wait:
396 case Intrinsic::amdgcn_s_barrier_leave:
397 case Intrinsic::amdgcn_s_get_barrier_state:
398 case Intrinsic::amdgcn_s_wakeup_barrier:
399 case Intrinsic::amdgcn_wave_barrier:
400 case Intrinsic::amdgcn_sched_barrier:
401 case Intrinsic::amdgcn_sched_group_barrier:
402 case Intrinsic::amdgcn_iglp_opt:
403 return false;
404 default:
405 break;
406 }
407 }
408
409 // Ignore non-acquire fences/atomics not aliasing with the original load; MSSA
410 // counts any atomic or fence as a universal MemoryDef.
411 // Acquire (or stronger) fences/atomics act as clobbers because they can bring
412 // in effects from other threads.
413 const auto MayAlias = [AA, Ptr](auto I) -> bool {
414 return !AA->isNoAlias(I->getPointerOperand(), Ptr);
415 };
416
417 if (const auto *F = dyn_cast<FenceInst>(DefInst)) {
418 if (!isAcquireOrStronger(F->getOrdering()))
419 return false;
420 SIAtomicAddrSpace AccessedAS =
422 return (AccessedAS & getSynchronizeAddrSpace(*F)) !=
424 }
425
426 if (const auto *I = dyn_cast<AtomicRMWInst>(DefInst))
427 return isAcquireOrStronger(I->getOrdering()) || MayAlias(I);
428
429 if (const auto *I = dyn_cast<AtomicCmpXchgInst>(DefInst))
430 return isAcquireOrStronger(I->getMergedOrdering()) || MayAlias(I);
431
432 // TODO This is pessimistic for one-as load-acquires from a different AS.
433 if (const auto *I = dyn_cast<LoadInst>(DefInst))
434 return isAcquireOrStronger(I->getOrdering());
435
436 // (Atomic) stores that don't alias do not clobber.
437 if (const auto *I = dyn_cast<StoreInst>(DefInst))
438 return MayAlias(I);
439
440 return true;
441}
442
444 AAResults *AA) {
445 MemorySSAWalker *Walker = MSSA->getWalker();
449 Walker->getClobberingMemoryAccess(Use->getDefiningAccess(), Loc)};
451
452 LLVM_DEBUG(dbgs() << "Checking clobbering of: " << *Load << '\n');
453
454 // Start with a nearest dominating clobbering access, it will be either
455 // live on entry (nothing to do, load is not clobbered), MemoryDef, or
456 // MemoryPhi if several MemoryDefs can define this memory state. In that
457 // case add all Defs to WorkList and continue going up and checking all
458 // the definitions of this memory location until the root. When all the
459 // defs are exhausted and came to the entry state we have no clobber.
460 // Along the scan ignore barriers which are considered clobbers by the
461 // MemorySSA, but not really writing anything into the memory.
462 while (!WorkList.empty()) {
463 MemoryAccess *MA = WorkList.pop_back_val();
464 if (!Visited.insert(MA).second)
465 continue;
466
467 if (MSSA->isLiveOnEntryDef(MA))
468 continue;
469
470 if (MemoryDef *Def = dyn_cast<MemoryDef>(MA)) {
471 LLVM_DEBUG(dbgs() << " Def: " << *Def->getMemoryInst() << '\n');
472
473 if (isReallyAClobber(Load->getPointerOperand(), Def, AA)) {
474 LLVM_DEBUG(dbgs() << " -> load is clobbered\n");
475 return true;
476 }
477
478 WorkList.push_back(
479 Walker->getClobberingMemoryAccess(Def->getDefiningAccess(), Loc));
480 continue;
481 }
482
483 const MemoryPhi *Phi = cast<MemoryPhi>(MA);
484 for (const auto &Use : Phi->incoming_values())
485 WorkList.push_back(
487 }
488
489 LLVM_DEBUG(dbgs() << " -> no clobber\n");
490 return false;
491}
492
494 SIAtomicAddrSpace::FLAT, //< AMDGPUAS::FLAT_ADDRESS
495 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::GLOBAL_ADDRESS
496 SIAtomicAddrSpace::GDS, //< AMDGPUAS::REGION_ADDRESS
497 SIAtomicAddrSpace::LDS, //< AMDGPUAS::LOCAL_ADDRESS
498 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::CONSTANT_ADDRESS
499 SIAtomicAddrSpace::SCRATCH, //< AMDGPUAS::PRIVATE_ADDRESS
500 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::CONSTANT_ADDRESS_32BIT
501 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::BUFFER_FAT_POINTER
502 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::BUFFER_RESOURCE
503 SIAtomicAddrSpace::GLOBAL, //< AMDGPUAS::BUFFER_STRIDED_POINTER
504};
505
506SIAtomicAddrSpace toSIAtomicAddrSpace(unsigned LLVMAddrSpace) {
507 constexpr unsigned SizeOfLLVMToSIAtomicAddrSpaceMapping =
510 if (LLVMAddrSpace > AMDGPUAS::MAX_AMDGPU_ADDRESS)
512 if (LLVMAddrSpace < SizeOfLLVMToSIAtomicAddrSpaceMapping)
513 return LLVMToSIAtomicAddrSpaceMapping[LLVMAddrSpace];
515}
516
518 {"global", SIAtomicAddrSpace::GLOBAL},
519 {"local", SIAtomicAddrSpace::LDS},
520}};
521
523 const Function *DiagFn,
524 const DebugLoc &DL) {
525 static constexpr StringLiteral FenceASPrefix = "amdgpu-synchronize-as";
526
527 if (!MMRA)
529
530 SIAtomicAddrSpace Result{};
531 for (const auto &[Prefix, Suffix] : MMRA) {
532 if (Prefix != FenceASPrefix)
533 continue;
534
535 if (auto It = ASNames.find(Suffix); It != ASNames.end()) {
536 Result |= It->second;
537 } else if (DiagFn) {
539 raw_svector_ostream OS(Str);
540 OS << "unknown address space '" << Suffix << "'; expected one of ";
541 ListSeparator LS;
542 for (const auto &[Name, Val] : ASNames)
543 OS << LS << '\'' << Name << '\'';
544 DiagFn->getContext().diagnose(
545 DiagnosticInfoUnsupported(*DiagFn, Str, DL, DS_Warning));
546 }
547 }
548
549 if (Result == SIAtomicAddrSpace::NONE)
551
552 return Result;
553}
554
558
559} // end namespace llvm::AMDGPU
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU address space definition.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
#define F(x, y, z)
Definition MD5.cpp:54
This file provides utility for Memory Model Relaxation Annotations (MMRAs).
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
uint64_t IntrinsicInst * II
This file defines generic set operations that may be used on set's of different types,...
#define LLVM_DEBUG(...)
Definition Debug.h:119
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
std::pair< std::optional< WeakTrackingVH >, CallGraphNode * > CallRecord
A pair of the calling instruction (a call or invoke) and the call graph node being called.
Definition CallGraph.h:174
The basic data container for the call graph of a Module of IR.
Definition CallGraph.h:72
CallGraphNode * getExternalCallingNode() const
Returns the CallGraphNode which is used to represent undetermined calls into the callgraph.
Definition CallGraph.h:127
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
Implements a dense probed hash-table based set.
Definition DenseSet.h:283
Diagnostic information for unsupported feature in backend.
const Function & getFunction() const
Definition Function.h:167
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
Definition Function.cpp:689
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Definition Function.cpp:352
unsigned getAddressSpace() 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.
LLVM_ABI uint64_t getGlobalSize(const DataLayout &DL) const
Get the size of this global variable in bytes.
Definition Globals.cpp:640
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
A wrapper class for inspecting calls to intrinsic functions.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
A helper class to return the specified delimiter string after the first invocation of operator String...
An instruction for reading from memory.
Helper class to manipulate !mmra metadata nodes.
bool contains(const KeyT &Key) const
Definition MapVector.h:149
Represents a read-write access to memory, whether it is a must-alias, or a may-alias.
Definition MemorySSA.h:369
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
Represents phi nodes for memory accesses.
Definition MemorySSA.h:473
This is the generic walker interface for walkers of MemorySSA.
Definition MemorySSA.h:1020
MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
Definition MemorySSA.h:1049
Encapsulates MemorySSA, including all data associated with memory accesses.
Definition MemorySSA.h:689
LLVM_ABI MemorySSAWalker * getWalker()
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
Definition MemorySSA.h:707
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
Definition MemorySSA.h:727
Class that has the common methods + fields of memory uses/defs.
Definition MemorySSA.h:252
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition StringRef.h:888
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent target extensions types, which are generally unintrospectable from target-independ...
StringRef getName() const
Return the name for this target extension type.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM_ABI 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.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition Value.cpp:985
std::pair< iterator, bool > insert(const ValueT &V)
Definition DenseSet.h:210
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
Definition DenseSet.h:183
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an SmallVector or SmallString.
Abstract Attribute helper functions.
Definition Attributor.h:166
@ BARRIER
Address space for modeling barrier IDs as addresses.
@ LOCAL_ADDRESS
Address space for local memory.
@ VGPR
Address space for VGPRs.
GVUsesInfoTy getTransitiveUsesOfLDSForLowering(const CallGraph &CG, Module &M)
Collects all uses of LDS Global Variables in M using getUsesOfGVByFunction, with isLDSVariableToLower...
static constexpr unsigned NamedBarrierTypeSizeInBytes
SIAtomicAddrSpace toSIAtomicAddrSpace(unsigned LLVMAddrSpace)
bool isDynamicLDS(const GlobalVariable &GV)
static const StringMap< SIAtomicAddrSpace > ASNames
void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot, ArrayRef< StringRef > FnAttrs)
Strip FnAttr attribute from any functions where we may have introduced its use.
bool eliminateGVConstantExprUsesFromAllInstructions(Module &M, function_ref< bool(const GlobalVariable &)> Filter)
Iterates over all GlobalVariables in M, and whenever Filter returns true, replace all constant users ...
LLVM_READNONE constexpr bool isKernel(CallingConv::ID CC)
SIAtomicAddrSpace
The distinct address spaces supported by the AMDGPU target for atomic memory operation.
@ ATOMIC
The address spaces that support atomic instructions.
@ FLAT
The address spaces that can be accessed by a FLAT instruction.
void getUsesOfGVByFunction(const CallGraph &CG, Module &M, function_ref< bool(const GlobalVariable &)> Filter, FunctionVariableMap &Kernels, FunctionVariableMap &Functions)
Finds uses of Global Variables on a per-function basis.
SIAtomicAddrSpace getSynchronizeAddrSpace(const MMRAMetadata &MMRA, const Function *DiagFn, const DebugLoc &DL)
Parses the values for the "amdgpu-synchronize-as" MMRA.
static constexpr SIAtomicAddrSpace LLVMToSIAtomicAddrSpaceMapping[]
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...
static TargetExtType * getTargetExtType(const GlobalVariable &GV)
MapVector< Function *, DenseSet< GlobalVariable * > > FunctionVariableMap
TargetExtType * isNamedBarrier(const GlobalVariable &GV)
bool isLDSVariableToLower(const GlobalVariable &GV)
Align getAlign(const DataLayout &DL, const GlobalVariable *GV)
unsigned getNumNamedBarriersDeclared(const DataLayout &DL, const GlobalVariable &GV)
unsigned getSyntheticApertureNumber(unsigned AS)
void copyMetadataForWidenedLoad(LoadInst &Dest, const LoadInst &Source)
bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, AAResults *AA)
Check is a Load is clobbered in its function.
GVUsesInfoTy getTransitiveUsesOfGV(const CallGraph &CG, Module &M, function_ref< bool(const GlobalVariable &)> Filter)
Collects all uses of Global Variables in M using getUsesOfGVByFunction.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
@ Load
The value being inserted comes from a load (InsertElement only).
LLVM_ABI bool convertUsersOfConstantsToInstructions(ArrayRef< Constant * > Consts, Function *RestrictToFunc=nullptr, bool RemoveDeadConstants=true, bool IncludeSelf=false)
Replace constant expressions users of the given constants with instructions.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
bool set_union(S1Ty &S1, const S2Ty &S2)
set_union(A, B) - Compute A := A u B, return whether A changed.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
bool isAcquireOrStronger(AtomicOrdering AO)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
#define N
FunctionVariableMap DirectAccess
FunctionVariableMap IndirectAccess
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39