20#include "llvm/IR/IntrinsicsAMDGPU.h"
21#include "llvm/IR/IntrinsicsR600.h"
24#define DEBUG_TYPE "amdgpu-annotate-kernel-features"
44 return "AMDGPU Annotate Kernel Features";
55char AMDGPUAnnotateKernelFeatures::ID = 0;
60 "Add AMDGPU function attributes",
false,
false)
62bool AMDGPUAnnotateKernelFeatures::addFeatureAttributes(
Function &
F) {
63 bool HaveStackObjects =
false;
65 bool HaveCall =
false;
70 if (isa<AllocaInst>(
I)) {
71 HaveStackObjects =
true;
75 if (
auto *CB = dyn_cast<CallBase>(&
I)) {
77 dyn_cast<Function>(CB->getCalledOperand()->stripPointerCasts());
81 if (!CB->isInlineAsm())
99 if (!IsFunc && HaveCall) {
100 F.addFnAttr(
"amdgpu-calls");
104 if (HaveStackObjects) {
105 F.addFnAttr(
"amdgpu-stack-objects");
112bool AMDGPUAnnotateKernelFeatures::runOnSCC(
CallGraphSCC &SCC) {
113 bool Changed =
false;
122 Changed |= addFeatureAttributes(*
F);
128bool AMDGPUAnnotateKernelFeatures::doInitialization(
CallGraph &CG) {
129 auto *TPC = getAnalysisIfAvailable<TargetPassConfig>();
138 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.