LLVM: include/llvm/Analysis/CGSCCPassManager.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88#ifndef LLVM_ANALYSIS_CGSCCPASSMANAGER_H
89#define LLVM_ANALYSIS_CGSCCPASSMANAGER_H
90
96#include
97#include
98
99namespace llvm {
100
102template <typename T, unsigned int N> class SmallPriorityWorklist;
103struct CGSCCUpdateResult;
104
106
107
108#define DEBUG_TYPE "cgscc"
109
110
111extern template class AllAnalysesOnLazyCallGraph::SCC;
112
113extern template class AnalysisManager<LazyCallGraph::SCC, LazyCallGraph &>;
114
115
116
117
118
119
120
123
124
125
126
127template <>
135
136
137
138
139
140
144
145
146template
149 : PassInfoMixin<RequireAnalysisPass<AnalysisT, LazyCallGraph::SCC,
150 CGSCCAnalysisManager, LazyCallGraph &,
151 CGSCCUpdateResult &>> {
154 (void)AM.template getResult(C, CG);
156 }
159 auto ClassName = AnalysisT::name();
160 auto PassName = MapClassName2PassName(ClassName);
162 }
163};
164
165
168
169
170
171
173public:
175 : InnerAM(&InnerAM), G(&G) {}
176
177
179
180
181
182
183
184
185
186
187
188
189
192
193private:
196};
197
198
199
200template <>
203
204
205
207
210
211
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
232
233
234
235
236
237
238
239
240
241
242
243
244
246
247
248
249
250
251
252
254
255
256
257
258
259
260
261
262
264
265
266
267
268
269
270
271
272
273
274
275
276
277
279
280
281
282
283
284
285
288
289
290
292
293
294
295
296
297
298
299
300
302};
303
304
305
306
307
308
309
310
311
312
314 : public PassInfoMixin {
315public:
319
322
325
329 }
330
334 return *this;
335 }
336
337
339
342 OS << "cgscc(";
343 Pass->printPipeline(OS, MapClassName2PassName);
344 OS << ')';
345 }
346
348
349private:
350 std::unique_ptr Pass;
351};
352
353
354
355template
356ModuleToPostOrderCGSCCPassAdaptor
358 using PassModelT =
361
362
364 std::unique_ptr<ModuleToPostOrderCGSCCPassAdaptor::PassConceptT>(
365 new PassModelT(std::forward(Pass))));
366}
367
368
369
370
371
372
373
374
375
378public:
380 public:
381 explicit Result() : FAM(nullptr) {}
383
385
388 return *FAM;
389 }
390
393
394 private:
396 };
397
398
400
401private:
403
405};
406
407extern template class OuterAnalysisManagerProxy<CGSCCAnalysisManager, Function>;
408
409
412
413
414
415
416
417
418
423
424
425
426
427
428
429
434
435
436
437
438
439
440
441
442
445public:
447
449 bool EagerlyInvalidate, bool NoRerun)
450 : Pass(std::move(Pass)), EagerlyInvalidate(EagerlyInvalidate),
451 NoRerun(NoRerun) {}
452
454 : Pass(std::move(Arg.Pass)), EagerlyInvalidate(Arg.EagerlyInvalidate),
455 NoRerun(Arg.NoRerun) {}
456
460 }
461
463 swap(*this, RHS);
464 return *this;
465 }
466
467
470
473 OS << "function";
474 if (EagerlyInvalidate || NoRerun) {
475 OS << "<";
476 if (EagerlyInvalidate)
477 OS << "eager-inv";
478 if (EagerlyInvalidate && NoRerun)
479 OS << ";";
480 if (NoRerun)
481 OS << "no-rerun";
482 OS << ">";
483 }
484 OS << '(';
485 Pass->printPipeline(OS, MapClassName2PassName);
486 OS << ')';
487 }
488
490
491private:
492 std::unique_ptr Pass;
493 bool EagerlyInvalidate;
494 bool NoRerun;
495};
496
497
498
499template
500CGSCCToFunctionPassAdaptor
502 bool EagerlyInvalidate = false,
503 bool NoRerun = false) {
504 using PassModelT =
506
507
509 std::unique_ptrCGSCCToFunctionPassAdaptor::PassConceptT(
510 new PassModelT(std::forward(Pass))),
511 EagerlyInvalidate, NoRerun);
512}
513
514
515
516
517
518
521public:
524
526};
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
543public:
547
549 int MaxIterations)
551
552
553
556
559 OS << "devirt<" << MaxIterations << ">(";
560 Pass->printPipeline(OS, MapClassName2PassName);
561 OS << ')';
562 }
563
564private:
565 std::unique_ptr Pass;
566 int MaxIterations;
567};
568
569
570
571template
573 int MaxIterations) {
574 using PassModelT =
577
578
580 std::unique_ptrDevirtSCCRepeatedPass::PassConceptT(
581 new PassModelT(std::forward(Pass))),
582 MaxIterations);
583}
584
585
586#undef DEBUG_TYPE
587
588}
589
590#endif
This header defines various interfaces for pass management in LLVM.
Implements a lazy call graph analysis and related passes for the new pass manager.
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
FunctionAnalysisManager FAM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char PassName[]
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
CGSCCAnalysisManager & getManager()
Accessor for the analysis manager.
Result(CGSCCAnalysisManager &InnerAM, LazyCallGraph &G)
Adaptor that maps from a SCC to its functions.
CGSCCToFunctionPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool EagerlyInvalidate, bool NoRerun)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
CGSCCToFunctionPassAdaptor & operator=(CGSCCToFunctionPassAdaptor RHS)
CGSCCToFunctionPassAdaptor(CGSCCToFunctionPassAdaptor &&Arg)
friend void swap(CGSCCToFunctionPassAdaptor &LHS, CGSCCToFunctionPassAdaptor &RHS)
A helper that repeats an SCC pass each time an indirect call is refined to a direct call by that pass...
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
DevirtSCCRepeatedPass(std::unique_ptr< PassConceptT > Pass, int MaxIterations)
bool invalidate(LazyCallGraph::SCC &C, const PreservedAnalyses &PA, CGSCCAnalysisManager::Invalidator &Inv)
void updateFAM(FunctionAnalysisManager &FAM)
FunctionAnalysisManager & getManager()
Accessor for the analysis manager.
Result(FunctionAnalysisManager &FAM)
A proxy from a FunctionAnalysisManager to an SCC.
Result run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &)
Computes the FunctionAnalysisManager and stores it in the result proxy.
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA, typename AnalysisManager< IRUnitT, ExtraArgTs... >::Invalidator &Inv)
Handler for invalidation of the outer IR unit, IRUnitT.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Result run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs...)
Run the analysis pass and create our proxy result object.
A node in the call graph.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
The core module pass which does a post-order walk of the SCCs and runs a CGSCC pass over each one.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Runs the CGSCC pass across every SCC in the module.
ModuleToPostOrderCGSCCPassAdaptor & operator=(ModuleToPostOrderCGSCCPassAdaptor RHS)
ModuleToPostOrderCGSCCPassAdaptor(std::unique_ptr< PassConceptT > Pass)
friend void swap(ModuleToPostOrderCGSCCPassAdaptor &LHS, ModuleToPostOrderCGSCCPassAdaptor &RHS)
ModuleToPostOrderCGSCCPassAdaptor(ModuleToPostOrderCGSCCPassAdaptor &&Arg)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
A Module instance is used to store all the information related to an LLVM module.
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
Manages a sequence of passes over a particular unit of IR.
Pass interface - Implemented by all 'passes'.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Result run(Function &F, FunctionAnalysisManager &FAM)
Implements a dense probed hash-table based set with some number of buckets stored inline.
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
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.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass, int MaxIterations)
A function to deduce a function pass type and wrap it in the templated adaptor.
LazyCallGraph::SCC & updateCGAndAnalysisManagerForFunctionPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)
Helper to update the call graph after running a function pass.
LazyCallGraph::SCC & updateCGAndAnalysisManagerForCGSCCPass(LazyCallGraph &G, LazyCallGraph::SCC &C, LazyCallGraph::Node &N, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR, FunctionAnalysisManager &FAM)
Helper to update the call graph after running a CGSCC pass.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
SmallMapVector< Value *, WeakTrackingVH, 16 > IndirectVHs
Weak VHs to keep track of indirect calls for the purposes of detecting devirtualization.
SmallPriorityWorklist< LazyCallGraph::SCC *, 1 > & CWorklist
Worklist of the SCCs queued for processing.
SmallDenseSet< std::pair< LazyCallGraph::Node *, LazyCallGraph::SCC * >, 4 > & InlinedInternalEdges
A hacky area where the inliner can retain history about inlining decisions that mutated the call grap...
SmallVector< Function *, 4 > & DeadFunctions
Functions that a pass has considered to be dead to be removed at the end of the call graph walk in ba...
SmallPtrSetImpl< LazyCallGraph::SCC * > & InvalidatedSCCs
The set of invalidated SCCs which should be skipped if they are found in CWorklist.
LazyCallGraph::SCC * UpdatedC
If non-null, the updated current SCC being processed.
PreservedAnalyses CrossSCCPA
Preserved analyses across SCCs.
A CRTP mix-in to automatically provide informational APIs needed for passes.
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &)
A utility pass template to force an analysis result to be available.
A MapVector that performs no allocations if smaller than a certain size.
Template for the abstract base class used to dispatch polymorphically over pass objects.
A template wrapper used to implement the polymorphic API.