LLVM: include/llvm/PassAnalysisSupport.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#if !defined(LLVM_PASS_H) || defined(LLVM_PASSANALYSISSUPPORT_H)
19#error "Do not include <PassAnalysisSupport.h>; include <Pass.h> instead"
20#endif
21
22#ifndef LLVM_PASSANALYSISSUPPORT_H
23#define LLVM_PASSANALYSISSUPPORT_H
24
27#include
28#include
29#include
30#include
31
32namespace llvm {
33
36class PMDataManager;
37class StringRef;
38
39
40
41
42
43
44
45
46
48public:
50
51private:
52
53
54
55
60 bool PreservesAll = false;
61
64 Set.push_back(ID);
65 }
66
67public:
69
70
71
74 template
77 }
78
80 template
83 }
84
85
86
87
89 pushUnique(Preserved, ID);
90 return *this;
91 }
93 pushUnique(Preserved, &ID);
94 return *this;
95 }
96
97 template
99 pushUnique(Preserved, &PassClass::ID);
100 return *this;
101 }
102
103
104
105
106
108 pushUnique(Used, ID);
109 return *this;
110 }
112 pushUnique(Used, &ID);
113 return *this;
114 }
115
116 template
118 pushUnique(Used, &PassClass::ID);
119 return *this;
120 }
121
122
123
124
125
126
128
129
131
132
134
135
136
137
138
139
140
141
143
146 return RequiredTransitive;
147 }
150};
151
152
153
154
155
156
158public:
161
163
164
166 Pass *ResultPass = nullptr;
167 for (const auto &AnalysisImpl : AnalysisImpls) {
168 if (AnalysisImpl.first == PI) {
169 ResultPass = AnalysisImpl.second;
170 break;
171 }
172 }
173 return ResultPass;
174 }
175
176
178
181 return;
182 std::pair<AnalysisID, Pass*> pir = std::make_pair(PI,P);
183 AnalysisImpls.push_back(pir);
184 }
185
186
188 AnalysisImpls.clear();
189 }
190
191
193
194private:
195
196
197 std::vector<std::pair<AnalysisID, Pass *>> AnalysisImpls;
198
199
201};
202
203
204
205
206
207
208
209
210template
212 assert(Resolver && "Pass not resident in a PassManager object!");
213
214 const void *PI = &AnalysisType::ID;
215
216 Pass *ResultPass = Resolver->getAnalysisIfAvailable(PI);
217 if (!ResultPass) return nullptr;
218
219
220
221
222
224}
225
226
227
228
229template
231 assert(Resolver && "Pass has not been inserted into a PassManager object!");
232 return getAnalysisID(&AnalysisType::ID);
233}
234
235template
237 assert(PI && "getAnalysis for unregistered pass!");
238 assert(Resolver&&"Pass has not been inserted into a PassManager object!");
239
240
241
242 Pass *ResultPass = Resolver->findImplPass(PI);
244 "getAnalysis*() called on an analysis that was not "
245 "'required' by pass!");
246
247
248
249
250
252}
253
254
255
256
257
258
259template
261 assert(Resolver &&"Pass has not been inserted into a PassManager object!");
262
263 return getAnalysisID(&AnalysisType::ID, F, Changed);
264}
265
266template
268 assert(PI && "getAnalysis for unregistered pass!");
269 assert(Resolver && "Pass has not been inserted into a PassManager object!");
270
271
272
273 Pass *ResultPass;
274 bool LocalChanged;
275 std::tie(ResultPass, LocalChanged) = Resolver->findImplPass(this, PI, F);
276
277 assert(ResultPass && "Unable to find requested analysis info");
278 if (Changed)
279 *Changed |= LocalChanged;
280 else
281 assert(!LocalChanged &&
282 "A pass trigged a code update but the update status is lost");
283
284
285
286
287
289}
290
291}
292
293#endif
aarch64 AArch64 CCMP Pass
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
AnalysisResolver - Simple interface used by Pass objects to pull all analysis information out of pass...
void addAnalysisImplsPair(AnalysisID PI, Pass *P)
Pass * findImplPass(AnalysisID PI)
Find pass that is implementing PI.
PMDataManager & getPMDataManager()
AnalysisResolver(PMDataManager &P)
void clearAnalysisImpls()
Clear cache that is used to connect a pass to the analysis (PassInfo).
AnalysisResolver()=delete
Pass * getAnalysisIfAvailable(AnalysisID ID) const
Return analysis result or null if it doesn't exist.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequiredID(const void *ID)
const VectorType & getRequiredSet() const
AnalysisUsage & addRequiredTransitiveID(char &ID)
AnalysisUsage & addPreservedID(char &ID)
AnalysisUsage & addPreservedID(const void *ID)
AnalysisUsage & addUsedIfAvailableID(const void *ID)
AnalysisUsage & addUsedIfAvailableID(char &ID)
const VectorType & getRequiredTransitiveSet() const
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
const VectorType & getUsedSet() const
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool getPreservesAll() const
Determine whether a pass said it does not transform its input at all.
const VectorType & getPreservedSet() const
AnalysisUsage & addRequiredTransitive()
PMDataManager provides the common place to manage the analysis data used by pass managers.
Pass interface - Implemented by all 'passes'.
virtual void * getAdjustedAnalysisPointer(AnalysisID ID)
getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through...
AnalysisType & getAnalysis() const
getAnalysis() - This function is used by subclasses to get to the analysis information ...
AnalysisType & getAnalysisID(AnalysisID PI) const
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable() - Subclasses use this function to get analysis information tha...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.