LLVM: lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
22
23using namespace llvm;
24
25namespace {
26
28 "amdgpu-stress-function-calls",
30 cl::desc("Force all functions to be noinline"),
32
33class AMDGPUAlwaysInline : public ModulePass {
34 bool GlobalOpt;
35
36public:
37 static char ID;
38
39 AMDGPUAlwaysInline(bool GlobalOpt = false) :
40 ModulePass(ID), GlobalOpt(GlobalOpt) { }
41 bool runOnModule(Module &M) override;
42
43 void getAnalysisUsage(AnalysisUsage &AU) const override {
45 }
46};
47
48}
49
50INITIALIZE_PASS(AMDGPUAlwaysInline, "amdgpu-always-inline",
51 "AMDGPU Inline All Functions", false, false)
52
53char AMDGPUAlwaysInline::ID = 0;
54
55static void
59
61
62 while (!Stack.empty()) {
63 User *U = Stack.pop_back_val();
64 if (!Visited.insert(U).second)
65 continue;
66
70
71
72
73
74
75 F->removeFnAttr(Attribute::NoInline);
76
77 FuncsToAlwaysInline.insert(F);
78 Stack.push_back(F);
79 }
80
81
82 continue;
83 }
84
86 }
87}
88
90 std::vector<GlobalAlias*> AliasesToRemove;
91
95 Triple TT(M.getTargetTriple());
96
100 continue;
103 AliasesToRemove.push_back(&A);
104 }
105
106
107
108 }
109
110 if (GlobalOpt) {
112 A->eraseFromParent();
113 }
114 }
115
116
117
118
119
120
121
122
123
124
125
127
128 unsigned AS = GV.getAddressSpace();
133 }
134
136 auto IncompatAttr
137 = StressCalls ? Attribute::AlwaysInline : Attribute::NoInline;
138
140 if (.isDeclaration() &&
.use_empty() &&
141 .hasFnAttribute(IncompatAttr)) {
142 if (StressCalls) {
143 if (!FuncsToAlwaysInline.count(&F))
144 FuncsToNoInline.insert(&F);
145 } else
146 FuncsToAlwaysInline.insert(&F);
147 }
148 }
149 }
150
151 for (Function *F : FuncsToAlwaysInline)
152 F->addFnAttr(Attribute::AlwaysInline);
153
154 for (Function *F : FuncsToNoInline)
155 F->addFnAttr(Attribute::NoInline);
156
157 return Changed || !FuncsToAlwaysInline.empty() || !FuncsToNoInline.empty();
158}
159
160bool AMDGPUAlwaysInline::runOnModule(Module &M) {
162}
163
165 return new AMDGPUAlwaysInline(GlobalOpt);
166}
167
static bool alwaysInlineImpl(Module &M, bool GlobalOpt)
Definition AMDGPUAlwaysInlinePass.cpp:89
static INITIALIZE_PASS(AMDGPUAlwaysInline, "amdgpu-always-inline", "AMDGPU Inline All Functions", false, false) char AMDGPUAlwaysInline void recursivelyVisitUsers(GlobalValue &GV, SmallPtrSetImpl< Function * > &FuncsToAlwaysInline)
Definition AMDGPUAlwaysInlinePass.cpp:56
The AMDGPU TargetMachine interface definition for hw codegen targets.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool EnableFunctionCalls
static bool EnableLowerModuleLDS
void setPreservesAll()
Set by analyses that do not transform their input at all.
@ InternalLinkage
Rename collisions when linking (static functions).
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
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 templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Triple - Helper class for working with autoconf configuration names.
@ REGION_ADDRESS
Address space for region memory. (GDS)
@ LOCAL_ADDRESS
Address space for local memory.
LLVM_READNONE constexpr bool isEntryFunctionCC(CallingConv::ID CC)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
ModulePass * createAMDGPUAlwaysInlinePass(bool GlobalOpt=true)
Definition AMDGPUAlwaysInlinePass.cpp:164
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition AMDGPUAlwaysInlinePass.cpp:168