22#define DEBUG_TYPE "amdgpu-annotate-kernel-features"
42 return "AMDGPU Annotate Kernel Features";
53char AMDGPUAnnotateKernelFeatures::ID = 0;
58 "Add AMDGPU function attributes",
false,
false)
60bool AMDGPUAnnotateKernelFeatures::addFeatureAttributes(
Function &
F) {
61 bool HaveStackObjects =
false;
63 bool HaveCall =
false;
68 if (isa<AllocaInst>(
I)) {
69 HaveStackObjects =
true;
73 if (
auto *CB = dyn_cast<CallBase>(&
I)) {
75 dyn_cast<Function>(CB->getCalledOperand()->stripPointerCasts());
79 if (!CB->isInlineAsm())
97 if (!IsFunc && HaveCall) {
98 F.addFnAttr(
"amdgpu-calls");
102 if (HaveStackObjects) {
103 F.addFnAttr(
"amdgpu-stack-objects");
110bool AMDGPUAnnotateKernelFeatures::runOnSCC(
CallGraphSCC &SCC) {
111 bool Changed =
false;
120 Changed |= addFeatureAttributes(*
F);
126bool AMDGPUAnnotateKernelFeatures::doInitialization(
CallGraph &CG) {
127 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
136 return new AMDGPUAnnotateKernelFeatures();
This file provides interfaces used to build and manipulate a call graph, which is a very useful tool ...
AMD GCN specific subclass of TargetSubtarget.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Target-Independent Code Generator Pass Configuration Options pass.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM Basic Block Representation.
A node in the call graph for a module.
virtual bool runOnSCC(CallGraphSCC &SCC)=0
runOnSCC - This method should be implemented by the subclass to perform whatever action is necessary ...
void getAnalysisUsage(AnalysisUsage &Info) const override
getAnalysisUsage - For this class, we declare that we require and preserve the call graph.
virtual bool doInitialization(CallGraph &CG)
doInitialization - This method is called before the SCC's of the program has been processed,...
CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.
The basic data container for the call graph of a Module of IR.
Pass interface - Implemented by all 'passes'.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
bool isEntryFunctionCC(CallingConv::ID CC)
bool isGraphics(CallingConv::ID cc)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
char & AMDGPUAnnotateKernelFeaturesID
Pass * createAMDGPUAnnotateKernelFeaturesPass()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.