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"
28 #include <vector>
29 
30 namespace llvm {
31 class StringRef;
32 class AAManager;
33 class TargetMachine;
34 class ModuleSummaryIndex;
35 
36 /// Tunable parameters for passes in the default pipelines.
38 public:
39  /// Constructor sets pipeline tuning defaults based on cl::opts. Each option
40  /// can be set in the PassBuilder when using a LLVM as a library.
42 
43  /// Tuning option to set loop interleaving on/off, set based on opt level.
45 
46  /// Tuning option to enable/disable loop vectorization, set based on opt
47  /// level.
49 
50  /// Tuning option to enable/disable slp loop vectorization, set based on opt
51  /// level.
53 
54  /// Tuning option to enable/disable loop unrolling. Its default value is true.
56 
57  /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
58  /// is that of the flag: `-forget-scev-loop-unroll`.
60 
61  /// Tuning option to cap the number of calls to retrive clobbering accesses in
62  /// MemorySSA, in LICM.
63  unsigned LicmMssaOptCap;
64 
65  /// Tuning option to disable promotion to scalars in LICM with MemorySSA, if
66  /// the number of access is too large.
68 
69  /// Tuning option to enable/disable call graph profile. Its default value is
70  /// that of the flag: `-enable-npm-call-graph-profile`.
72 
73  /// Tuning option to enable/disable function merging. Its default value is
74  /// false.
76 };
77 
78 /// This class provides access to building LLVM's passes.
79 ///
80 /// Its members provide the baseline state available to passes during their
81 /// construction. The \c PassRegistry.def file specifies how to construct all
82 /// of the built-in passes, and those may reference these members during
83 /// construction.
84 class PassBuilder {
85  TargetMachine *TM;
87  Optional<PGOOptions> PGOOpt;
89 
90 public:
91  /// A struct to capture parsed pass pipeline names.
92  ///
93  /// A pipeline is defined as a series of names, each of which may in itself
94  /// recursively contain a nested pipeline. A name is either the name of a pass
95  /// (e.g. "instcombine") or the name of a pipeline type (e.g. "cgscc"). If the
96  /// name is the name of a pass, the InnerPipeline is empty, since passes
97  /// cannot contain inner pipelines. See parsePassPipeline() for a more
98  /// detailed description of the textual pipeline format.
99  struct PipelineElement {
101  std::vector<PipelineElement> InnerPipeline;
102  };
103 
104  explicit PassBuilder(TargetMachine *TM = nullptr,
106  Optional<PGOOptions> PGOOpt = None,
107  PassInstrumentationCallbacks *PIC = nullptr);
108 
109  /// Cross register the analysis managers through their proxies.
110  ///
111  /// This is an interface that can be used to cross register each
112  /// AnalysisManager with all the others analysis managers.
117 
118  /// Registers all available module analysis passes.
119  ///
120  /// This is an interface that can be used to populate a \c
121  /// ModuleAnalysisManager with all registered module analyses. Callers can
122  /// still manually register any additional analyses. Callers can also
123  /// pre-register analyses and this will not override those.
125 
126  /// Registers all available CGSCC analysis passes.
127  ///
128  /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
129  /// with all registered CGSCC analyses. Callers can still manually register any
130  /// additional analyses. Callers can also pre-register analyses and this will
131  /// not override those.
133 
134  /// Registers all available function analysis passes.
135  ///
136  /// This is an interface that can be used to populate a \c
137  /// FunctionAnalysisManager with all registered function analyses. Callers can
138  /// still manually register any additional analyses. Callers can also
139  /// pre-register analyses and this will not override those.
141 
142  /// Registers all available loop analysis passes.
143  ///
144  /// This is an interface that can be used to populate a \c LoopAnalysisManager
145  /// with all registered loop analyses. Callers can still manually register any
146  /// additional analyses.
148 
149  /// Construct the core LLVM function canonicalization and simplification
150  /// pipeline.
151  ///
152  /// This is a long pipeline and uses most of the per-function optimization
153  /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
154  /// repeatedly over the IR and is not expected to destroy important
155  /// information about the semantics of the IR.
156  ///
157  /// Note that \p Level cannot be `O0` here. The pipelines produced are
158  /// only intended for use when attempting to optimize code. If frontends
159  /// require some transformations for semantic reasons, they should explicitly
160  /// build them.
161  ///
162  /// \p Phase indicates the current ThinLTO phase.
166 
167  /// Construct the core LLVM module canonicalization and simplification
168  /// pipeline.
169  ///
170  /// This pipeline focuses on canonicalizing and simplifying the entire module
171  /// of IR. Much like the function simplification pipeline above, it is
172  /// suitable to run repeatedly over the IR and is not expected to destroy
173  /// important information. It does, however, perform inlining and other
174  /// heuristic based simplifications that are not strictly reversible.
175  ///
176  /// Note that \p Level cannot be `O0` here. The pipelines produced are
177  /// only intended for use when attempting to optimize code. If frontends
178  /// require some transformations for semantic reasons, they should explicitly
179  /// build them.
180  ///
181  /// \p Phase indicates the current ThinLTO phase.
184 
185  /// Construct the module pipeline that performs inlining as well as
186  /// the inlining-driven cleanups.
189 
190  /// Construct the core LLVM module optimization pipeline.
191  ///
192  /// This pipeline focuses on optimizing the execution speed of the IR. It
193  /// uses cost modeling and thresholds to balance code growth against runtime
194  /// improvements. It includes vectorization and other information destroying
195  /// transformations. It also cannot generally be run repeatedly on a module
196  /// without potentially seriously regressing either runtime performance of
197  /// the code or serious code size growth.
198  ///
199  /// Note that \p Level cannot be `O0` here. The pipelines produced are
200  /// only intended for use when attempting to optimize code. If frontends
201  /// require some transformations for semantic reasons, they should explicitly
202  /// build them.
204  bool LTOPreLink = false);
205 
206  /// Build a per-module default optimization pipeline.
207  ///
208  /// This provides a good default optimization pipeline for per-module
209  /// optimization and code generation without any link-time optimization. It
210  /// typically correspond to frontend "-O[123]" options for optimization
211  /// levels \c O1, \c O2 and \c O3 resp.
212  ///
213  /// Note that \p Level cannot be `O0` here. The pipelines produced are
214  /// only intended for use when attempting to optimize code. If frontends
215  /// require some transformations for semantic reasons, they should explicitly
216  /// build them.
218  bool LTOPreLink = false);
219 
220  /// Build a pre-link, ThinLTO-targeting default optimization pipeline to
221  /// a pass manager.
222  ///
223  /// This adds the pre-link optimizations tuned to prepare a module for
224  /// a ThinLTO run. It works to minimize the IR which needs to be analyzed
225  /// without making irreversible decisions which could be made better during
226  /// the LTO run.
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 
234  /// Build an ThinLTO default optimization pipeline to a pass manager.
235  ///
236  /// This provides a good default optimization pipeline for link-time
237  /// optimization and code generation. It is particularly tuned to fit well
238  /// when IR coming into the LTO phase was first run through \c
239  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
240  ///
241  /// Note that \p Level cannot be `O0` here. The pipelines produced are
242  /// only intended for use when attempting to optimize code. If frontends
243  /// require some transformations for semantic reasons, they should explicitly
244  /// build them.
247  const ModuleSummaryIndex *ImportSummary);
248 
249  /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
250  /// manager.
251  ///
252  /// This adds the pre-link optimizations tuned to work well with a later LTO
253  /// run. It works to minimize the IR which needs to be analyzed without
254  /// making irreversible decisions which could be made better during the LTO
255  /// run.
256  ///
257  /// Note that \p Level cannot be `O0` here. The pipelines produced are
258  /// only intended for use when attempting to optimize code. If frontends
259  /// require some transformations for semantic reasons, they should explicitly
260  /// build them.
262 
263  /// Build an LTO default optimization pipeline to a pass manager.
264  ///
265  /// This provides a good default optimization pipeline for link-time
266  /// optimization and code generation. It is particularly tuned to fit well
267  /// when IR coming into the LTO phase was first run through \c
268  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
269  ///
270  /// Note that \p Level cannot be `O0` here. The pipelines produced are
271  /// only intended for use when attempting to optimize code. If frontends
272  /// require some transformations for semantic reasons, they should explicitly
273  /// build them.
275  ModuleSummaryIndex *ExportSummary);
276 
277  /// Build an O0 pipeline with the minimal semantically required passes.
278  ///
279  /// This should only be used for non-LTO and LTO pre-link pipelines.
281  bool LTOPreLink = false);
282 
283  /// Build the default `AAManager` with the default alias analysis pipeline
284  /// registered.
285  ///
286  /// This also adds target-specific alias analyses registered via
287  /// TargetMachine::registerDefaultAliasAnalyses().
289 
290  /// Parse a textual pass pipeline description into a \c
291  /// ModulePassManager.
292  ///
293  /// The format of the textual pass pipeline description looks something like:
294  ///
295  /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
296  ///
297  /// Pass managers have ()s describing the nest structure of passes. All passes
298  /// are comma separated. As a special shortcut, if the very first pass is not
299  /// a module pass (as a module pass manager is), this will automatically form
300  /// the shortest stack of pass managers that allow inserting that first pass.
301  /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop
302  /// passes 'lpassN', all of these are valid:
303  ///
304  /// fpass1,fpass2,fpass3
305  /// cgpass1,cgpass2,cgpass3
306  /// lpass1,lpass2,lpass3
307  ///
308  /// And they are equivalent to the following (resp.):
309  ///
310  /// module(function(fpass1,fpass2,fpass3))
311  /// module(cgscc(cgpass1,cgpass2,cgpass3))
312  /// module(function(loop(lpass1,lpass2,lpass3)))
313  ///
314  /// This shortcut is especially useful for debugging and testing small pass
315  /// combinations.
316  ///
317  /// The sequence of passes aren't necessarily the exact same kind of pass.
318  /// You can mix different levels implicitly if adaptor passes are defined to
319  /// make them work. For example,
320  ///
321  /// mpass1,fpass1,fpass2,mpass2,lpass1
322  ///
323  /// This pipeline uses only one pass manager: the top-level module manager.
324  /// fpass1,fpass2 and lpass1 are added into the the top-level module manager
325  /// using only adaptor passes. No nested function/loop pass managers are
326  /// added. The purpose is to allow easy pass testing when the user
327  /// specifically want the pass to run under a adaptor directly. This is
328  /// preferred when a pipeline is largely of one type, but one or just a few
329  /// passes are of different types(See PassBuilder.cpp for examples).
331 
332  /// {{@ Parse a textual pass pipeline description into a specific PassManager
333  ///
334  /// Automatic deduction of an appropriate pass manager stack is not supported.
335  /// For example, to insert a loop pass 'lpass' into a FunctionPassManager,
336  /// this is the valid pipeline text:
337  ///
338  /// function(lpass)
339  Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText);
341  Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText);
342  /// @}}
343 
344  /// Parse a textual alias analysis pipeline into the provided AA manager.
345  ///
346  /// The format of the textual AA pipeline is a comma separated list of AA
347  /// pass names:
348  ///
349  /// basic-aa,globals-aa,...
350  ///
351  /// The AA manager is set up such that the provided alias analyses are tried
352  /// in the order specified. See the \c AAManaager documentation for details
353  /// about the logic used. This routine just provides the textual mapping
354  /// between AA names and the analyses to register with the manager.
355  ///
356  /// Returns false if the text cannot be parsed cleanly. The specific state of
357  /// the \p AA manager is unspecified if such an error is encountered and this
358  /// returns false.
359  Error parseAAPipeline(AAManager &AA, StringRef PipelineText);
360 
361  /// Returns true if the pass name is the name of an alias analysis pass.
363 
364  /// Returns true if the pass name is the name of a (non-alias) analysis pass.
366 
367  /// Print pass names.
368  void printPassNames(raw_ostream &OS);
369 
370  /// Register a callback for a default optimizer pipeline extension
371  /// point
372  ///
373  /// This extension point allows adding passes that perform peephole
374  /// optimizations similar to the instruction combiner. These passes will be
375  /// inserted after each instance of the instruction combiner pass.
378  PeepholeEPCallbacks.push_back(C);
379  }
380 
381  /// Register a callback for a default optimizer pipeline extension
382  /// point
383  ///
384  /// This extension point allows adding late loop canonicalization and
385  /// simplification passes. This is the last point in the loop optimization
386  /// pipeline before loop deletion. Each pass added
387  /// here must be an instance of LoopPass.
388  /// This is the place to add passes that can remove loops, such as target-
389  /// specific loop idiom recognition.
392  LateLoopOptimizationsEPCallbacks.push_back(C);
393  }
394 
395  /// Register a callback for a default optimizer pipeline extension
396  /// point
397  ///
398  /// This extension point allows adding loop passes to the end of the loop
399  /// optimizer.
402  LoopOptimizerEndEPCallbacks.push_back(C);
403  }
404 
405  /// Register a callback for a default optimizer pipeline extension
406  /// point
407  ///
408  /// This extension point allows adding optimization passes after most of the
409  /// main optimizations, but before the last cleanup-ish optimizations.
412  ScalarOptimizerLateEPCallbacks.push_back(C);
413  }
414 
415  /// Register a callback for a default optimizer pipeline extension
416  /// point
417  ///
418  /// This extension point allows adding CallGraphSCC passes at the end of the
419  /// main CallGraphSCC passes and before any function simplification passes run
420  /// by CGPassManager.
423  CGSCCOptimizerLateEPCallbacks.push_back(C);
424  }
425 
426  /// Register a callback for a default optimizer pipeline extension
427  /// point
428  ///
429  /// This extension point allows adding optimization passes before the
430  /// vectorizer and other highly target specific optimization passes are
431  /// executed.
434  VectorizerStartEPCallbacks.push_back(C);
435  }
436 
437  /// Register a callback for a default optimizer pipeline extension point.
438  ///
439  /// This extension point allows adding optimization once at the start of the
440  /// pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO
441  /// link-time pipelines).
444  PipelineStartEPCallbacks.push_back(C);
445  }
446 
447  /// Register a callback for a default optimizer pipeline extension point.
448  ///
449  /// This extension point allows adding optimization right after passes that do
450  /// basic simplification of the input IR.
453  PipelineEarlySimplificationEPCallbacks.push_back(C);
454  }
455 
456  /// Register a callback for a default optimizer pipeline extension point
457  ///
458  /// This extension point allows adding optimizations at the very end of the
459  /// function optimization pipeline.
462  OptimizerLastEPCallbacks.push_back(C);
463  }
464 
465  /// Register a callback for parsing an AliasAnalysis Name to populate
466  /// the given AAManager \p AA
468  const std::function<bool(StringRef Name, AAManager &AA)> &C) {
469  AAParsingCallbacks.push_back(C);
470  }
471 
472  /// {{@ Register callbacks for analysis registration with this PassBuilder
473  /// instance.
474  /// Callees register their analyses with the given AnalysisManager objects.
476  const std::function<void(CGSCCAnalysisManager &)> &C) {
477  CGSCCAnalysisRegistrationCallbacks.push_back(C);
478  }
480  const std::function<void(FunctionAnalysisManager &)> &C) {
481  FunctionAnalysisRegistrationCallbacks.push_back(C);
482  }
484  const std::function<void(LoopAnalysisManager &)> &C) {
485  LoopAnalysisRegistrationCallbacks.push_back(C);
486  }
488  const std::function<void(ModuleAnalysisManager &)> &C) {
489  ModuleAnalysisRegistrationCallbacks.push_back(C);
490  }
491  /// @}}
492 
493  /// {{@ Register pipeline parsing callbacks with this pass builder instance.
494  /// Using these callbacks, callers can parse both a single pass name, as well
495  /// as entire sub-pipelines, and populate the PassManager instance
496  /// accordingly.
500  CGSCCPipelineParsingCallbacks.push_back(C);
501  }
505  FunctionPipelineParsingCallbacks.push_back(C);
506  }
510  LoopPipelineParsingCallbacks.push_back(C);
511  }
515  ModulePipelineParsingCallbacks.push_back(C);
516  }
517  /// @}}
518 
519  /// Register a callback for a top-level pipeline entry.
520  ///
521  /// If the PassManager type is not given at the top level of the pipeline
522  /// text, this Callback should be used to determine the appropriate stack of
523  /// PassManagers and populate the passed ModulePassManager.
526  &C);
527 
528  /// Add PGOInstrumenation passes for O0 only.
529  void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen,
530  bool IsCS, std::string ProfileFile,
531  std::string ProfileRemappingFile);
532 
533  /// Returns PIC. External libraries can use this to register pass
534  /// instrumentation callbacks.
536  return PIC;
537  }
538 
539 private:
540  // O1 pass pipeline
542  buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
544 
545  void addRequiredLTOPreLinkPasses(ModulePassManager &MPM);
546 
547  void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
548  bool IsFullLTO);
549 
551  parsePipelineText(StringRef Text);
552 
553  Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
554  Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
555  Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
556  Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
557  bool parseAAPassName(AAManager &AA, StringRef Name);
558 
559  Error parseLoopPassPipeline(LoopPassManager &LPM,
560  ArrayRef<PipelineElement> Pipeline);
561  Error parseFunctionPassPipeline(FunctionPassManager &FPM,
562  ArrayRef<PipelineElement> Pipeline);
563  Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
564  ArrayRef<PipelineElement> Pipeline);
565  Error parseModulePassPipeline(ModulePassManager &MPM,
566  ArrayRef<PipelineElement> Pipeline);
567 
568  void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
569  bool RunProfileGen, bool IsCS, std::string ProfileFile,
570  std::string ProfileRemappingFile);
571  void invokePeepholeEPCallbacks(FunctionPassManager &, OptimizationLevel);
572 
573  // Extension Point callbacks
575  PeepholeEPCallbacks;
577  LateLoopOptimizationsEPCallbacks;
579  LoopOptimizerEndEPCallbacks;
581  ScalarOptimizerLateEPCallbacks;
583  CGSCCOptimizerLateEPCallbacks;
585  VectorizerStartEPCallbacks;
587  OptimizerLastEPCallbacks;
588  // Module callbacks
590  PipelineStartEPCallbacks;
592  PipelineEarlySimplificationEPCallbacks;
593 
595  ModuleAnalysisRegistrationCallbacks;
598  2>
599  ModulePipelineParsingCallbacks;
600  SmallVector<
602  TopLevelPipelineParsingCallbacks;
603  // CGSCC callbacks
605  CGSCCAnalysisRegistrationCallbacks;
608  2>
609  CGSCCPipelineParsingCallbacks;
610  // Function callbacks
612  FunctionAnalysisRegistrationCallbacks;
615  2>
616  FunctionPipelineParsingCallbacks;
617  // Loop callbacks
619  LoopAnalysisRegistrationCallbacks;
622  2>
623  LoopPipelineParsingCallbacks;
624  // AA callbacks
626  AAParsingCallbacks;
627 };
628 
629 /// This utility template takes care of adding require<> and invalidate<>
630 /// passes for an analysis to a given \c PassManager. It is intended to be used
631 /// during parsing of a pass pipeline when parsing a single PipelineName.
632 /// When registering a new function analysis FancyAnalysis with the pass
633 /// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look
634 /// like this:
635 ///
636 /// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
637 /// ArrayRef<PipelineElement> P) {
638 /// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name,
639 /// FPM))
640 /// return true;
641 /// return false;
642 /// }
643 template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
644  typename... ExtraArgTs>
646  StringRef AnalysisName, StringRef PipelineName,
648  if (!PipelineName.endswith(">"))
649  return false;
650  // See if this is an invalidate<> pass name
651  if (PipelineName.startswith("invalidate<")) {
652  PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
653  if (PipelineName != AnalysisName)
654  return false;
656  return true;
657  }
658 
659  // See if this is a require<> pass name
660  if (PipelineName.startswith("require<")) {
661  PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
662  if (PipelineName != AnalysisName)
663  return false;
664  PM.addPass(RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
665  ExtraArgTs...>());
666  return true;
667  }
668 
669  return false;
670 }
671 }
672 
673 #endif
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >
Definition: LoopPassManager.h:70
Instrumentation.h
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:1233
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:286
llvm
---------------------— PointerInfo ------------------------------------—
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:442
Inliner.h
llvm::StringRef::endswith
LLVM_NODISCARD bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition: StringRef.h:297
llvm::PassBuilder::getPassInstrumentationCallbacks
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Returns PIC.
Definition: PassBuilder.h:535
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::PassBuilder::buildModuleOptimizationPipeline
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Construct the core LLVM module optimization pipeline.
Definition: PassBuilderPipelines.cpp:1015
llvm::PassBuilder::PassBuilder
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), Optional< PGOOptions > PGOOpt=None, PassInstrumentationCallbacks *PIC=nullptr)
Definition: PassBuilder.cpp:362
llvm::PipelineTuningOptions
Tunable parameters for passes in the default pipelines.
Definition: PassBuilder.h:37
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:59
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:475
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:460
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:410
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:633
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:67
llvm::PassBuilder::parsePassPipeline
Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
Definition: PassBuilder.cpp:1523
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:611
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:502
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:121
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:467
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:84
llvm::PassBuilder::buildFunctionSimplificationPipeline
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:363
llvm::PassBuilder::PipelineElement
A struct to capture parsed pass pipeline names.
Definition: PassBuilder.h:99
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:645
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:663
llvm::PassBuilder::buildThinLTOPreLinkDefaultPipeline
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1213
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:1657
llvm::PassBuilder::isAAPassName
bool isAAPassName(StringRef PassName)
Returns true if the pass name is the name of an alias analysis pass.
Definition: PassBuilder.cpp:1646
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:451
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:512
llvm::PassBuilder::registerFunctionAnalyses
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
Definition: PassBuilder.cpp:415
llvm::PassBuilder::buildLTOPreLinkDefaultPipeline
ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1329
llvm::PassBuilder::registerModuleAnalyses
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
Definition: PassBuilder.cpp:397
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:432
CGSCCPassManager.h
llvm::PassBuilder::buildLTODefaultPipeline
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1338
llvm::InvalidateAnalysisPass
A no-op pass template which simply forces a specific analysis result to be invalidated.
Definition: PassManager.h:1270
llvm::PassBuilder::buildThinLTODefaultPipeline
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1273
llvm::PassBuilder::buildDefaultAAPipeline
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Definition: PassBuilderPipelines.cpp:1703
llvm::PipelineTuningOptions::PipelineTuningOptions
PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
Definition: PassBuilderPipelines.cpp:165
llvm::PassBuilder::printPassNames
void printPassNames(raw_ostream &OS)
Print pass names.
Definition: PassBuilder.cpp:1688
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:79
llvm::PipelineTuningOptions::SLPVectorization
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition: PassBuilder.h:52
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:400
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(FunctionAnalysisManager &)> &C)
Definition: PassBuilder.h:479
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:497
LoopPassManager.h
llvm::PassBuilder::PipelineElement::Name
StringRef Name
Definition: PassBuilder.h:100
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:390
llvm::PipelineTuningOptions::CallGraphProfile
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
Definition: PassBuilder.h:71
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:58
llvm::PipelineTuningOptions::LoopVectorization
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition: PassBuilder.h:48
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:507
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:1626
llvm::PassManager< Function >
llvm::PassBuilder::registerLoopAnalyses
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
Definition: PassBuilder.cpp:424
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:1172
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:75
llvm::PassBuilder::registerCGSCCAnalyses
void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
Definition: PassBuilder.cpp:406
PGOOptions.h
llvm::OptimizationLevel
Definition: OptimizationLevel.h:22
PassManager.h
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(LoopAnalysisManager &)> &C)
Definition: PassBuilder.h:483
llvm::PassBuilder::buildO0DefaultPipeline
ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build an O0 pipeline with the minimal semantically required passes.
Definition: PassBuilderPipelines.cpp:1604
OptimizationLevel.h
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1028
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:1498
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:421
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:376
llvm::RequireAnalysisPass
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1242
llvm::PassBuilder::buildModuleSimplificationPipeline
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM module canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:729
llvm::PipelineTuningOptions::LoopUnrolling
bool LoopUnrolling
Tuning option to enable/disable loop unrolling. Its default value is true.
Definition: PassBuilder.h:55
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(ModuleAnalysisManager &)> &C)
Definition: PassBuilder.h:487
llvm::PipelineTuningOptions::LicmMssaOptCap
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
Definition: PassBuilder.h:63
raw_ostream.h
llvm::PipelineTuningOptions::LoopInterleaving
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
Definition: PassBuilder.h:44
llvm::PassManager::addPass
std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
Definition: PassManager.h:552
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:157
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:1752
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70
CGAM
CGSCCAnalysisManager CGAM
Definition: PassBuilderBindings.cpp:60
PassName
static const char PassName[]
Definition: X86LowerAMXIntrinsics.cpp:669
llvm::PassBuilder::PipelineElement::InnerPipeline
std::vector< PipelineElement > InnerPipeline
Definition: PassBuilder.h:101