19#include "llvm/IR/IntrinsicsAMDGPU.h"
20#include "llvm/IR/IntrinsicsR600.h"
24#define DEBUG_TYPE "amdgpu-attributor"
33 "amdgpu-kernarg-preload-count",
36#define AMDGPU_ATTRIBUTE(Name, Str) Name##_POS,
39 #include "AMDGPUAttributes.def"
43#define AMDGPU_ATTRIBUTE(Name, Str) Name = 1 << Name##_POS,
47 #include "AMDGPUAttributes.def"
51#define AMDGPU_ATTRIBUTE(Name, Str) {Name, Str},
54 #include "AMDGPUAttributes.def"
64 bool HasApertureRegs,
bool SupportsGetDoorBellID,
65 unsigned CodeObjectVersion) {
67 case Intrinsic::amdgcn_workitem_id_x:
70 case Intrinsic::amdgcn_workgroup_id_x:
72 return WORKGROUP_ID_X;
73 case Intrinsic::amdgcn_workitem_id_y:
74 case Intrinsic::r600_read_tidig_y:
76 case Intrinsic::amdgcn_workitem_id_z:
77 case Intrinsic::r600_read_tidig_z:
79 case Intrinsic::amdgcn_workgroup_id_y:
80 case Intrinsic::r600_read_tgid_y:
81 return WORKGROUP_ID_Y;
82 case Intrinsic::amdgcn_workgroup_id_z:
83 case Intrinsic::r600_read_tgid_z:
84 return WORKGROUP_ID_Z;
85 case Intrinsic::amdgcn_lds_kernel_id:
87 case Intrinsic::amdgcn_dispatch_ptr:
89 case Intrinsic::amdgcn_dispatch_id:
91 case Intrinsic::amdgcn_implicitarg_ptr:
92 return IMPLICIT_ARG_PTR;
95 case Intrinsic::amdgcn_queue_ptr:
98 case Intrinsic::amdgcn_is_shared:
99 case Intrinsic::amdgcn_is_private:
107 case Intrinsic::trap:
108 if (SupportsGetDoorBellID)
134 return F.hasFnAttribute(Attribute::SanitizeAddress) ||
135 F.hasFnAttribute(Attribute::SanitizeThread) ||
136 F.hasFnAttribute(Attribute::SanitizeMemory) ||
137 F.hasFnAttribute(Attribute::SanitizeHWAddress) ||
138 F.hasFnAttribute(Attribute::SanitizeMemTag);
152 enum ConstantStatus { DS_GLOBAL = 1 << 0, ADDR_SPACE_CAST = 1 << 1 };
157 return ST.hasApertureRegs();
161 bool supportsGetDoorbellID(
Function &
F) {
163 return ST.supportsGetDoorbellID();
166 std::pair<unsigned, unsigned> getFlatWorkGroupSizes(
const Function &
F) {
168 return ST.getFlatWorkGroupSizes(
F);
171 std::pair<unsigned, unsigned>
172 getMaximumFlatWorkGroupRange(
const Function &
F) {
174 return {
ST.getMinFlatWorkGroupSize(),
ST.getMaxFlatWorkGroupSize()};
178 unsigned getCodeObjectVersion()
const {
179 return CodeObjectVersion;
185 std::pair<unsigned, unsigned>
187 std::pair<unsigned, unsigned> FlatWorkGroupSize) {
189 return ST.getWavesPerEU(
F, FlatWorkGroupSize);
192 std::pair<unsigned, unsigned>
193 getEffectiveWavesPerEU(
const Function &
F,
194 std::pair<unsigned, unsigned> WavesPerEU,
195 std::pair<unsigned, unsigned> FlatWorkGroupSize) {
197 return ST.getEffectiveWavesPerEU(WavesPerEU, FlatWorkGroupSize);
202 return ST.getMaxWavesPerEU();
208 if (
CE->getOpcode() == Instruction::AddrSpaceCast) {
209 unsigned SrcAS =
CE->getOperand(0)->getType()->getPointerAddressSpace();
216 uint8_t getConstantAccess(
const Constant *
C,
218 auto It = ConstantStatus.find(
C);
219 if (It != ConstantStatus.end())
226 if (
const auto *CE = dyn_cast<ConstantExpr>(
C))
227 if (visitConstExpr(CE))
228 Result |= ADDR_SPACE_CAST;
230 for (
const Use &U :
C->operands()) {
231 const auto *OpC = dyn_cast<Constant>(U);
232 if (!OpC || !Visited.
insert(OpC).second)
235 Result |= getConstantAccess(OpC, Visited);
244 bool HasAperture = hasApertureRegs(Fn);
247 if (!IsNonEntryFunc && HasAperture)
251 uint8_t Access = getConstantAccess(
C, Visited);
254 if (IsNonEntryFunc && (Access & DS_GLOBAL))
257 return !HasAperture && (Access & ADDR_SPACE_CAST);
263 const unsigned CodeObjectVersion;
266struct AAAMDAttributes
267 :
public StateWrapper<BitIntegerState<uint32_t, ALL_ARGUMENT_MASK, 0>,
275 static AAAMDAttributes &createForPosition(
const IRPosition &IRP,
279 const std::string
getName()
const override {
return "AAAMDAttributes"; }
282 const char *getIdAddr()
const override {
return &
ID; }
291 static const char ID;
293const char AAAMDAttributes::ID = 0;
295struct AAUniformWorkGroupSize
296 :
public StateWrapper<BooleanState, AbstractAttribute> {
301 static AAUniformWorkGroupSize &createForPosition(
const IRPosition &IRP,
305 const std::string
getName()
const override {
306 return "AAUniformWorkGroupSize";
310 const char *getIdAddr()
const override {
return &
ID; }
319 static const char ID;
321const char AAUniformWorkGroupSize::ID = 0;
323struct AAUniformWorkGroupSizeFunction :
public AAUniformWorkGroupSize {
325 : AAUniformWorkGroupSize(IRP,
A) {}
334 bool InitialValue =
false;
335 if (
F->hasFnAttribute(
"uniform-work-group-size"))
337 F->getFnAttribute(
"uniform-work-group-size").getValueAsString() ==
341 indicateOptimisticFixpoint();
343 indicatePessimisticFixpoint();
352 <<
"->" << getAssociatedFunction()->
getName() <<
"\n");
354 const auto *CallerInfo =
A.getAAFor<AAUniformWorkGroupSize>(
360 CallerInfo->getState());
365 bool AllCallSitesKnown =
true;
366 if (!
A.checkForAllCallSites(CheckCallSite, *
this,
true, AllCallSitesKnown))
367 return indicatePessimisticFixpoint();
374 LLVMContext &Ctx = getAssociatedFunction()->getContext();
377 getAssumed() ?
"true" :
"false"));
378 return A.manifestAttrs(getIRPosition(), AttrList,
382 bool isValidState()
const override {
387 const std::string getAsStr(
Attributor *)
const override {
388 return "AMDWorkGroupSize[" + std::to_string(getAssumed()) +
"]";
392 void trackStatistics()
const override {}
395AAUniformWorkGroupSize &
396AAUniformWorkGroupSize::createForPosition(
const IRPosition &IRP,
399 return *
new (
A.Allocator) AAUniformWorkGroupSizeFunction(IRP,
A);
401 "AAUniformWorkGroupSize is only valid for function position");
404struct AAAMDAttributesFunction :
public AAAMDAttributes {
406 : AAAMDAttributes(IRP,
A) {}
415 removeAssumedBits(IMPLICIT_ARG_PTR);
416 removeAssumedBits(HOSTCALL_PTR);
421 (Attr.first == IMPLICIT_ARG_PTR || Attr.first == HOSTCALL_PTR))
424 if (
F->hasFnAttribute(Attr.second))
425 addKnownBits(Attr.first);
428 if (
F->isDeclaration())
434 indicatePessimisticFixpoint();
442 auto OrigAssumed = getAssumed();
446 *
this, this->getIRPosition(), DepClassTy::REQUIRED);
448 return indicatePessimisticFixpoint();
452 bool NeedsImplicit =
false;
453 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
454 bool HasApertureRegs = InfoCache.hasApertureRegs(*
F);
455 bool SupportsGetDoorbellID = InfoCache.supportsGetDoorbellID(*
F);
456 unsigned COV = InfoCache.getCodeObjectVersion();
461 const AAAMDAttributes *AAAMD =
A.getAAFor<AAAMDAttributes>(
464 return indicatePessimisticFixpoint();
469 bool NonKernelOnly =
false;
472 HasApertureRegs, SupportsGetDoorbellID, COV);
474 if ((IsNonEntryFunc || !NonKernelOnly))
475 removeAssumedBits(AttrMask);
481 removeAssumedBits(IMPLICIT_ARG_PTR);
483 if (isAssumed(QUEUE_PTR) && checkForQueuePtr(
A)) {
487 removeAssumedBits(IMPLICIT_ARG_PTR);
489 removeAssumedBits(QUEUE_PTR);
492 if (funcRetrievesMultigridSyncArg(
A, COV)) {
493 assert(!isAssumed(IMPLICIT_ARG_PTR) &&
494 "multigrid_sync_arg needs implicitarg_ptr");
495 removeAssumedBits(MULTIGRID_SYNC_ARG);
498 if (funcRetrievesHostcallPtr(
A, COV)) {
499 assert(!isAssumed(IMPLICIT_ARG_PTR) &&
"hostcall needs implicitarg_ptr");
500 removeAssumedBits(HOSTCALL_PTR);
503 if (funcRetrievesHeapPtr(
A, COV)) {
504 assert(!isAssumed(IMPLICIT_ARG_PTR) &&
"heap_ptr needs implicitarg_ptr");
505 removeAssumedBits(HEAP_PTR);
508 if (isAssumed(QUEUE_PTR) && funcRetrievesQueuePtr(
A, COV)) {
509 assert(!isAssumed(IMPLICIT_ARG_PTR) &&
"queue_ptr needs implicitarg_ptr");
510 removeAssumedBits(QUEUE_PTR);
513 if (isAssumed(LDS_KERNEL_ID) && funcRetrievesLDSKernelId(
A)) {
514 removeAssumedBits(LDS_KERNEL_ID);
517 if (isAssumed(DEFAULT_QUEUE) && funcRetrievesDefaultQueue(
A, COV))
518 removeAssumedBits(DEFAULT_QUEUE);
520 if (isAssumed(COMPLETION_ACTION) && funcRetrievesCompletionAction(
A, COV))
521 removeAssumedBits(COMPLETION_ACTION);
523 return getAssumed() != OrigAssumed ? ChangeStatus::CHANGED
524 : ChangeStatus::UNCHANGED;
529 LLVMContext &Ctx = getAssociatedFunction()->getContext();
532 if (isKnown(Attr.first))
536 return A.manifestAttrs(getIRPosition(), AttrList,
540 const std::string getAsStr(
Attributor *)
const override {
545 if (isAssumed(Attr.first))
546 OS <<
' ' << Attr.second;
552 void trackStatistics()
const override {}
559 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
561 bool NeedsQueuePtr =
false;
566 NeedsQueuePtr =
true;
572 bool HasApertureRegs = InfoCache.hasApertureRegs(*
F);
578 if (!HasApertureRegs) {
579 bool UsedAssumedInformation =
false;
580 A.checkForAllInstructions(CheckAddrSpaceCasts, *
this,
581 {Instruction::AddrSpaceCast},
582 UsedAssumedInformation);
589 if (!IsNonEntryFunc && HasApertureRegs)
594 for (
const Use &U :
I.operands()) {
595 if (
const auto *
C = dyn_cast<Constant>(U)) {
596 if (InfoCache.needsQueuePtr(
C, *
F))
606 bool funcRetrievesMultigridSyncArg(
Attributor &
A,
unsigned COV) {
609 return funcRetrievesImplicitKernelArg(
A,
Range);
612 bool funcRetrievesHostcallPtr(
Attributor &
A,
unsigned COV) {
615 return funcRetrievesImplicitKernelArg(
A,
Range);
618 bool funcRetrievesDefaultQueue(
Attributor &
A,
unsigned COV) {
621 return funcRetrievesImplicitKernelArg(
A,
Range);
624 bool funcRetrievesCompletionAction(
Attributor &
A,
unsigned COV) {
627 return funcRetrievesImplicitKernelArg(
A,
Range);
630 bool funcRetrievesHeapPtr(
Attributor &
A,
unsigned COV) {
634 return funcRetrievesImplicitKernelArg(
A,
Range);
637 bool funcRetrievesQueuePtr(
Attributor &
A,
unsigned COV) {
641 return funcRetrievesImplicitKernelArg(
A,
Range);
652 auto &
Call = cast<CallBase>(
I);
653 if (
Call.getIntrinsicID() != Intrinsic::amdgcn_implicitarg_ptr)
667 bool UsedAssumedInformation =
false;
668 return !
A.checkForAllCallLikeInstructions(DoesNotLeadToKernelArgLoc, *
this,
669 UsedAssumedInformation);
674 auto &
Call = cast<CallBase>(
I);
675 return Call.getIntrinsicID() != Intrinsic::amdgcn_lds_kernel_id;
677 bool UsedAssumedInformation =
false;
678 return !
A.checkForAllCallLikeInstructions(DoesNotRetrieve, *
this,
679 UsedAssumedInformation);
683AAAMDAttributes &AAAMDAttributes::createForPosition(
const IRPosition &IRP,
686 return *
new (
A.Allocator) AAAMDAttributesFunction(IRP,
A);
691struct AAAMDSizeRangeAttribute
692 :
public StateWrapper<IntegerRangeState, AbstractAttribute, uint32_t> {
699 :
Base(IRP, 32), AttrName(AttrName) {}
702 void trackStatistics()
const override {}
704 template <
class AttributeImpl>
711 <<
"->" << getAssociatedFunction()->
getName() <<
'\n');
724 bool AllCallSitesKnown =
true;
725 if (!
A.checkForAllCallSites(CheckCallSite, *
this,
true, AllCallSitesKnown))
726 return indicatePessimisticFixpoint();
734 if (getAssumed().getLower() == Min && getAssumed().getUpper() - 1 == Max)
741 OS << getAssumed().getLower() <<
',' << getAssumed().getUpper() - 1;
742 return A.manifestAttrs(getIRPosition(),
747 const std::string getAsStr(
Attributor *)
const override {
751 OS << getAssumed().getLower() <<
',' << getAssumed().getUpper() - 1;
758struct AAAMDFlatWorkGroupSize :
public AAAMDSizeRangeAttribute {
760 : AAAMDSizeRangeAttribute(IRP,
A,
"amdgpu-flat-work-group-size") {}
764 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
765 unsigned MinGroupSize, MaxGroupSize;
766 std::tie(MinGroupSize, MaxGroupSize) = InfoCache.getFlatWorkGroupSizes(*
F);
771 indicatePessimisticFixpoint();
775 return updateImplImpl<AAAMDFlatWorkGroupSize>(
A);
779 static AAAMDFlatWorkGroupSize &createForPosition(
const IRPosition &IRP,
784 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
786 std::tie(Min, Max) = InfoCache.getMaximumFlatWorkGroupRange(*
F);
787 return emitAttributeIfNotDefault(
A, Min, Max);
791 const std::string
getName()
const override {
792 return "AAAMDFlatWorkGroupSize";
796 const char *getIdAddr()
const override {
return &
ID; }
805 static const char ID;
808const char AAAMDFlatWorkGroupSize::ID = 0;
810AAAMDFlatWorkGroupSize &
811AAAMDFlatWorkGroupSize::createForPosition(
const IRPosition &IRP,
814 return *
new (
A.Allocator) AAAMDFlatWorkGroupSize(IRP,
A);
816 "AAAMDFlatWorkGroupSize is only valid for function position");
820struct AAAMDWavesPerEU :
public AAAMDSizeRangeAttribute {
822 : AAAMDSizeRangeAttribute(IRP,
A,
"amdgpu-waves-per-eu") {}
824 bool isValidState()
const override {
830 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
832 if (
const auto *AssumedGroupSize =
A.getAAFor<AAAMDFlatWorkGroupSize>(
836 std::tie(Min, Max) = InfoCache.getWavesPerEU(
837 *
F, {AssumedGroupSize->getAssumed().getLower().getZExtValue(),
838 AssumedGroupSize->getAssumed().getUpper().getZExtValue() - 1});
841 intersectKnown(
Range);
845 indicatePessimisticFixpoint();
849 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
856 <<
"->" <<
Func->getName() <<
'\n');
858 const auto *CallerInfo =
A.getAAFor<AAAMDWavesPerEU>(
860 const auto *AssumedGroupSize =
A.getAAFor<AAAMDFlatWorkGroupSize>(
862 if (!CallerInfo || !AssumedGroupSize)
866 std::tie(Min, Max) = InfoCache.getEffectiveWavesPerEU(
868 {CallerInfo->getAssumed().getLower().getZExtValue(),
869 CallerInfo->getAssumed().getUpper().getZExtValue() - 1},
870 {AssumedGroupSize->getAssumed().getLower().getZExtValue(),
871 AssumedGroupSize->getAssumed().getUpper().getZExtValue() - 1});
879 bool AllCallSitesKnown =
true;
880 if (!
A.checkForAllCallSites(CheckCallSite, *
this,
true, AllCallSitesKnown))
881 return indicatePessimisticFixpoint();
887 static AAAMDWavesPerEU &createForPosition(
const IRPosition &IRP,
892 auto &InfoCache =
static_cast<AMDGPUInformationCache &
>(
A.getInfoCache());
893 unsigned Max = InfoCache.getMaxWavesPerEU(*
F);
894 return emitAttributeIfNotDefault(
A, 1, Max);
898 const std::string
getName()
const override {
return "AAAMDWavesPerEU"; }
901 const char *getIdAddr()
const override {
return &
ID; }
910 static const char ID;
913const char AAAMDWavesPerEU::ID = 0;
915AAAMDWavesPerEU &AAAMDWavesPerEU::createForPosition(
const IRPosition &IRP,
918 return *
new (
A.Allocator) AAAMDWavesPerEU(IRP,
A);
922static bool inlineAsmUsesAGPRs(
const InlineAsm *IA) {
923 for (
const auto &CI :
IA->ParseConstraints()) {
925 Code.consume_front(
"{");
926 if (
Code.starts_with(
"a"))
936 StateWrapper<BooleanState, AbstractAttribute>,
940 static AAAMDGPUNoAGPR &createForPosition(
const IRPosition &IRP,
943 return *
new (
A.Allocator) AAAMDGPUNoAGPR(IRP,
A);
949 if (
F->hasFnAttribute(
"amdgpu-no-agpr"))
950 indicateOptimisticFixpoint();
953 const std::string getAsStr(
Attributor *
A)
const override {
954 return getAssumed() ?
"amdgpu-no-agpr" :
"amdgpu-maybe-agpr";
957 void trackStatistics()
const override {}
963 const auto &CB = cast<CallBase>(
I);
964 const Value *CalleeOp = CB.getCalledOperand();
967 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(CalleeOp))
968 return !inlineAsmUsesAGPRs(IA);
974 if (
Callee->isIntrinsic())
978 const auto *
CalleeInfo =
A.getAAFor<AAAMDGPUNoAGPR>(
983 bool UsedAssumedInformation =
false;
984 if (!
A.checkForAllCallLikeInstructions(CheckForNoAGPRs, *
this,
985 UsedAssumedInformation))
986 return indicatePessimisticFixpoint();
993 LLVMContext &Ctx = getAssociatedFunction()->getContext();
994 return A.manifestAttrs(getIRPosition(),
998 const std::string
getName()
const override {
return "AAAMDGPUNoAGPR"; }
999 const char *getIdAddr()
const override {
return &
ID; }
1007 static const char ID;
1010const char AAAMDGPUNoAGPR::ID = 0;
1014 for (
unsigned I = 0;
1023 Arg.
addAttr(Attribute::InReg);
1031 if (!
F.isIntrinsic())
1037 AMDGPUInformationCache InfoCache(M, AG, Allocator,
nullptr, TM);
1039 {&AAAMDAttributes::ID, &AAUniformWorkGroupSize::ID,
1047 AC.IsClosedWorldModule =
Options.IsClosedWorld;
1049 AC.IsModulePass =
true;
1050 AC.DefaultInitializeLiveInternals =
false;
1051 AC.IndirectCalleeSpecializationCallback =
1057 if (NumAssumedCallees == 1)
1060 const auto &
TTI =
TM.getTargetTransformInfo(*CB.getCaller());
1063 AC.IPOAmendableCB = [](
const Function &
F) {
1070 if (
F.isIntrinsic())
1081 addPreloadKernArgHint(
F, TM);
1085 if (
auto *LI = dyn_cast<LoadInst>(&
I)) {
1089 if (
auto *SI = dyn_cast<StoreInst>(&
I)) {
1097 return Change == ChangeStatus::CHANGED;
1100class AMDGPUAttributorLegacy :
public ModulePass {
1107 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
1117 return runImpl(M, AG, *TM, {});
1142char AMDGPUAttributorLegacy::ID = 0;
1145 return new AMDGPUAttributorLegacy();
static cl::opt< unsigned > KernargPreloadCount("amdgpu-kernarg-preload-count", cl::desc("How many kernel arguments to preload onto SGPRs"), cl::init(0))
static bool isDSAddress(const Constant *C)
static constexpr std::pair< ImplicitArgumentMask, StringLiteral > ImplicitAttrs[]
static ImplicitArgumentMask intrinsicToAttrMask(Intrinsic::ID ID, bool &NonKernelOnly, bool &NeedsImplicit, bool HasApertureRegs, bool SupportsGetDoorBellID, unsigned CodeObjectVersion)
static bool funcRequiresHostcallPtr(const Function &F)
Returns true if the function requires the implicit argument be passed regardless of the function cont...
ImplicitArgumentPositions
static bool castRequiresQueuePtr(unsigned SrcAS)
Expand Atomic instructions
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
static bool runImpl(Function &F, const TargetLowering &TLI)
AMD GCN specific subclass of TargetSubtarget.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Target-Independent Code Generator Pass Configuration Options pass.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Class for arbitrary precision integers.
This class represents a conversion between pointers from one address space to another.
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
This class represents an incoming formal argument to a Function.
bool hasByRefAttr() const
Return true if this argument has the byref attribute.
void addAttr(Attribute::AttrKind Kind)
bool hasNestAttr() const
Return true if this argument has the nest attribute.
static Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
LLVM Basic Block Representation.
Allocate memory in an ever growing pool, as if by bump-pointer.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Wrapper to unify "old style" CallGraph and "new style" LazyCallGraph.
A constant value that is initialized with an expression using other constant values.
This class represents a range of values.
This is an important base class in LLVM.
Legacy analysis pass which computes a CycleInfo.
Implements a dense probed hash-table based set.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned getAddressSpace() const
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
This is an important class for using LLVM in a threaded context.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
virtual bool runOnModule(Module &M)=0
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
A Module instance is used to store all the information related to an LLVM module.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Pass interface - Implemented by all 'passes'.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A vector that has set insertion semantics.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
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...
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...
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
A Use represents the edge between a Value definition and its users.
bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
LLVM Value Representation.
A raw_ostream that writes to an std::string.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ REGION_ADDRESS
Address space for region memory. (GDS)
@ LOCAL_ADDRESS
Address space for local memory.
@ PRIVATE_ADDRESS
Address space for private memory.
unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI)
bool isEntryFunctionCC(CallingConv::ID CC)
unsigned getAMDHSACodeObjectVersion(const Module &M)
unsigned getDefaultQueueImplicitArgPosition(unsigned CodeObjectVersion)
unsigned getHostcallImplicitArgPosition(unsigned CodeObjectVersion)
unsigned getCompletionActionImplicitArgPosition(unsigned CodeObjectVersion)
unsigned getMultigridSyncArgImplicitArgPosition(unsigned CodeObjectVersion)
bool isGraphics(CallingConv::ID cc)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ C
The default llvm calling convention, compatible with C.
@ CE
Windows NT (Windows on ARM)
initializer< Ty > init(const Ty &Val)
NodeAddr< FuncNode * > Func
NodeAddr< CodeNode * > Code
This is an optimization pass for GlobalISel generic memory operations.
void initializeCycleInfoWrapperPassPass(PassRegistry &)
Pass * createAMDGPUAttributorLegacyPass()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
ChangeStatus clampStateAndIndicateChange(StateType &S, const StateType &R)
Helper function to clamp a state S of type StateType with the information in R and indicate/return if...
@ REQUIRED
The target cannot be valid if the source is not.
An abstract interface for address space information.
static const char ID
Unique ID (due to the unique address)
An abstract state for querying live call edges.
virtual const SetVector< Function * > & getOptimisticEdges() const =0
Get the optimistic edges.
static const char ID
Unique ID (due to the unique address)
virtual bool hasNonAsmUnknownCallee() const =0
Is there any call with a unknown callee, excluding any inline asm.
static const char ID
Unique ID (due to the unique address)
static const char ID
Unique ID (due to the unique address)
Instruction * getRemoteInst() const
Return the actual instruction that causes the access.
An abstract interface for struct information.
virtual bool forallInterferingAccesses(AA::RangeTy Range, function_ref< bool(const Access &, bool)> CB) const =0
Call CB on all accesses that might interfere with Range and return true if all such accesses were kno...
static const char ID
Unique ID (due to the unique address)
static const char ID
Unique ID (due to the unique address)
static const char ID
Unique ID (due to the unique address)
static const char ID
Unique ID (due to the unique address)
Helper to represent an access offset and size, with logic to deal with uncertainty and check for over...
Base struct for all "concrete attribute" deductions.
virtual const char * getIdAddr() const =0
This function should return the address of the ID of the AbstractAttribute.
Wrapper for FunctionAnalysisManager.
Configuration for the Attributor.
The fixpoint analysis framework that orchestrates the attribute deduction.
Class to accumulate and hold information about a callee.
Helper class that provides common functionality to manifest IR attributes.
ChangeStatus manifest(Attributor &A) override
See AbstractAttribute::manifest(...).
Helper to describe and deal with positions in the LLVM-IR.
static const IRPosition callsite_returned(const CallBase &CB)
Create a position describing the returned value of CB.
static const IRPosition value(const Value &V, const CallBaseContext *CBContext=nullptr)
Create a position describing the value of V.
@ IRP_FUNCTION
An attribute for a function (scope).
static const IRPosition function(const Function &F, const CallBaseContext *CBContext=nullptr)
Create a position describing the function scope of F.
Kind getPositionKind() const
Return the associated position kind.
State for an integer range.
bool isValidState() const override
See AbstractState::isValidState()
Helper to tie a abstract state implementation to an abstract attribute.
StateType & getState() override
See AbstractAttribute::getState(...).