LLVM: include/llvm/IR/Analysis.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12#ifndef LLVM_IR_ANALYSIS_H
13#define LLVM_IR_ANALYSIS_H
14
17
18namespace llvm {
19
22
23
24
25
26
27
28
30
31
32
33
34
35
36
37
38
40
41
42
43
44
45
46
47
48
49
51public:
53
54private:
56};
57
58template AnalysisSetKey AllAnalysesOn::SetKey;
59
62
63
64
65
66
67
68
69
70
71
72
74public:
76
77private:
79};
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
113public:
114
116
117
120 PA.PreservedIDs.insert(&AllAnalysesKey);
121 return PA;
122 }
123
124
130
131
136
137
138
140
141 NotPreservedAnalysisIDs.erase(ID);
142
143
144
146 PreservedIDs.insert(ID);
147 return *this;
148 }
149
150
155
156
158
160 PreservedIDs.insert(ID);
161 return *this;
162 }
163
164
165
166
167
168
169
170
172 abandon(AnalysisT::ID());
173 return *this;
174 }
175
176
177
178
179
180
181
182
184 PreservedIDs.erase(ID);
185 NotPreservedAnalysisIDs.insert(ID);
186 return *this;
187 }
188
189
190
191
192
195 return;
197 *this = Arg;
198 return;
199 }
200
201
202 for (auto *ID : Arg.NotPreservedAnalysisIDs) {
203 PreservedIDs.erase(ID);
204 NotPreservedAnalysisIDs.insert(ID);
205 }
206 PreservedIDs.remove_if(
207 [&](void *ID) { return !Arg.PreservedIDs.contains(ID); });
208 }
209
210
211
212
213
215 if (Arg.areAllPreserved())
216 return;
218 *this = std::move(Arg);
219 return;
220 }
221
222
223 for (auto *ID : Arg.NotPreservedAnalysisIDs) {
224 PreservedIDs.erase(ID);
225 NotPreservedAnalysisIDs.insert(ID);
226 }
227 PreservedIDs.remove_if(
228 [&](void *ID) { return !Arg.PreservedIDs.contains(ID); });
229 }
230
231
232
233 class PreservedAnalysisChecker {
235
238 const bool IsAbandoned;
239
240
241
242
244 : PA(PA), ID(ID), IsAbandoned(PA.NotPreservedAnalysisIDs.count(ID)) {}
245
246 public:
247
248
249
251 return !IsAbandoned && (PA.PreservedIDs.count(&AllAnalysesKey) ||
252 PA.PreservedIDs.count(ID));
253 }
254
255
256
257
259
260
261
262
265 return !IsAbandoned && (PA.PreservedIDs.count(&AllAnalysesKey) ||
266 PA.PreservedIDs.count(SetID));
267 }
268 };
269
270
271
272
273
274
278
279
280
281
282
283
287
288
289
290
291
293 return NotPreservedAnalysisIDs.empty() &&
294 PreservedIDs.count(&AllAnalysesKey);
295 }
296
297
298
299
303
304
305
306
308 return NotPreservedAnalysisIDs.empty() &&
309 (PreservedIDs.count(&AllAnalysesKey) || PreservedIDs.count(SetID));
310 }
311
312private:
313
315
316
318
319
320
321
322
323
324
325
327};
328}
329
330#endif
#define LLVM_TEMPLATE_ABI
This file defines the SmallPtrSet class.
This templated class represents "all analyses that operate over " (e....
Definition Analysis.h:50
static AnalysisSetKey * ID()
Definition Analysis.h:52
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
static AnalysisSetKey * ID()
Definition Analysis.h:75
A Module instance is used to store all the information related to an LLVM module.
A checker object that makes it easy to query for whether an analysis or some set covering it is prese...
Definition Analysis.h:233
bool preserved()
Returns true if the checker's analysis was not abandoned and either.
Definition Analysis.h:250
bool preservedWhenStateless()
Return true if the checker's analysis was not abandoned, i.e.
Definition Analysis.h:258
friend class PreservedAnalyses
Definition Analysis.h:234
bool preservedSet()
Returns true if the checker's analysis was not abandoned and either.
Definition Analysis.h:263
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition Analysis.h:115
bool areAllPreserved() const
Test whether all analyses are preserved (and none are abandoned).
Definition Analysis.h:292
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserve(AnalysisKey *ID)
Given an analysis's ID, mark the analysis as preserved, adding it to the set.
Definition Analysis.h:139
PreservedAnalyses & abandon()
Mark an analysis as abandoned.
Definition Analysis.h:171
bool allAnalysesInSetPreserved() const
Directly test whether a set of analyses is preserved.
Definition Analysis.h:300
PreservedAnalysisChecker getChecker(AnalysisKey *ID) const
Build a checker for this PreservedAnalyses and the specified analysis ID.
Definition Analysis.h:284
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
void intersect(const PreservedAnalyses &Arg)
Intersect this set with another in place.
Definition Analysis.h:193
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Definition Analysis.h:132
PreservedAnalyses & abandon(AnalysisKey *ID)
Mark an analysis as abandoned using its ID.
Definition Analysis.h:183
void intersect(PreservedAnalyses &&Arg)
Intersect this set with a temporary other set in place.
Definition Analysis.h:214
bool allAnalysesInSetPreserved(AnalysisSetKey *SetID) const
Directly test whether a set of analyses is preserved.
Definition Analysis.h:307
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition Analysis.h:275
PreservedAnalyses & preserveSet(AnalysisSetKey *ID)
Mark an analysis set as preserved using its ID.
Definition Analysis.h:157
static PreservedAnalyses allInSet()
Construct a preserved analyses object with a single preserved set.
Definition Analysis.h:125
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
AnalysisSetKey AllAnalysesOn< IRUnitT >::SetKey
Definition Analysis.h:58
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
A special type used to provide an address that identifies a set of related analyses.
Definition Analysis.h:39