LLVM  14.0.0git
PassBuilder.h
Go to the documentation of this file.
1 //===- Parsing, selection, and construction of pass pipelines --*- C++ -*--===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// Interfaces for registering analysis passes, producing common pass manager
11 /// configurations, and parsing of pass pipelines.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_PASSES_PASSBUILDER_H
16 #define LLVM_PASSES_PASSBUILDER_H
17 
18 #include "llvm/ADT/Optional.h"
20 #include "llvm/IR/PassManager.h"
22 #include "llvm/Support/Error.h"
29 #include <vector>
30 
31 namespace llvm {
32 class StringRef;
33 class AAManager;
34 class TargetMachine;
35 class ModuleSummaryIndex;
36 
37 /// Tunable parameters for passes in the default pipelines.
39 public:
40  /// Constructor sets pipeline tuning defaults based on cl::opts. Each option
41  /// can be set in the PassBuilder when using a LLVM as a library.
43 
44  /// Tuning option to set loop interleaving on/off, set based on opt level.
46 
47  /// Tuning option to enable/disable loop vectorization, set based on opt
48  /// level.
50 
51  /// Tuning option to enable/disable slp loop vectorization, set based on opt
52  /// level.
54 
55  /// Tuning option to enable/disable loop unrolling. Its default value is true.
57 
58  /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
59  /// is that of the flag: `-forget-scev-loop-unroll`.
61 
62  /// Tuning option to cap the number of calls to retrive clobbering accesses in
63  /// MemorySSA, in LICM.
64  unsigned LicmMssaOptCap;
65 
66  /// Tuning option to disable promotion to scalars in LICM with MemorySSA, if
67  /// the number of access is too large.
69 
70  /// Tuning option to enable/disable call graph profile. Its default value is
71  /// that of the flag: `-enable-npm-call-graph-profile`.
73 
74  /// Tuning option to enable/disable function merging. Its default value is
75  /// false.
77 
78  // Experimental option to eagerly invalidate more analyses. This has the
79  // potential to decrease max memory usage in exchange for more compile time.
80  // This may affect codegen due to either passes using analyses only when
81  // cached, or invalidating and recalculating an analysis that was
82  // stale/imprecise but still valid. Currently this invalidates all function
83  // analyses after various module->function or cgscc->function adaptors in the
84  // default pipelines.
86 };
87 
88 /// This class provides access to building LLVM's passes.
89 ///
90 /// Its members provide the baseline state available to passes during their
91 /// construction. The \c PassRegistry.def file specifies how to construct all
92 /// of the built-in passes, and those may reference these members during
93 /// construction.
94 class PassBuilder {
95  TargetMachine *TM;
97  Optional<PGOOptions> PGOOpt;
99 
100 public:
101  /// A struct to capture parsed pass pipeline names.
102  ///
103  /// A pipeline is defined as a series of names, each of which may in itself
104  /// recursively contain a nested pipeline. A name is either the name of a pass
105  /// (e.g. "instcombine") or the name of a pipeline type (e.g. "cgscc"). If the
106  /// name is the name of a pass, the InnerPipeline is empty, since passes
107  /// cannot contain inner pipelines. See parsePassPipeline() for a more
108  /// detailed description of the textual pipeline format.
111  std::vector<PipelineElement> InnerPipeline;
112  };
113 
114  explicit PassBuilder(TargetMachine *TM = nullptr,
116  Optional<PGOOptions> PGOOpt = None,
117  PassInstrumentationCallbacks *PIC = nullptr);
118 
119  /// Cross register the analysis managers through their proxies.
120  ///
121  /// This is an interface that can be used to cross register each
122  /// AnalysisManager with all the others analysis managers.
127 
128  /// Registers all available module analysis passes.
129  ///
130  /// This is an interface that can be used to populate a \c
131  /// ModuleAnalysisManager with all registered module analyses. Callers can
132  /// still manually register any additional analyses. Callers can also
133  /// pre-register analyses and this will not override those.
135 
136  /// Registers all available CGSCC analysis passes.
137  ///
138  /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
139  /// with all registered CGSCC analyses. Callers can still manually register any
140  /// additional analyses. Callers can also pre-register analyses and this will
141  /// not override those.
143 
144  /// Registers all available function analysis passes.
145  ///
146  /// This is an interface that can be used to populate a \c
147  /// FunctionAnalysisManager with all registered function analyses. Callers can
148  /// still manually register any additional analyses. Callers can also
149  /// pre-register analyses and this will not override those.
151 
152  /// Registers all available loop analysis passes.
153  ///
154  /// This is an interface that can be used to populate a \c LoopAnalysisManager
155  /// with all registered loop analyses. Callers can still manually register any
156  /// additional analyses.
158 
159  /// Construct the core LLVM function canonicalization and simplification
160  /// pipeline.
161  ///
162  /// This is a long pipeline and uses most of the per-function optimization
163  /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
164  /// repeatedly over the IR and is not expected to destroy important
165  /// information about the semantics of the IR.
166  ///
167  /// Note that \p Level cannot be `O0` here. The pipelines produced are
168  /// only intended for use when attempting to optimize code. If frontends
169  /// require some transformations for semantic reasons, they should explicitly
170  /// build them.
171  ///
172  /// \p Phase indicates the current ThinLTO phase.
176 
177  /// Construct the core LLVM module canonicalization and simplification
178  /// pipeline.
179  ///
180  /// This pipeline focuses on canonicalizing and simplifying the entire module
181  /// of IR. Much like the function simplification pipeline above, it is
182  /// suitable to run repeatedly over the IR and is not expected to destroy
183  /// important information. It does, however, perform inlining and other
184  /// heuristic based simplifications that are not strictly reversible.
185  ///
186  /// Note that \p Level cannot be `O0` here. The pipelines produced are
187  /// only intended for use when attempting to optimize code. If frontends
188  /// require some transformations for semantic reasons, they should explicitly
189  /// build them.
190  ///
191  /// \p Phase indicates the current ThinLTO phase.
194 
195  /// Construct the module pipeline that performs inlining as well as
196  /// the inlining-driven cleanups.
199 
200  /// Construct the module pipeline that performs inlining with
201  /// module inliner pass.
204 
205  /// Construct the core LLVM module optimization pipeline.
206  ///
207  /// This pipeline focuses on optimizing the execution speed of the IR. It
208  /// uses cost modeling and thresholds to balance code growth against runtime
209  /// improvements. It includes vectorization and other information destroying
210  /// transformations. It also cannot generally be run repeatedly on a module
211  /// without potentially seriously regressing either runtime performance of
212  /// the code or serious code size growth.
213  ///
214  /// Note that \p Level cannot be `O0` here. The pipelines produced are
215  /// only intended for use when attempting to optimize code. If frontends
216  /// require some transformations for semantic reasons, they should explicitly
217  /// build them.
219  bool LTOPreLink = false);
220 
221  /// Build a per-module default optimization pipeline.
222  ///
223  /// This provides a good default optimization pipeline for per-module
224  /// optimization and code generation without any link-time optimization. It
225  /// typically correspond to frontend "-O[123]" options for optimization
226  /// levels \c O1, \c O2 and \c O3 resp.
227  ///
228  /// Note that \p Level cannot be `O0` here. The pipelines produced are
229  /// only intended for use when attempting to optimize code. If frontends
230  /// require some transformations for semantic reasons, they should explicitly
231  /// build them.
233  bool LTOPreLink = false);
234 
235  /// Build a pre-link, ThinLTO-targeting default optimization pipeline to
236  /// a pass manager.
237  ///
238  /// This adds the pre-link optimizations tuned to prepare a module for
239  /// a ThinLTO run. It works to minimize the IR which needs to be analyzed
240  /// without making irreversible decisions which could be made better during
241  /// the LTO run.
242  ///
243  /// Note that \p Level cannot be `O0` here. The pipelines produced are
244  /// only intended for use when attempting to optimize code. If frontends
245  /// require some transformations for semantic reasons, they should explicitly
246  /// build them.
248 
249  /// Build an ThinLTO default optimization pipeline to a pass manager.
250  ///
251  /// This provides a good default optimization pipeline for link-time
252  /// optimization and code generation. It is particularly tuned to fit well
253  /// when IR coming into the LTO phase was first run through \c
254  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
255  ///
256  /// Note that \p Level cannot be `O0` here. The pipelines produced are
257  /// only intended for use when attempting to optimize code. If frontends
258  /// require some transformations for semantic reasons, they should explicitly
259  /// build them.
262  const ModuleSummaryIndex *ImportSummary);
263 
264  /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
265  /// manager.
266  ///
267  /// This adds the pre-link optimizations tuned to work well with a later LTO
268  /// run. It works to minimize the IR which needs to be analyzed without
269  /// making irreversible decisions which could be made better during the LTO
270  /// run.
271  ///
272  /// Note that \p Level cannot be `O0` here. The pipelines produced are
273  /// only intended for use when attempting to optimize code. If frontends
274  /// require some transformations for semantic reasons, they should explicitly
275  /// build them.
277 
278  /// Build an LTO default optimization pipeline to a pass manager.
279  ///
280  /// This provides a good default optimization pipeline for link-time
281  /// optimization and code generation. It is particularly tuned to fit well
282  /// when IR coming into the LTO phase was first run through \c
283  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
284  ///
285  /// Note that \p Level cannot be `O0` here. The pipelines produced are
286  /// only intended for use when attempting to optimize code. If frontends
287  /// require some transformations for semantic reasons, they should explicitly
288  /// build them.
290  ModuleSummaryIndex *ExportSummary);
291 
292  /// Build an O0 pipeline with the minimal semantically required passes.
293  ///
294  /// This should only be used for non-LTO and LTO pre-link pipelines.
296  bool LTOPreLink = false);
297 
298  /// Build the default `AAManager` with the default alias analysis pipeline
299  /// registered.
300  ///
301  /// This also adds target-specific alias analyses registered via
302  /// TargetMachine::registerDefaultAliasAnalyses().
304 
305  /// Parse a textual pass pipeline description into a \c
306  /// ModulePassManager.
307  ///
308  /// The format of the textual pass pipeline description looks something like:
309  ///
310  /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
311  ///
312  /// Pass managers have ()s describing the nest structure of passes. All passes
313  /// are comma separated. As a special shortcut, if the very first pass is not
314  /// a module pass (as a module pass manager is), this will automatically form
315  /// the shortest stack of pass managers that allow inserting that first pass.
316  /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop
317  /// passes 'lpassN', all of these are valid:
318  ///
319  /// fpass1,fpass2,fpass3
320  /// cgpass1,cgpass2,cgpass3
321  /// lpass1,lpass2,lpass3
322  ///
323  /// And they are equivalent to the following (resp.):
324  ///
325  /// module(function(fpass1,fpass2,fpass3))
326  /// module(cgscc(cgpass1,cgpass2,cgpass3))
327  /// module(function(loop(lpass1,lpass2,lpass3)))
328  ///
329  /// This shortcut is especially useful for debugging and testing small pass
330  /// combinations.
331  ///
332  /// The sequence of passes aren't necessarily the exact same kind of pass.
333  /// You can mix different levels implicitly if adaptor passes are defined to
334  /// make them work. For example,
335  ///
336  /// mpass1,fpass1,fpass2,mpass2,lpass1
337  ///
338  /// This pipeline uses only one pass manager: the top-level module manager.
339  /// fpass1,fpass2 and lpass1 are added into the the top-level module manager
340  /// using only adaptor passes. No nested function/loop pass managers are
341  /// added. The purpose is to allow easy pass testing when the user
342  /// specifically want the pass to run under a adaptor directly. This is
343  /// preferred when a pipeline is largely of one type, but one or just a few
344  /// passes are of different types(See PassBuilder.cpp for examples).
346 
347  /// {{@ Parse a textual pass pipeline description into a specific PassManager
348  ///
349  /// Automatic deduction of an appropriate pass manager stack is not supported.
350  /// For example, to insert a loop pass 'lpass' into a FunctionPassManager,
351  /// this is the valid pipeline text:
352  ///
353  /// function(lpass)
354  Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText);
356  Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText);
357  /// @}}
358 
359  /// Parse a textual alias analysis pipeline into the provided AA manager.
360  ///
361  /// The format of the textual AA pipeline is a comma separated list of AA
362  /// pass names:
363  ///
364  /// basic-aa,globals-aa,...
365  ///
366  /// The AA manager is set up such that the provided alias analyses are tried
367  /// in the order specified. See the \c AAManaager documentation for details
368  /// about the logic used. This routine just provides the textual mapping
369  /// between AA names and the analyses to register with the manager.
370  ///
371  /// Returns false if the text cannot be parsed cleanly. The specific state of
372  /// the \p AA manager is unspecified if such an error is encountered and this
373  /// returns false.
374  Error parseAAPipeline(AAManager &AA, StringRef PipelineText);
375 
376  /// Returns true if the pass name is the name of an alias analysis pass.
378 
379  /// Returns true if the pass name is the name of a (non-alias) analysis pass.
381 
382  /// Print pass names.
383  void printPassNames(raw_ostream &OS);
384 
385  /// Register a callback for a default optimizer pipeline extension
386  /// point
387  ///
388  /// This extension point allows adding passes that perform peephole
389  /// optimizations similar to the instruction combiner. These passes will be
390  /// inserted after each instance of the instruction combiner pass.
393  PeepholeEPCallbacks.push_back(C);
394  }
395 
396  /// Register a callback for a default optimizer pipeline extension
397  /// point
398  ///
399  /// This extension point allows adding late loop canonicalization and
400  /// simplification passes. This is the last point in the loop optimization
401  /// pipeline before loop deletion. Each pass added
402  /// here must be an instance of LoopPass.
403  /// This is the place to add passes that can remove loops, such as target-
404  /// specific loop idiom recognition.
407  LateLoopOptimizationsEPCallbacks.push_back(C);
408  }
409 
410  /// Register a callback for a default optimizer pipeline extension
411  /// point
412  ///
413  /// This extension point allows adding loop passes to the end of the loop
414  /// optimizer.
417  LoopOptimizerEndEPCallbacks.push_back(C);
418  }
419 
420  /// Register a callback for a default optimizer pipeline extension
421  /// point
422  ///
423  /// This extension point allows adding optimization passes after most of the
424  /// main optimizations, but before the last cleanup-ish optimizations.
427  ScalarOptimizerLateEPCallbacks.push_back(C);
428  }
429 
430  /// Register a callback for a default optimizer pipeline extension
431  /// point
432  ///
433  /// This extension point allows adding CallGraphSCC passes at the end of the
434  /// main CallGraphSCC passes and before any function simplification passes run
435  /// by CGPassManager.
438  CGSCCOptimizerLateEPCallbacks.push_back(C);
439  }
440 
441  /// Register a callback for a default optimizer pipeline extension
442  /// point
443  ///
444  /// This extension point allows adding optimization passes before the
445  /// vectorizer and other highly target specific optimization passes are
446  /// executed.
449  VectorizerStartEPCallbacks.push_back(C);
450  }
451 
452  /// Register a callback for a default optimizer pipeline extension point.
453  ///
454  /// This extension point allows adding optimization once at the start of the
455  /// pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO
456  /// link-time pipelines).
459  PipelineStartEPCallbacks.push_back(C);
460  }
461 
462  /// Register a callback for a default optimizer pipeline extension point.
463  ///
464  /// This extension point allows adding optimization right after passes that do
465  /// basic simplification of the input IR.
468  PipelineEarlySimplificationEPCallbacks.push_back(C);
469  }
470 
471  /// Register a callback for a default optimizer pipeline extension point
472  ///
473  /// This extension point allows adding optimizations at the very end of the
474  /// function optimization pipeline.
477  OptimizerLastEPCallbacks.push_back(C);
478  }
479 
480  /// Register a callback for parsing an AliasAnalysis Name to populate
481  /// the given AAManager \p AA
483  const std::function<bool(StringRef Name, AAManager &AA)> &C) {
484  AAParsingCallbacks.push_back(C);
485  }
486 
487  /// {{@ Register callbacks for analysis registration with this PassBuilder
488  /// instance.
489  /// Callees register their analyses with the given AnalysisManager objects.
491  const std::function<void(CGSCCAnalysisManager &)> &C) {
492  CGSCCAnalysisRegistrationCallbacks.push_back(C);
493  }
495  const std::function<void(FunctionAnalysisManager &)> &C) {
496  FunctionAnalysisRegistrationCallbacks.push_back(C);
497  }
499  const std::function<void(LoopAnalysisManager &)> &C) {
500  LoopAnalysisRegistrationCallbacks.push_back(C);
501  }
503  const std::function<void(ModuleAnalysisManager &)> &C) {
504  ModuleAnalysisRegistrationCallbacks.push_back(C);
505  }
506  /// @}}
507 
508  /// {{@ Register pipeline parsing callbacks with this pass builder instance.
509  /// Using these callbacks, callers can parse both a single pass name, as well
510  /// as entire sub-pipelines, and populate the PassManager instance
511  /// accordingly.
515  CGSCCPipelineParsingCallbacks.push_back(C);
516  }
520  FunctionPipelineParsingCallbacks.push_back(C);
521  }
525  LoopPipelineParsingCallbacks.push_back(C);
526  }
530  ModulePipelineParsingCallbacks.push_back(C);
531  }
532  /// @}}
533 
534  /// Register a callback for a top-level pipeline entry.
535  ///
536  /// If the PassManager type is not given at the top level of the pipeline
537  /// text, this Callback should be used to determine the appropriate stack of
538  /// PassManagers and populate the passed ModulePassManager.
541  &C);
542 
543  /// Add PGOInstrumenation passes for O0 only.
544  void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen,
545  bool IsCS, std::string ProfileFile,
546  std::string ProfileRemappingFile);
547 
548  /// Returns PIC. External libraries can use this to register pass
549  /// instrumentation callbacks.
551  return PIC;
552  }
553 
554 private:
555  // O1 pass pipeline
557  buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
559 
560  void addRequiredLTOPreLinkPasses(ModulePassManager &MPM);
561 
562  void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
563  bool IsFullLTO);
564 
566  parsePipelineText(StringRef Text);
567 
568  Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
569  Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
570  Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
571  Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
572  bool parseAAPassName(AAManager &AA, StringRef Name);
573 
574  Error parseLoopPassPipeline(LoopPassManager &LPM,
575  ArrayRef<PipelineElement> Pipeline);
576  Error parseFunctionPassPipeline(FunctionPassManager &FPM,
577  ArrayRef<PipelineElement> Pipeline);
578  Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
579  ArrayRef<PipelineElement> Pipeline);
580  Error parseModulePassPipeline(ModulePassManager &MPM,
581  ArrayRef<PipelineElement> Pipeline);
582 
583  void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
584  bool RunProfileGen, bool IsCS, std::string ProfileFile,
585  std::string ProfileRemappingFile);
586  void invokePeepholeEPCallbacks(FunctionPassManager &, OptimizationLevel);
587 
588  // Extension Point callbacks
590  PeepholeEPCallbacks;
592  LateLoopOptimizationsEPCallbacks;
594  LoopOptimizerEndEPCallbacks;
596  ScalarOptimizerLateEPCallbacks;
598  CGSCCOptimizerLateEPCallbacks;
600  VectorizerStartEPCallbacks;
602  OptimizerLastEPCallbacks;
603  // Module callbacks
605  PipelineStartEPCallbacks;
607  PipelineEarlySimplificationEPCallbacks;
608 
610  ModuleAnalysisRegistrationCallbacks;
613  2>
614  ModulePipelineParsingCallbacks;
615  SmallVector<
617  TopLevelPipelineParsingCallbacks;
618  // CGSCC callbacks
620  CGSCCAnalysisRegistrationCallbacks;
623  2>
624  CGSCCPipelineParsingCallbacks;
625  // Function callbacks
627  FunctionAnalysisRegistrationCallbacks;
630  2>
631  FunctionPipelineParsingCallbacks;
632  // Loop callbacks
634  LoopAnalysisRegistrationCallbacks;
637  2>
638  LoopPipelineParsingCallbacks;
639  // AA callbacks
641  AAParsingCallbacks;
642 };
643 
644 /// This utility template takes care of adding require<> and invalidate<>
645 /// passes for an analysis to a given \c PassManager. It is intended to be used
646 /// during parsing of a pass pipeline when parsing a single PipelineName.
647 /// When registering a new function analysis FancyAnalysis with the pass
648 /// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look
649 /// like this:
650 ///
651 /// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
652 /// ArrayRef<PipelineElement> P) {
653 /// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name,
654 /// FPM))
655 /// return true;
656 /// return false;
657 /// }
658 template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
659  typename... ExtraArgTs>
661  StringRef AnalysisName, StringRef PipelineName,
663  if (!PipelineName.endswith(">"))
664  return false;
665  // See if this is an invalidate<> pass name
666  if (PipelineName.startswith("invalidate<")) {
667  PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
668  if (PipelineName != AnalysisName)
669  return false;
671  return true;
672  }
673 
674  // See if this is a require<> pass name
675  if (PipelineName.startswith("require<")) {
676  PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
677  if (PipelineName != AnalysisName)
678  return false;
679  PM.addPass(RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
680  ExtraArgTs...>());
681  return true;
682  }
683 
684  return false;
685 }
686 }
687 
688 #endif
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >
Definition: LoopPassManager.h:70
Instrumentation.h
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1287
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:285
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
Phase
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
Definition: AArch64FalkorHWPFFix.cpp:231
Optional.h
llvm::PassBuilder::registerPipelineStartEPCallback
void registerPipelineStartEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:457
Inliner.h
llvm::StringRef::endswith
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:296
llvm::PassManager::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
Definition: PassManager.h:553
llvm::PassBuilder::getPassInstrumentationCallbacks
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Returns PIC.
Definition: PassBuilder.h:550
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1177
llvm::PassBuilder::buildModuleOptimizationPipeline
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Construct the core LLVM module optimization pipeline.
Definition: PassBuilderPipelines.cpp:1088
llvm::PassBuilder::PassBuilder
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), Optional< PGOOptions > PGOOpt=None, PassInstrumentationCallbacks *PIC=nullptr)
Definition: PassBuilder.cpp:375
llvm::PipelineTuningOptions
Tunable parameters for passes in the default pipelines.
Definition: PassBuilder.h:38
Error.h
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::PipelineTuningOptions::ForgetAllSCEVInLoopUnroll
bool ForgetAllSCEVInLoopUnroll
Tuning option to forget all SCEV loops in LoopUnroll.
Definition: PassBuilder.h:60
PIC
PassInstrumentationCallbacks PIC
Definition: PassBuilderBindings.cpp:55
llvm::Optional
Definition: APInt.h:33
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(CGSCCAnalysisManager &)> &C)
{{@ Register callbacks for analysis registration with this PassBuilder instance.
Definition: PassBuilder.h:490
llvm::PassBuilder::registerOptimizerLastEPCallback
void registerOptimizerLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:475
llvm::PassBuilder::registerScalarOptimizerLateEPCallback
void registerScalarOptimizerLateEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:425
llvm::PassBuilder::addPGOInstrPassesForO0
void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen, bool IsCS, std::string ProfileFile, std::string ProfileRemappingFile)
Add PGOInstrumenation passes for O0 only.
Definition: PassBuilderPipelines.cpp:661
llvm::PipelineTuningOptions::LicmMssaNoAccForPromotionCap
unsigned LicmMssaNoAccForPromotionCap
Tuning option to disable promotion to scalars in LICM with MemorySSA, if the number of access is too ...
Definition: PassBuilder.h:68
llvm::PassBuilder::parsePassPipeline
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
Definition: PassBuilder.cpp:1590
llvm::StringRef::substr
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:610
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:517
llvm::ThinOrFullLTOPhase
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
Definition: Pass.h:73
llvm::ModuleInlinerWrapperPass
Module pass, wrapping the inliner pass.
Definition: Inliner.h:120
llvm::PassBuilder::registerParseAACallback
void registerParseAACallback(const std::function< bool(StringRef Name, AAManager &AA)> &C)
Register a callback for parsing an AliasAnalysis Name to populate the given AAManager AA.
Definition: PassBuilder.h:482
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
MAM
ModuleAnalysisManager MAM
Definition: PassBuilderBindings.cpp:61
llvm::PassBuilder
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:94
llvm::PassBuilder::buildFunctionSimplificationPipeline
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:384
llvm::PassBuilder::PipelineElement
A struct to capture parsed pass pipeline names.
Definition: PassBuilder.h:109
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::parseAnalysisUtilityPasses
bool parseAnalysisUtilityPasses(StringRef AnalysisName, StringRef PipelineName, PassManager< IRUnitT, AnalysisManagerT, ExtraArgTs... > &PM)
This utility template takes care of adding require<> and invalidate<> passes for an analysis to a giv...
Definition: PassBuilder.h:660
llvm::PassBuilder::buildInlinerPipeline
ModuleInlinerWrapperPass buildInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining as well as the inlining-driven cleanups.
Definition: PassBuilderPipelines.cpp:691
llvm::PassBuilder::buildThinLTOPreLinkDefaultPipeline
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1294
llvm::None
const NoneType None
Definition: None.h:23
llvm::PassBuilder::isAnalysisPassName
bool isAnalysisPassName(StringRef PassName)
Returns true if the pass name is the name of a (non-alias) analysis pass.
Definition: PassBuilder.cpp:1728
llvm::PassBuilder::isAAPassName
bool isAAPassName(StringRef PassName)
Returns true if the pass name is the name of an alias analysis pass.
Definition: PassBuilder.cpp:1717
llvm::PassBuilder::buildModuleInlinerPipeline
ModulePassManager buildModuleInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining with module inliner pass.
Definition: PassBuilderPipelines.cpp:762
llvm::PipelineTuningOptions::EagerlyInvalidateAnalyses
bool EagerlyInvalidateAnalyses
Definition: PassBuilder.h:85
llvm::PassBuilder::registerPipelineEarlySimplificationEPCallback
void registerPipelineEarlySimplificationEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:466
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:527
llvm::PassBuilder::registerFunctionAnalyses
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
Definition: PassBuilder.cpp:430
ModuleInliner.h
llvm::PassBuilder::buildLTOPreLinkDefaultPipeline
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1411
llvm::PassBuilder::registerModuleAnalyses
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
Definition: PassBuilder.cpp:412
llvm::PassBuilder::registerVectorizerStartEPCallback
void registerVectorizerStartEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:447
CGSCCPassManager.h
llvm::PassBuilder::buildLTODefaultPipeline
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1420
llvm::InvalidateAnalysisPass
A no-op pass template which simply forces a specific analysis result to be invalidated.
Definition: PassManager.h:1280
llvm::PassBuilder::buildThinLTODefaultPipeline
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1355
llvm::PassBuilder::buildDefaultAAPipeline
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Definition: PassBuilderPipelines.cpp:1791
llvm::PipelineTuningOptions::PipelineTuningOptions
PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
Definition: PassBuilderPipelines.cpp:185
llvm::PassBuilder::printPassNames
void printPassNames(raw_ostream &OS)
Print pass names.
Definition: PassBuilder.cpp:1759
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:80
llvm::PipelineTuningOptions::SLPVectorization
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition: PassBuilder.h:53
llvm::PassBuilder::registerLoopOptimizerEndEPCallback
void registerLoopOptimizerEndEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:415
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(FunctionAnalysisManager &)> &C)
Definition: PassBuilder.h:494
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
{{@ Register pipeline parsing callbacks with this pass builder instance.
Definition: PassBuilder.h:512
LoopPassManager.h
llvm::PassBuilder::PipelineElement::Name
StringRef Name
Definition: PassBuilder.h:110
llvm::PassBuilder::registerLateLoopOptimizationsEPCallback
void registerLateLoopOptimizationsEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:405
llvm::PipelineTuningOptions::CallGraphProfile
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
Definition: PassBuilder.h:72
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::PipelineTuningOptions::LoopVectorization
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition: PassBuilder.h:49
llvm::PICLevel::Level
Level
Definition: CodeGen.h:33
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:522
LAM
LoopAnalysisManager LAM
Definition: PassBuilderBindings.cpp:58
llvm::PassBuilder::parseAAPipeline
Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
Definition: PassBuilder.cpp:1697
llvm::PassManager< Function >
llvm::PassBuilder::registerLoopAnalyses
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
Definition: PassBuilder.cpp:444
llvm::StringRef::size
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:156
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::PassBuilder::buildPerModuleDefaultPipeline
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
Definition: PassBuilderPipelines.cpp:1252
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::PipelineTuningOptions::MergeFunctions
bool MergeFunctions
Tuning option to enable/disable function merging.
Definition: PassBuilder.h:76
llvm::PassBuilder::registerCGSCCAnalyses
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
Definition: PassBuilder.cpp:421
PGOOptions.h
llvm::OptimizationLevel
Definition: OptimizationLevel.h:22
PassManager.h
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(LoopAnalysisManager &)> &C)
Definition: PassBuilder.h:498
llvm::PassBuilder::buildO0DefaultPipeline
ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build an O0 pipeline with the minimal semantically required passes.
Definition: PassBuilderPipelines.cpp:1690
OptimizationLevel.h
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1088
llvm::PassInstrumentationCallbacks
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Definition: PassInstrumentation.h:66
llvm::PassBuilder::crossRegisterProxies
void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM)
Cross register the analysis managers through their proxies.
Definition: PassBuilder.cpp:1565
llvm::PassBuilder::registerCGSCCOptimizerLateEPCallback
void registerCGSCCOptimizerLateEPCallback(const std::function< void(CGSCCPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:436
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::PassBuilder::registerPeepholeEPCallback
void registerPeepholeEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:391
llvm::RequireAnalysisPass
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1252
llvm::PassBuilder::buildModuleSimplificationPipeline
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM module canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:795
llvm::PipelineTuningOptions::LoopUnrolling
bool LoopUnrolling
Tuning option to enable/disable loop unrolling. Its default value is true.
Definition: PassBuilder.h:56
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(ModuleAnalysisManager &)> &C)
Definition: PassBuilder.h:502
llvm::PipelineTuningOptions::LicmMssaOptCap
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
Definition: PassBuilder.h:64
raw_ostream.h
llvm::PipelineTuningOptions::LoopInterleaving
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
Definition: PassBuilder.h:45
llvm::PassBuilder::registerParseTopLevelPipelineCallback
void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
Definition: PassBuilder.cpp:1827
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70
CGAM
CGSCCAnalysisManager CGAM
Definition: PassBuilderBindings.cpp:60
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:670
llvm::PassBuilder::PipelineElement::InnerPipeline
std::vector< PipelineElement > InnerPipeline
Definition: PassBuilder.h:111