LLVM  16.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  /// Tuning option to override the default inliner threshold.
80 
81  // Experimental option to eagerly invalidate more analyses. This has the
82  // potential to decrease max memory usage in exchange for more compile time.
83  // This may affect codegen due to either passes using analyses only when
84  // cached, or invalidating and recalculating an analysis that was
85  // stale/imprecise but still valid. Currently this invalidates all function
86  // analyses after various module->function or cgscc->function adaptors in the
87  // default pipelines.
89 };
90 
91 /// This class provides access to building LLVM's passes.
92 ///
93 /// Its members provide the baseline state available to passes during their
94 /// construction. The \c PassRegistry.def file specifies how to construct all
95 /// of the built-in passes, and those may reference these members during
96 /// construction.
97 class PassBuilder {
98  TargetMachine *TM;
100  std::optional<PGOOptions> PGOOpt;
102 
103 public:
104  /// A struct to capture parsed pass pipeline names.
105  ///
106  /// A pipeline is defined as a series of names, each of which may in itself
107  /// recursively contain a nested pipeline. A name is either the name of a pass
108  /// (e.g. "instcombine") or the name of a pipeline type (e.g. "cgscc"). If the
109  /// name is the name of a pass, the InnerPipeline is empty, since passes
110  /// cannot contain inner pipelines. See parsePassPipeline() for a more
111  /// detailed description of the textual pipeline format.
114  std::vector<PipelineElement> InnerPipeline;
115  };
116 
117  explicit PassBuilder(TargetMachine *TM = nullptr,
119  std::optional<PGOOptions> PGOOpt = std::nullopt,
120  PassInstrumentationCallbacks *PIC = nullptr);
121 
122  /// Cross register the analysis managers through their proxies.
123  ///
124  /// This is an interface that can be used to cross register each
125  /// AnalysisManager with all the others analysis managers.
130 
131  /// Registers all available module analysis passes.
132  ///
133  /// This is an interface that can be used to populate a \c
134  /// ModuleAnalysisManager with all registered module analyses. Callers can
135  /// still manually register any additional analyses. Callers can also
136  /// pre-register analyses and this will not override those.
138 
139  /// Registers all available CGSCC analysis passes.
140  ///
141  /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
142  /// with all registered CGSCC analyses. Callers can still manually register any
143  /// additional analyses. Callers can also pre-register analyses and this will
144  /// not override those.
146 
147  /// Registers all available function analysis passes.
148  ///
149  /// This is an interface that can be used to populate a \c
150  /// FunctionAnalysisManager with all registered function analyses. Callers can
151  /// still manually register any additional analyses. Callers can also
152  /// pre-register analyses and this will not override those.
154 
155  /// Registers all available loop analysis passes.
156  ///
157  /// This is an interface that can be used to populate a \c LoopAnalysisManager
158  /// with all registered loop analyses. Callers can still manually register any
159  /// additional analyses.
161 
162  /// Construct the core LLVM function canonicalization and simplification
163  /// pipeline.
164  ///
165  /// This is a long pipeline and uses most of the per-function optimization
166  /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
167  /// repeatedly over the IR and is not expected to destroy important
168  /// information about the semantics of the IR.
169  ///
170  /// Note that \p Level cannot be `O0` here. The pipelines produced are
171  /// only intended for use when attempting to optimize code. If frontends
172  /// require some transformations for semantic reasons, they should explicitly
173  /// build them.
174  ///
175  /// \p Phase indicates the current ThinLTO phase.
179 
180  /// Construct the core LLVM module canonicalization and simplification
181  /// pipeline.
182  ///
183  /// This pipeline focuses on canonicalizing and simplifying the entire module
184  /// of IR. Much like the function simplification pipeline above, it is
185  /// suitable to run repeatedly over the IR and is not expected to destroy
186  /// important information. It does, however, perform inlining and other
187  /// heuristic based simplifications that are not strictly reversible.
188  ///
189  /// Note that \p Level cannot be `O0` here. The pipelines produced are
190  /// only intended for use when attempting to optimize code. If frontends
191  /// require some transformations for semantic reasons, they should explicitly
192  /// build them.
193  ///
194  /// \p Phase indicates the current ThinLTO phase.
197 
198  /// Construct the module pipeline that performs inlining as well as
199  /// the inlining-driven cleanups.
202 
203  /// Construct the module pipeline that performs inlining with
204  /// module inliner pass.
207 
208  /// Construct the core LLVM module optimization pipeline.
209  ///
210  /// This pipeline focuses on optimizing the execution speed of the IR. It
211  /// uses cost modeling and thresholds to balance code growth against runtime
212  /// improvements. It includes vectorization and other information destroying
213  /// transformations. It also cannot generally be run repeatedly on a module
214  /// without potentially seriously regressing either runtime performance of
215  /// the code or serious code size growth.
216  ///
217  /// Note that \p Level cannot be `O0` here. The pipelines produced are
218  /// only intended for use when attempting to optimize code. If frontends
219  /// require some transformations for semantic reasons, they should explicitly
220  /// build them.
223  ThinOrFullLTOPhase LTOPhase);
224 
225  /// Build a per-module default optimization pipeline.
226  ///
227  /// This provides a good default optimization pipeline for per-module
228  /// optimization and code generation without any link-time optimization. It
229  /// typically correspond to frontend "-O[123]" options for optimization
230  /// levels \c O1, \c O2 and \c O3 resp.
231  ///
232  /// Note that \p Level cannot be `O0` here. The pipelines produced are
233  /// only intended for use when attempting to optimize code. If frontends
234  /// require some transformations for semantic reasons, they should explicitly
235  /// build them.
237  bool LTOPreLink = false);
238 
239  /// Build a pre-link, ThinLTO-targeting default optimization pipeline to
240  /// a pass manager.
241  ///
242  /// This adds the pre-link optimizations tuned to prepare a module for
243  /// a ThinLTO run. It works to minimize the IR which needs to be analyzed
244  /// without making irreversible decisions which could be made better during
245  /// the LTO run.
246  ///
247  /// Note that \p Level cannot be `O0` here. The pipelines produced are
248  /// only intended for use when attempting to optimize code. If frontends
249  /// require some transformations for semantic reasons, they should explicitly
250  /// build them.
252 
253  /// Build an ThinLTO default optimization pipeline to a pass manager.
254  ///
255  /// This provides a good default optimization pipeline for link-time
256  /// optimization and code generation. It is particularly tuned to fit well
257  /// when IR coming into the LTO phase was first run through \c
258  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
259  ///
260  /// Note that \p Level cannot be `O0` here. The pipelines produced are
261  /// only intended for use when attempting to optimize code. If frontends
262  /// require some transformations for semantic reasons, they should explicitly
263  /// build them.
266  const ModuleSummaryIndex *ImportSummary);
267 
268  /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
269  /// manager.
270  ///
271  /// This adds the pre-link optimizations tuned to work well with a later LTO
272  /// run. It works to minimize the IR which needs to be analyzed without
273  /// making irreversible decisions which could be made better during the LTO
274  /// run.
275  ///
276  /// Note that \p Level cannot be `O0` here. The pipelines produced are
277  /// only intended for use when attempting to optimize code. If frontends
278  /// require some transformations for semantic reasons, they should explicitly
279  /// build them.
281 
282  /// Build an LTO default optimization pipeline to a pass manager.
283  ///
284  /// This provides a good default optimization pipeline for link-time
285  /// optimization and code generation. It is particularly tuned to fit well
286  /// when IR coming into the LTO phase was first run through \c
287  /// addPreLinkLTODefaultPipeline, and the two coordinate closely.
288  ///
289  /// Note that \p Level cannot be `O0` here. The pipelines produced are
290  /// only intended for use when attempting to optimize code. If frontends
291  /// require some transformations for semantic reasons, they should explicitly
292  /// build them.
294  ModuleSummaryIndex *ExportSummary);
295 
296  /// Build an O0 pipeline with the minimal semantically required passes.
297  ///
298  /// This should only be used for non-LTO and LTO pre-link pipelines.
300  bool LTOPreLink = false);
301 
302  /// Build the default `AAManager` with the default alias analysis pipeline
303  /// registered.
304  ///
305  /// This also adds target-specific alias analyses registered via
306  /// TargetMachine::registerDefaultAliasAnalyses().
308 
309  /// Parse a textual pass pipeline description into a \c
310  /// ModulePassManager.
311  ///
312  /// The format of the textual pass pipeline description looks something like:
313  ///
314  /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
315  ///
316  /// Pass managers have ()s describing the nest structure of passes. All passes
317  /// are comma separated. As a special shortcut, if the very first pass is not
318  /// a module pass (as a module pass manager is), this will automatically form
319  /// the shortest stack of pass managers that allow inserting that first pass.
320  /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop
321  /// passes 'lpassN', all of these are valid:
322  ///
323  /// fpass1,fpass2,fpass3
324  /// cgpass1,cgpass2,cgpass3
325  /// lpass1,lpass2,lpass3
326  ///
327  /// And they are equivalent to the following (resp.):
328  ///
329  /// module(function(fpass1,fpass2,fpass3))
330  /// module(cgscc(cgpass1,cgpass2,cgpass3))
331  /// module(function(loop(lpass1,lpass2,lpass3)))
332  ///
333  /// This shortcut is especially useful for debugging and testing small pass
334  /// combinations.
335  ///
336  /// The sequence of passes aren't necessarily the exact same kind of pass.
337  /// You can mix different levels implicitly if adaptor passes are defined to
338  /// make them work. For example,
339  ///
340  /// mpass1,fpass1,fpass2,mpass2,lpass1
341  ///
342  /// This pipeline uses only one pass manager: the top-level module manager.
343  /// fpass1,fpass2 and lpass1 are added into the the top-level module manager
344  /// using only adaptor passes. No nested function/loop pass managers are
345  /// added. The purpose is to allow easy pass testing when the user
346  /// specifically want the pass to run under a adaptor directly. This is
347  /// preferred when a pipeline is largely of one type, but one or just a few
348  /// passes are of different types(See PassBuilder.cpp for examples).
350 
351  /// {{@ Parse a textual pass pipeline description into a specific PassManager
352  ///
353  /// Automatic deduction of an appropriate pass manager stack is not supported.
354  /// For example, to insert a loop pass 'lpass' into a FunctionPassManager,
355  /// this is the valid pipeline text:
356  ///
357  /// function(lpass)
358  Error parsePassPipeline(CGSCCPassManager &CGPM, StringRef PipelineText);
360  Error parsePassPipeline(LoopPassManager &LPM, StringRef PipelineText);
361  /// @}}
362 
363  /// Parse a textual alias analysis pipeline into the provided AA manager.
364  ///
365  /// The format of the textual AA pipeline is a comma separated list of AA
366  /// pass names:
367  ///
368  /// basic-aa,globals-aa,...
369  ///
370  /// The AA manager is set up such that the provided alias analyses are tried
371  /// in the order specified. See the \c AAManaager documentation for details
372  /// about the logic used. This routine just provides the textual mapping
373  /// between AA names and the analyses to register with the manager.
374  ///
375  /// Returns false if the text cannot be parsed cleanly. The specific state of
376  /// the \p AA manager is unspecified if such an error is encountered and this
377  /// returns false.
378  Error parseAAPipeline(AAManager &AA, StringRef PipelineText);
379 
380  /// Print pass names.
381  void printPassNames(raw_ostream &OS);
382 
383  /// Register a callback for a default optimizer pipeline extension
384  /// point
385  ///
386  /// This extension point allows adding passes that perform peephole
387  /// optimizations similar to the instruction combiner. These passes will be
388  /// inserted after each instance of the instruction combiner pass.
391  PeepholeEPCallbacks.push_back(C);
392  }
393 
394  /// Register a callback for a default optimizer pipeline extension
395  /// point
396  ///
397  /// This extension point allows adding late loop canonicalization and
398  /// simplification passes. This is the last point in the loop optimization
399  /// pipeline before loop deletion. Each pass added
400  /// here must be an instance of LoopPass.
401  /// This is the place to add passes that can remove loops, such as target-
402  /// specific loop idiom recognition.
405  LateLoopOptimizationsEPCallbacks.push_back(C);
406  }
407 
408  /// Register a callback for a default optimizer pipeline extension
409  /// point
410  ///
411  /// This extension point allows adding loop passes to the end of the loop
412  /// optimizer.
415  LoopOptimizerEndEPCallbacks.push_back(C);
416  }
417 
418  /// Register a callback for a default optimizer pipeline extension
419  /// point
420  ///
421  /// This extension point allows adding optimization passes after most of the
422  /// main optimizations, but before the last cleanup-ish optimizations.
425  ScalarOptimizerLateEPCallbacks.push_back(C);
426  }
427 
428  /// Register a callback for a default optimizer pipeline extension
429  /// point
430  ///
431  /// This extension point allows adding CallGraphSCC passes at the end of the
432  /// main CallGraphSCC passes and before any function simplification passes run
433  /// by CGPassManager.
436  CGSCCOptimizerLateEPCallbacks.push_back(C);
437  }
438 
439  /// Register a callback for a default optimizer pipeline extension
440  /// point
441  ///
442  /// This extension point allows adding optimization passes before the
443  /// vectorizer and other highly target specific optimization passes are
444  /// executed.
447  VectorizerStartEPCallbacks.push_back(C);
448  }
449 
450  /// Register a callback for a default optimizer pipeline extension point.
451  ///
452  /// This extension point allows adding optimization once at the start of the
453  /// pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO
454  /// link-time pipelines).
457  PipelineStartEPCallbacks.push_back(C);
458  }
459 
460  /// Register a callback for a default optimizer pipeline extension point.
461  ///
462  /// This extension point allows adding optimization right after passes that do
463  /// basic simplification of the input IR.
466  PipelineEarlySimplificationEPCallbacks.push_back(C);
467  }
468 
469  /// Register a callback for a default optimizer pipeline extension point
470  ///
471  /// This extension point allows adding optimizations before the function
472  /// optimization pipeline.
475  OptimizerEarlyEPCallbacks.push_back(C);
476  }
477 
478  /// Register a callback for a default optimizer pipeline extension point
479  ///
480  /// This extension point allows adding optimizations at the very end of the
481  /// function optimization pipeline.
484  OptimizerLastEPCallbacks.push_back(C);
485  }
486 
487  /// Register a callback for a default optimizer pipeline extension point
488  ///
489  /// This extension point allows adding optimizations at the start of the full
490  /// LTO pipeline.
493  FullLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
494  }
495 
496  /// Register a callback for a default optimizer pipeline extension point
497  ///
498  /// This extension point allows adding optimizations at the end of the full
499  /// LTO pipeline.
502  FullLinkTimeOptimizationLastEPCallbacks.push_back(C);
503  }
504 
505  /// Register a callback for parsing an AliasAnalysis Name to populate
506  /// the given AAManager \p AA
508  const std::function<bool(StringRef Name, AAManager &AA)> &C) {
509  AAParsingCallbacks.push_back(C);
510  }
511 
512  /// {{@ Register callbacks for analysis registration with this PassBuilder
513  /// instance.
514  /// Callees register their analyses with the given AnalysisManager objects.
516  const std::function<void(CGSCCAnalysisManager &)> &C) {
517  CGSCCAnalysisRegistrationCallbacks.push_back(C);
518  }
520  const std::function<void(FunctionAnalysisManager &)> &C) {
521  FunctionAnalysisRegistrationCallbacks.push_back(C);
522  }
524  const std::function<void(LoopAnalysisManager &)> &C) {
525  LoopAnalysisRegistrationCallbacks.push_back(C);
526  }
528  const std::function<void(ModuleAnalysisManager &)> &C) {
529  ModuleAnalysisRegistrationCallbacks.push_back(C);
530  }
531  /// @}}
532 
533  /// {{@ Register pipeline parsing callbacks with this pass builder instance.
534  /// Using these callbacks, callers can parse both a single pass name, as well
535  /// as entire sub-pipelines, and populate the PassManager instance
536  /// accordingly.
538  const std::function<bool(StringRef Name, CGSCCPassManager &,
540  CGSCCPipelineParsingCallbacks.push_back(C);
541  }
543  const std::function<bool(StringRef Name, FunctionPassManager &,
545  FunctionPipelineParsingCallbacks.push_back(C);
546  }
548  const std::function<bool(StringRef Name, LoopPassManager &,
550  LoopPipelineParsingCallbacks.push_back(C);
551  }
553  const std::function<bool(StringRef Name, ModulePassManager &,
555  ModulePipelineParsingCallbacks.push_back(C);
556  }
557  /// @}}
558 
559  /// Register a callback for a top-level pipeline entry.
560  ///
561  /// If the PassManager type is not given at the top level of the pipeline
562  /// text, this Callback should be used to determine the appropriate stack of
563  /// PassManagers and populate the passed ModulePassManager.
566  &C);
567 
568  /// Add PGOInstrumenation passes for O0 only.
569  void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen,
570  bool IsCS, std::string ProfileFile,
571  std::string ProfileRemappingFile);
572 
573  /// Returns PIC. External libraries can use this to register pass
574  /// instrumentation callbacks.
576  return PIC;
577  }
578 
579 private:
580  // O1 pass pipeline
582  buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
584 
585  void addRequiredLTOPreLinkPasses(ModulePassManager &MPM);
586 
587  void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
588  bool IsFullLTO);
589 
590  static std::optional<std::vector<PipelineElement>>
591  parsePipelineText(StringRef Text);
592 
593  Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
594  Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
595  Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
596  Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
597  bool parseAAPassName(AAManager &AA, StringRef Name);
598 
599  Error parseLoopPassPipeline(LoopPassManager &LPM,
600  ArrayRef<PipelineElement> Pipeline);
601  Error parseFunctionPassPipeline(FunctionPassManager &FPM,
602  ArrayRef<PipelineElement> Pipeline);
603  Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
604  ArrayRef<PipelineElement> Pipeline);
605  Error parseModulePassPipeline(ModulePassManager &MPM,
606  ArrayRef<PipelineElement> Pipeline);
607 
608  void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
609  bool RunProfileGen, bool IsCS, std::string ProfileFile,
610  std::string ProfileRemappingFile,
611  ThinOrFullLTOPhase LTOPhase);
612  void invokePeepholeEPCallbacks(FunctionPassManager &, OptimizationLevel);
613 
614  // Extension Point callbacks
616  PeepholeEPCallbacks;
618  LateLoopOptimizationsEPCallbacks;
620  LoopOptimizerEndEPCallbacks;
622  ScalarOptimizerLateEPCallbacks;
624  CGSCCOptimizerLateEPCallbacks;
626  VectorizerStartEPCallbacks;
627  // Module callbacks
629  OptimizerEarlyEPCallbacks;
631  OptimizerLastEPCallbacks;
633  FullLinkTimeOptimizationEarlyEPCallbacks;
635  FullLinkTimeOptimizationLastEPCallbacks;
637  PipelineStartEPCallbacks;
639  PipelineEarlySimplificationEPCallbacks;
640 
642  ModuleAnalysisRegistrationCallbacks;
645  2>
646  ModulePipelineParsingCallbacks;
647  SmallVector<
649  TopLevelPipelineParsingCallbacks;
650  // CGSCC callbacks
652  CGSCCAnalysisRegistrationCallbacks;
655  2>
656  CGSCCPipelineParsingCallbacks;
657  // Function callbacks
659  FunctionAnalysisRegistrationCallbacks;
662  2>
663  FunctionPipelineParsingCallbacks;
664  // Loop callbacks
666  LoopAnalysisRegistrationCallbacks;
669  2>
670  LoopPipelineParsingCallbacks;
671  // AA callbacks
672  SmallVector<std::function<bool(StringRef Name, AAManager &AA)>, 2>
673  AAParsingCallbacks;
674 };
675 
676 /// This utility template takes care of adding require<> and invalidate<>
677 /// passes for an analysis to a given \c PassManager. It is intended to be used
678 /// during parsing of a pass pipeline when parsing a single PipelineName.
679 /// When registering a new function analysis FancyAnalysis with the pass
680 /// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look
681 /// like this:
682 ///
683 /// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
684 /// ArrayRef<PipelineElement> P) {
685 /// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name,
686 /// FPM))
687 /// return true;
688 /// return false;
689 /// }
690 template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
691  typename... ExtraArgTs>
693  StringRef AnalysisName, StringRef PipelineName,
695  if (!PipelineName.endswith(">"))
696  return false;
697  // See if this is an invalidate<> pass name
698  if (PipelineName.startswith("invalidate<")) {
699  PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
700  if (PipelineName != AnalysisName)
701  return false;
703  return true;
704  }
705 
706  // See if this is a require<> pass name
707  if (PipelineName.startswith("require<")) {
708  PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
709  if (PipelineName != AnalysisName)
710  return false;
711  PM.addPass(RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
712  ExtraArgTs...>());
713  return true;
714  }
715 
716  return false;
717 }
718 }
719 
720 #endif
llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >
Definition: LoopPassManager.h:69
Instrumentation.h
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:881
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Phase
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
Definition: AArch64FalkorHWPFFix.cpp:230
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:455
Inliner.h
llvm::PassManager::addPass
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same< PassT, PassManager >::value > addPass(PassT &&Pass)
Definition: PassManager.h:544
llvm::PassBuilder::getPassInstrumentationCallbacks
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Returns PIC.
Definition: PassBuilder.h:575
llvm::PassBuilder::registerOptimizerEarlyEPCallback
void registerOptimizerEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:473
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::PassBuilder::buildModuleOptimizationPipeline
ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase LTOPhase)
Construct the core LLVM module optimization pipeline.
Definition: PassBuilderPipelines.cpp:1226
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::StringRef::substr
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:564
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(CGSCCAnalysisManager &)> &C)
{{@ Register callbacks for analysis registration with this PassBuilder instance.
Definition: PassBuilder.h:515
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:482
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:423
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:767
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:1651
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:542
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:122
llvm::StringRef::startswith
bool startswith(StringRef Prefix) const
Definition: StringRef.h:260
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:507
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:97
llvm::PassBuilder::buildFunctionSimplificationPipeline
FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:468
llvm::PassBuilder::PipelineElement
A struct to capture parsed pass pipeline names.
Definition: PassBuilder.h:112
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
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:692
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:797
llvm::PassBuilder::buildThinLTOPreLinkDefaultPipeline
ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1440
llvm::PassBuilder::buildModuleInlinerPipeline
ModulePassManager buildModuleInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining with module inliner pass.
Definition: PassBuilderPipelines.cpp:879
llvm::PipelineTuningOptions::EagerlyInvalidateAnalyses
bool EagerlyInvalidateAnalyses
Definition: PassBuilder.h:88
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:464
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:552
llvm::PassBuilder::registerFunctionAnalyses
void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
Definition: PassBuilder.cpp:452
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:1555
llvm::PassBuilder::registerModuleAnalyses
void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
Definition: PassBuilder.cpp:434
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:445
CGSCCPassManager.h
llvm::PassBuilder::buildLTODefaultPipeline
ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1564
llvm::InvalidateAnalysisPass
A no-op pass template which simply forces a specific analysis result to be invalidated.
Definition: PassManager.h:1271
llvm::PassBuilder::buildThinLTODefaultPipeline
ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build an ThinLTO default optimization pipeline to a pass manager.
Definition: PassBuilderPipelines.cpp:1498
llvm::PassBuilder::buildDefaultAAPipeline
AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
Definition: PassBuilderPipelines.cpp:1966
llvm::PipelineTuningOptions::PipelineTuningOptions
PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
Definition: PassBuilderPipelines.cpp:286
llvm::PassBuilder::printPassNames
void printPassNames(raw_ostream &OS)
Print pass names.
Definition: PassBuilder.cpp:1786
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
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:413
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(FunctionAnalysisManager &)> &C)
Definition: PassBuilder.h:519
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
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:537
LoopPassManager.h
llvm::PassBuilder::PipelineElement::Name
StringRef Name
Definition: PassBuilder.h:113
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:403
llvm::PassBuilder::PassBuilder
PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr)
Definition: PassBuilder.cpp:397
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:50
llvm::PipelineTuningOptions::LoopVectorization
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition: PassBuilder.h:49
llvm::PassBuilder::registerPipelineParsingCallback
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &C)
Definition: PassBuilder.h:547
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:1758
llvm::PassManager< Function >
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
llvm::PassBuilder::registerLoopAnalyses
void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
Definition: PassBuilder.cpp:466
llvm::PassBuilder::registerFullLinkTimeOptimizationLastEPCallback
void registerFullLinkTimeOptimizationLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:500
llvm::PassBuilder::buildPerModuleDefaultPipeline
ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build a per-module default optimization pipeline.
Definition: PassBuilderPipelines.cpp:1397
llvm::PassBuilder::registerFullLinkTimeOptimizationEarlyEPCallback
void registerFullLinkTimeOptimizationEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
Definition: PassBuilder.h:491
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::StringRef::endswith
bool endswith(StringRef Suffix) const
Definition: StringRef.h:276
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:443
PGOOptions.h
llvm::OptimizationLevel
Definition: OptimizationLevel.h:22
PassManager.h
llvm::PassBuilder::registerAnalysisRegistrationCallback
void registerAnalysisRegistrationCallback(const std::function< void(LoopAnalysisManager &)> &C)
Definition: PassBuilder.h:523
llvm::PassBuilder::buildO0DefaultPipeline
ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, bool LTOPreLink=false)
Build an O0 pipeline with the minimal semantically required passes.
Definition: PassBuilderPipelines.cpp:1858
llvm::PipelineTuningOptions::InlinerThreshold
int InlinerThreshold
Tuning option to override the default inliner threshold.
Definition: PassBuilder.h:79
OptimizationLevel.h
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1199
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:1626
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:434
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
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:389
llvm::RequireAnalysisPass
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:1243
llvm::PassBuilder::buildModuleSimplificationPipeline
ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM module canonicalization and simplification pipeline.
Definition: PassBuilderPipelines.cpp:918
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:527
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:1854
MPM
ModulePassManager MPM
Definition: PassBuilderBindings.cpp:70
CGAM
CGSCCAnalysisManager CGAM
Definition: PassBuilderBindings.cpp:60
llvm::PassBuilder::PipelineElement::InnerPipeline
std::vector< PipelineElement > InnerPipeline
Definition: PassBuilder.h:114