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
28#include
29#include
30#include
31#include
32
33namespace llvm {
34
39
40
41
42
43
44
45
46
47
49public:
51
52private:
53
54
55
56
61 bool PreservesAll = false;
62
65 Set.push_back(ID);
66 }
67
68public:
70
71
72
75 template
79
81 template
85
86
87
88
90 pushUnique(Preserved, ID);
91 return *this;
92 }
94 pushUnique(Preserved, &ID);
95 return *this;
96 }
97
98 template
100 pushUnique(Preserved, &PassClass::ID);
101 return *this;
102 }
103
104
105
106
107
109 pushUnique(Used, ID);
110 return *this;
111 }
113 pushUnique(Used, &ID);
114 return *this;
115 }
116
117 template
119 pushUnique(Used, &PassClass::ID);
120 return *this;
121 }
122
123
124
125
126
127
129
130
132
133
135
136
137
138
139
140
141
142
144
147 return RequiredTransitive;
148 }
151};
152
153
154
155
156
157
159public:
162
164
165
167 Pass *ResultPass = nullptr;
168 for (const auto &AnalysisImpl : AnalysisImpls) {
169 if (AnalysisImpl.first == PI) {
170 ResultPass = AnalysisImpl.second;
171 break;
172 }
173 }
174 return ResultPass;
175 }
176
177
180
183 return;
184 std::pair<AnalysisID, Pass*> pir = std::make_pair(PI,P);
185 AnalysisImpls.push_back(pir);
186 }
187
188
190 AnalysisImpls.clear();
191 }
192
193
195
196private:
197
198
199 std::vector<std::pair<AnalysisID, Pass *>> AnalysisImpls;
200
201
203};
204
205
206
207
208
209
210
211
212template
214 assert(Resolver && "Pass not resident in a PassManager object!");
215
216 const void *PI = &AnalysisType::ID;
217 return (AnalysisType *)Resolver->getAnalysisIfAvailable(PI);
218}
219
220
221
222
223template
225 assert(Resolver && "Pass has not been inserted into a PassManager object!");
227}
228
229template
231 assert(PI && "getAnalysis for unregistered pass!");
232 assert(Resolver&&"Pass has not been inserted into a PassManager object!");
233
234
235
236 Pass *ResultPass = Resolver->findImplPass(PI);
238 "getAnalysis*() called on an analysis that was not "
239 "'required' by pass!");
240 return *(AnalysisType *)ResultPass;
241}
242
243
244
245
246
247
248template
250 assert(Resolver &&"Pass has not been inserted into a PassManager object!");
251
253}
254
255template
257 assert(PI && "getAnalysis for unregistered pass!");
258 assert(Resolver && "Pass has not been inserted into a PassManager object!");
259
260
261
262 Pass *ResultPass;
263 bool LocalChanged;
264 std::tie(ResultPass, LocalChanged) = Resolver->findImplPass(this, PI, F);
265
266 assert(ResultPass && "Unable to find requested analysis info");
268 *Changed |= LocalChanged;
269 else
270 assert(!LocalChanged &&
271 "A pass trigged a code update but the update status is lost");
272 return *(AnalysisType *)ResultPass;
273}
274
275}
276
277#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallVector class.
void addAnalysisImplsPair(AnalysisID PI, Pass *P)
Definition PassAnalysisSupport.h:181
Pass * findImplPass(AnalysisID PI)
Find pass that is implementing PI.
Definition PassAnalysisSupport.h:166
PMDataManager & getPMDataManager()
Definition PassAnalysisSupport.h:163
AnalysisResolver(PMDataManager &P)
Definition PassAnalysisSupport.h:161
void clearAnalysisImpls()
Clear cache that is used to connect a pass to the analysis (PassInfo).
Definition PassAnalysisSupport.h:189
AnalysisResolver()=delete
LLVM_ABI Pass * getAnalysisIfAvailable(AnalysisID ID) const
Return analysis result or null if it doesn't exist.
Represent the analysis usage information of a pass.
Definition PassAnalysisSupport.h:48
LLVM_ABI AnalysisUsage & addRequiredID(const void *ID)
const VectorType & getRequiredSet() const
Definition PassAnalysisSupport.h:145
LLVM_ABI AnalysisUsage & addRequiredTransitiveID(char &ID)
AnalysisUsage & addPreservedID(char &ID)
Definition PassAnalysisSupport.h:93
AnalysisUsage & addPreservedID(const void *ID)
Definition PassAnalysisSupport.h:89
AnalysisUsage & addUsedIfAvailableID(const void *ID)
Definition PassAnalysisSupport.h:108
AnalysisUsage & addUsedIfAvailableID(char &ID)
Definition PassAnalysisSupport.h:112
const VectorType & getRequiredTransitiveSet() const
Definition PassAnalysisSupport.h:146
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
Definition PassAnalysisSupport.h:118
SmallVectorImpl< AnalysisID > VectorType
Definition PassAnalysisSupport.h:50
const VectorType & getUsedSet() const
Definition PassAnalysisSupport.h:150
AnalysisUsage & addRequired()
Definition PassAnalysisSupport.h:76
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition PassAnalysisSupport.h:99
LLVM_ABI 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.
Definition PassAnalysisSupport.h:131
bool getPreservesAll() const
Determine whether a pass said it does not transform its input at all.
Definition PassAnalysisSupport.h:134
const VectorType & getPreservedSet() const
Definition PassAnalysisSupport.h:149
AnalysisUsage & addRequiredTransitive()
Definition PassAnalysisSupport.h:82
PMDataManager provides the common place to manage the analysis data used by pass managers.
Pass interface - Implemented by all 'passes'.
Pass(PassKind K, char &pid)
AnalysisType & getAnalysis() const
getAnalysis() - This function is used by subclasses to get to the analysis information ...
Definition PassAnalysisSupport.h:224
AnalysisType & getAnalysisID(AnalysisID PI) const
Definition PassAnalysisSupport.h:230
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable() - Subclasses use this function to get analysis information tha...
Definition PassAnalysisSupport.h:213
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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.