LLVM 24.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
21#include "llvm/IR/PassManager.h"
24#include "llvm/Support/Error.h"
31#include <optional>
32#include <vector>
33
34namespace llvm {
35class StringRef;
36class AAManager;
37class TargetMachine;
39
40/// Tunable parameters for passes in the default pipelines.
42public:
43 /// Constructor sets pipeline tuning defaults based on cl::opts. Each option
44 /// can be set in the PassBuilder when using a LLVM as a library.
46
47 /// Tuning option to set loop interleaving on/off, set based on opt level.
49
50 /// Tuning option to enable/disable loop vectorization, set based on opt
51 /// level.
53
54 /// Tuning option to enable/disable slp loop vectorization, set based on opt
55 /// level.
57
58 /// Tuning option to enable/disable loop unrolling. Its default value is true.
60
61 /// Tuning option to enable/disable loop interchange. Its default value is
62 /// false.
64
65 /// Tuning option to enable/disable loop fusion. Its default value is false.
67
68 /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
69 /// is that of the flag: `-forget-scev-loop-unroll`.
71
72 /// Tuning option to cap the number of calls to retrive clobbering accesses in
73 /// MemorySSA, in LICM.
75
76 /// Tuning option to disable promotion to scalars in LICM with MemorySSA, if
77 /// the number of access is too large.
79
80 /// Tuning option to enable/disable call graph profile. Its default value is
81 /// that of the flag: `-enable-npm-call-graph-profile`.
83
84 // Add LTO pipeline tuning option to enable the unified LTO pipeline.
86
87 /// Tuning option to enable/disable function merging. Its default value is
88 /// false.
90
91 /// Tuning option to override the default inliner threshold.
93
94 // Experimental option to eagerly invalidate more analyses. This has the
95 // potential to decrease max memory usage in exchange for more compile time.
96 // This may affect codegen due to either passes using analyses only when
97 // cached, or invalidating and recalculating an analysis that was
98 // stale/imprecise but still valid. Currently this invalidates all function
99 // analyses after various module->function or cgscc->function adaptors in the
100 // default pipelines.
102
103 // Tuning option to enable/disable speculative devirtualization.
104 // Its default value is false.
106};
107
108/// This class provides access to building LLVM's passes.
109///
110/// Its members provide the baseline state available to passes during their
111/// construction. The \c PassRegistry.def file specifies how to construct all
112/// of the built-in passes, and those may reference these members during
113/// construction.
115 TargetMachine *TM;
117 std::optional<PGOOptions> PGOOpt;
120
121public:
122 /// A struct to capture parsed pass pipeline names.
123 ///
124 /// A pipeline is defined as a series of names, each of which may in itself
125 /// recursively contain a nested pipeline. A name is either the name of a pass
126 /// (e.g. "instcombine") or the name of a pipeline type (e.g. "cgscc"). If the
127 /// name is the name of a pass, the InnerPipeline is empty, since passes
128 /// cannot contain inner pipelines. See parsePassPipeline() for a more
129 /// detailed description of the textual pipeline format.
132 std::vector<PipelineElement> InnerPipeline;
133 };
134
135 LLVM_ABI explicit PassBuilder(
136 TargetMachine *TM = nullptr,
138 std::optional<PGOOptions> PGOOpt = std::nullopt,
139 PassInstrumentationCallbacks *PIC = nullptr,
141
142 /// Cross register the analysis managers through their proxies.
143 ///
144 /// This is an interface that can be used to cross register each
145 /// AnalysisManager with all the others analysis managers.
146 LLVM_ABI void
149 MachineFunctionAnalysisManager *MFAM = nullptr);
150
151 /// Registers all available module analysis passes.
152 ///
153 /// This is an interface that can be used to populate a \c
154 /// ModuleAnalysisManager with all registered module analyses. Callers can
155 /// still manually register any additional analyses. Callers can also
156 /// pre-register analyses and this will not override those.
158
159 /// Registers all available CGSCC analysis passes.
160 ///
161 /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
162 /// with all registered CGSCC analyses. Callers can still manually register any
163 /// additional analyses. Callers can also pre-register analyses and this will
164 /// not override those.
166
167 /// Registers all available function analysis passes.
168 ///
169 /// This is an interface that can be used to populate a \c
170 /// FunctionAnalysisManager with all registered function analyses. Callers can
171 /// still manually register any additional analyses. Callers can also
172 /// pre-register analyses and this will not override those.
174
175 /// Registers all available loop analysis passes.
176 ///
177 /// This is an interface that can be used to populate a \c LoopAnalysisManager
178 /// with all registered loop analyses. Callers can still manually register any
179 /// additional analyses.
181
182 /// Registers all available machine function analysis passes.
183 ///
184 /// This is an interface that can be used to populate a \c
185 /// MachineFunctionAnalysisManager with all registered function analyses.
186 /// Callers can still manually register any additional analyses. Callers can
187 /// also pre-register analyses and this will not override those.
188 LLVM_ABI void
190
191 /// Construct the core LLVM function canonicalization and simplification
192 /// pipeline.
193 ///
194 /// This is a long pipeline and uses most of the per-function optimization
195 /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
196 /// repeatedly over the IR and is not expected to destroy important
197 /// information about the semantics of the IR.
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.
203 ///
204 /// \p Phase indicates the current ThinLTO phase.
207
208 /// Construct the core LLVM module canonicalization and simplification
209 /// pipeline.
210 ///
211 /// This pipeline focuses on canonicalizing and simplifying the entire module
212 /// of IR. Much like the function simplification pipeline above, it is
213 /// suitable to run repeatedly over the IR and is not expected to destroy
214 /// important information. It does, however, perform inlining and other
215 /// heuristic based simplifications that are not strictly reversible.
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.
221 ///
222 /// \p Phase indicates the current ThinLTO phase.
225
226 /// Construct the module pipeline that performs inlining as well as
227 /// the inlining-driven cleanups.
230
231 /// Construct the module pipeline that performs inlining with
232 /// module inliner pass.
235
236 /// Construct the core LLVM module optimization pipeline.
237 ///
238 /// This pipeline focuses on optimizing the execution speed of the IR. It
239 /// uses cost modeling and thresholds to balance code growth against runtime
240 /// improvements. It includes vectorization and other information destroying
241 /// transformations. It also cannot generally be run repeatedly on a module
242 /// without potentially seriously regressing either runtime performance of
243 /// the code or serious code size growth.
244 ///
245 /// Note that \p Level cannot be `O0` here. The pipelines produced are
246 /// only intended for use when attempting to optimize code. If frontends
247 /// require some transformations for semantic reasons, they should explicitly
248 /// build them.
250 OptimizationLevel Level, ThinOrFullLTOPhase LTOPhase);
251
252 /// Build a per-module default optimization pipeline.
253 ///
254 /// This provides a good default optimization pipeline for per-module
255 /// optimization and code generation without any link-time optimization. It
256 /// typically correspond to frontend "-O[123]" options for optimization
257 /// levels \c O1, \c O2 and \c O3 resp.
259 OptimizationLevel Level,
261
262 /// Build a fat object default optimization pipeline.
263 ///
264 /// This builds a pipeline that runs the LTO/ThinLTO pre-link pipeline, and
265 /// emits a section containing the pre-link bitcode along side the object code
266 /// generated in non-LTO compilation.
268 bool ThinLTO,
269 bool EmitSummary,
270 bool Verify = true);
271
272 /// Build a pre-link, ThinLTO-targeting default optimization pipeline to
273 /// a pass manager.
274 ///
275 /// This adds the pre-link optimizations tuned to prepare a module for
276 /// a ThinLTO run. It works to minimize the IR which needs to be analyzed
277 /// without making irreversible decisions which could be made better during
278 /// the LTO run.
281
282 /// Build a ThinLTO 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 /// buildThinLTOPreLinkDefaultPipeline, and the two coordinate closely.
289 OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary);
290
291 /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
292 /// manager.
293 ///
294 /// This adds the pre-link optimizations tuned to work well with a later LTO
295 /// run. It works to minimize the IR which needs to be analyzed without
296 /// making irreversible decisions which could be made better during the LTO
297 /// run.
300
301 /// Build an LTO default optimization pipeline to a pass manager.
302 ///
303 /// This provides a good default optimization pipeline for link-time
304 /// optimization and code generation. It is particularly tuned to fit well
305 /// when IR coming into the LTO phase was first run through \c
306 /// buildLTOPreLinkDefaultPipeline, and the two coordinate closely.
308 OptimizationLevel Level, ModuleSummaryIndex *ExportSummary);
309
310 /// Build an O0 pipeline with the minimal semantically required passes.
311 ///
312 /// This should only be used for non-LTO and LTO pre-link pipelines.
316
317 /// Build the default `AAManager` with the default alias analysis pipeline
318 /// registered.
319 ///
320 /// This also adds target-specific alias analyses registered via
321 /// TargetMachine::registerDefaultAliasAnalyses().
323
324 /// Parse a textual pass pipeline description into a \c
325 /// ModulePassManager.
326 ///
327 /// The format of the textual pass pipeline description looks something like:
328 ///
329 /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
330 ///
331 /// Pass managers have ()s describing the nest structure of passes. All passes
332 /// are comma separated. As a special shortcut, if the very first pass is not
333 /// a module pass (as a module pass manager is), this will automatically form
334 /// the shortest stack of pass managers that allow inserting that first pass.
335 /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop
336 /// passes 'lpassN', all of these are valid:
337 ///
338 /// fpass1,fpass2,fpass3
339 /// cgpass1,cgpass2,cgpass3
340 /// lpass1,lpass2,lpass3
341 ///
342 /// And they are equivalent to the following (resp.):
343 ///
344 /// module(function(fpass1,fpass2,fpass3))
345 /// module(cgscc(cgpass1,cgpass2,cgpass3))
346 /// module(function(loop(lpass1,lpass2,lpass3)))
347 ///
348 /// This shortcut is especially useful for debugging and testing small pass
349 /// combinations.
350 ///
351 /// The sequence of passes aren't necessarily the exact same kind of pass.
352 /// You can mix different levels implicitly if adaptor passes are defined to
353 /// make them work. For example,
354 ///
355 /// mpass1,fpass1,fpass2,mpass2,lpass1
356 ///
357 /// This pipeline uses only one pass manager: the top-level module manager.
358 /// fpass1,fpass2 and lpass1 are added into the top-level module manager
359 /// using only adaptor passes. No nested function/loop pass managers are
360 /// added. The purpose is to allow easy pass testing when the user
361 /// specifically want the pass to run under a adaptor directly. This is
362 /// preferred when a pipeline is largely of one type, but one or just a few
363 /// passes are of different types(See PassBuilder.cpp for examples).
365 StringRef PipelineText);
366
367 /// {{@ Parse a textual pass pipeline description into a specific PassManager
368 ///
369 /// Automatic deduction of an appropriate pass manager stack is not supported.
370 /// For example, to insert a loop pass 'lpass' into a FunctionPassManager,
371 /// this is the valid pipeline text:
372 ///
373 /// function(lpass)
375 StringRef PipelineText);
377 StringRef PipelineText);
379 StringRef PipelineText);
380 /// @}}
381
382 /// Parse a textual MIR pipeline into the provided \c MachineFunctionPass
383 /// manager.
384 /// The format of the textual machine pipeline is a comma separated list of
385 /// machine pass names:
386 ///
387 /// machine-funciton-pass,machine-module-pass,...
388 ///
389 /// There is no need to specify the pass nesting, and this function
390 /// currently cannot handle the pass nesting.
392 StringRef PipelineText);
393
394 /// Parse a textual alias analysis pipeline into the provided AA manager.
395 ///
396 /// The format of the textual AA pipeline is a comma separated list of AA
397 /// pass names:
398 ///
399 /// basic-aa,globals-aa,...
400 ///
401 /// The AA manager is set up such that the provided alias analyses are tried
402 /// in the order specified. See the \c AAManaager documentation for details
403 /// about the logic used. This routine just provides the textual mapping
404 /// between AA names and the analyses to register with the manager.
405 ///
406 /// Returns false if the text cannot be parsed cleanly. The specific state of
407 /// the \p AA manager is unspecified if such an error is encountered and this
408 /// returns false.
410
411 /// Parse RegAllocFilterName to get RegAllocFilterFunc.
412 LLVM_ABI std::optional<RegAllocFilterFunc>
413 parseRegAllocFilter(StringRef RegAllocFilterName);
414
415 /// Print pass names.
417
418 /// Register a callback for a default optimizer pipeline extension
419 /// point
420 ///
421 /// This extension point allows adding passes that perform peephole
422 /// optimizations similar to the instruction combiner. These passes will be
423 /// inserted after each instance of the instruction combiner pass.
425 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
426 PeepholeEPCallbacks.push_back(C);
427 }
428
429 /// Register a callback for a default optimizer pipeline extension
430 /// point
431 ///
432 /// This extension point allows adding late loop canonicalization and
433 /// simplification passes. This is the last point in the loop optimization
434 /// pipeline before loop deletion. Each pass added
435 /// here must be an instance of LoopPass.
436 /// This is the place to add passes that can remove loops, such as target-
437 /// specific loop idiom recognition.
439 const std::function<void(LoopPassManager &, OptimizationLevel)> &C) {
440 LateLoopOptimizationsEPCallbacks.push_back(C);
441 }
442
443 /// Register a callback for a default optimizer pipeline extension
444 /// point
445 ///
446 /// This extension point allows adding loop passes to the end of the loop
447 /// optimizer.
449 const std::function<void(LoopPassManager &, OptimizationLevel)> &C) {
450 LoopOptimizerEndEPCallbacks.push_back(C);
451 }
452
453 /// Register a callback for a default optimizer pipeline extension
454 /// point
455 ///
456 /// This extension point allows adding optimization passes after most of the
457 /// main optimizations, but before the last cleanup-ish optimizations.
459 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
460 ScalarOptimizerLateEPCallbacks.push_back(C);
461 }
462
463 /// Register a callback for a default optimizer pipeline extension
464 /// point
465 ///
466 /// This extension point allows adding CallGraphSCC passes at the end of the
467 /// main CallGraphSCC passes and before any function simplification passes run
468 /// by CGPassManager.
470 const std::function<void(CGSCCPassManager &, OptimizationLevel)> &C) {
471 CGSCCOptimizerLateEPCallbacks.push_back(C);
472 }
473
474 /// Register a callback for a default optimizer pipeline extension
475 /// point
476 ///
477 /// This extension point allows adding optimization passes before the
478 /// vectorizer and other highly target specific optimization passes are
479 /// executed.
481 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
482 VectorizerStartEPCallbacks.push_back(C);
483 }
484
485 /// Register a callback for a default optimizer pipeline extension
486 /// point
487 ///
488 /// This extension point allows adding optimization passes after the
489 /// vectorizer and other highly target specific optimization passes are
490 /// executed.
492 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
493 VectorizerEndEPCallbacks.push_back(C);
494 }
495
496 /// Register a callback for a default optimizer pipeline extension point.
497 ///
498 /// This extension point allows adding optimization once at the start of the
499 /// pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO
500 /// link-time pipelines).
502 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
503 PipelineStartEPCallbacks.push_back(C);
504 }
505
506 /// Register a callback for a default optimizer pipeline extension point.
507 ///
508 /// This extension point allows adding optimization right after passes that do
509 /// basic simplification of the input IR.
511 const std::function<void(ModulePassManager &, OptimizationLevel,
513 PipelineEarlySimplificationEPCallbacks.push_back(C);
514 }
515
516 /// Register a callback for a default optimizer pipeline extension point
517 ///
518 /// This extension point allows adding optimizations before the function
519 /// optimization pipeline.
521 const std::function<void(ModulePassManager &, OptimizationLevel,
523 OptimizerEarlyEPCallbacks.push_back(C);
524 }
525
526 /// Register a callback for a default optimizer pipeline extension point
527 ///
528 /// This extension point allows adding optimizations at the very end of the
529 /// function optimization pipeline.
531 const std::function<void(ModulePassManager &, OptimizationLevel,
533 OptimizerLastEPCallbacks.push_back(C);
534 }
535
536 /// Register a callback for a default optimizer pipeline extension point
537 ///
538 /// This extension point allows adding optimizations at the start of the full
539 /// LTO pipeline.
541 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
542 FullLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
543 }
544
545 /// Register a callback for a default optimizer pipeline extension point
546 ///
547 /// This extension point allows adding optimizations at the end of the full
548 /// LTO pipeline.
550 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
551 FullLinkTimeOptimizationLastEPCallbacks.push_back(C);
552 }
553
554 /// Register a callback for ThinLTO default optimizer pipeline extension point
555 ///
556 /// This extension point allows adding optimizations at the start of the
557 /// thin LTO pipeline.
559 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
560 ThinLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
561 }
562
563 /// Register a callback for ThinLTO default optimizer pipeline extension point
564 ///
565 /// This extension point allows adding optimizations at the end of the thin
566 /// LTO pipeline.
568 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
569 ThinLinkTimeOptimizationLastEPCallbacks.push_back(C);
570 }
571
572 /// Register a callback for parsing an AliasAnalysis Name to populate
573 /// the given AAManager \p AA
575 const std::function<bool(StringRef Name, AAManager &AA)> &C) {
576 AAParsingCallbacks.push_back(C);
577 }
578
579 /// {{@ Register callbacks for analysis registration with this PassBuilder
580 /// instance.
581 /// Callees register their analyses with the given AnalysisManager objects.
583 const std::function<void(CGSCCAnalysisManager &)> &C) {
584 CGSCCAnalysisRegistrationCallbacks.push_back(C);
585 }
587 const std::function<void(FunctionAnalysisManager &)> &C) {
588 FunctionAnalysisRegistrationCallbacks.push_back(C);
589 }
591 const std::function<void(LoopAnalysisManager &)> &C) {
592 LoopAnalysisRegistrationCallbacks.push_back(C);
593 }
595 const std::function<void(ModuleAnalysisManager &)> &C) {
596 ModuleAnalysisRegistrationCallbacks.push_back(C);
597 }
599 const std::function<void(MachineFunctionAnalysisManager &)> &C) {
600 MachineFunctionAnalysisRegistrationCallbacks.push_back(C);
601 }
602 /// @}}
603
604 /// {{@ Register pipeline parsing callbacks with this pass builder instance.
605 /// Using these callbacks, callers can parse both a single pass name, as well
606 /// as entire sub-pipelines, and populate the PassManager instance
607 /// accordingly.
609 const std::function<bool(StringRef Name, CGSCCPassManager &,
611 CGSCCPipelineParsingCallbacks.push_back(C);
612 }
614 const std::function<bool(StringRef Name, FunctionPassManager &,
616 FunctionPipelineParsingCallbacks.push_back(C);
617 }
619 const std::function<bool(StringRef Name, LoopPassManager &,
621 LoopPipelineParsingCallbacks.push_back(C);
622 }
624 const std::function<bool(StringRef Name, ModulePassManager &,
626 ModulePipelineParsingCallbacks.push_back(C);
627 }
629 const std::function<bool(StringRef Name, MachineFunctionPassManager &,
631 MachineFunctionPipelineParsingCallbacks.push_back(C);
632 }
633 /// @}}
634
635 /// Register callbacks to parse target specific filter field if regalloc pass
636 /// needs it. E.g. AMDGPU requires regalloc passes can handle sgpr and vgpr
637 /// separately.
639 const std::function<RegAllocFilterFunc(StringRef)> &C) {
640 RegClassFilterParsingCallbacks.push_back(C);
641 }
642
643 /// Register a callback for a top-level pipeline entry.
644 ///
645 /// If the PassManager type is not given at the top level of the pipeline
646 /// text, this Callback should be used to determine the appropriate stack of
647 /// PassManagers and populate the passed ModulePassManager.
649 const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>
650 &C);
651
652 /// Add PGOInstrumenation passes for O0 only.
654 bool RunProfileGen, bool IsCS,
655 bool AtomicCounterUpdate,
656 std::string ProfileFile,
657 std::string ProfileRemappingFile);
658
659 /// Returns PIC. External libraries can use this to register pass
660 /// instrumentation callbacks.
664
665 /// Returns the virtual file system.
669
670 // Invoke the callbacks registered for the various extension points.
671 // Custom pipelines should use these to invoke the callbacks registered
672 // by TargetMachines and other clients.
674 OptimizationLevel Level);
676 OptimizationLevel Level);
678 OptimizationLevel Level);
680 OptimizationLevel Level);
682 OptimizationLevel Level);
684 OptimizationLevel Level);
686 OptimizationLevel Level);
688 OptimizationLevel Level,
691 OptimizationLevel Level,
693 LLVM_ABI void
695 OptimizationLevel Level);
696 LLVM_ABI void
698 OptimizationLevel Level);
699 LLVM_ABI void
701 OptimizationLevel Level);
702 LLVM_ABI void
704 OptimizationLevel Level);
706 OptimizationLevel Level);
707 LLVM_ABI void
709 OptimizationLevel Level,
711
713 if (!Name.consume_front(PassName))
714 return false;
715 // normal pass name w/o parameters == default parameters
716 if (Name.empty())
717 return true;
718 return Name.starts_with("<") && Name.ends_with(">");
719 }
720
721 /// This performs customized parsing of pass name with parameters.
722 ///
723 /// We do not need parametrization of passes in textual pipeline very often,
724 /// yet on a rare occasion ability to specify parameters right there can be
725 /// useful.
726 ///
727 /// \p Name - parameterized specification of a pass from a textual pipeline
728 /// is a string in a form of :
729 /// PassName '<' parameter-list '>'
730 ///
731 /// Parameter list is being parsed by the parser callable argument, \p Parser,
732 /// It takes a string-ref of parameters and returns either StringError or a
733 /// parameter list in a form of a custom parameters type, all wrapped into
734 /// Expected<> template class.
735 ///
736 template <typename ParametersParseCallableT>
737 static auto parsePassParameters(ParametersParseCallableT &&Parser,
739 -> decltype(Parser(StringRef{})) {
740 using ParametersT = typename decltype(Parser(StringRef{}))::value_type;
741
742 StringRef Params = Name;
743 if (!Params.consume_front(PassName)) {
745 "unable to strip pass name from parametrized pass specification");
746 }
747 if (!Params.empty() &&
748 (!Params.consume_front("<") || !Params.consume_back(">"))) {
749 llvm_unreachable("invalid format for parametrized pass name");
750 }
751
752 Expected<ParametersT> Result = Parser(Params);
753 assert((Result || Result.template errorIsA<StringError>()) &&
754 "Pass parameter parser can only return StringErrors.");
755 return Result;
756 }
757
758 /// Handle passes only accept one bool-valued parameter.
759 ///
760 /// \return false when Params is empty.
761 LLVM_ABI static Expected<bool> parseSinglePassOption(StringRef Params,
762 StringRef OptionName,
763 StringRef PassName);
764
765private:
766 // O1 pass pipeline
768 buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
770
771 void addRequiredLTOPreLinkPasses(ModulePassManager &MPM);
772
773 void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
774 ThinOrFullLTOPhase LTOPhase);
775
776 static std::optional<std::vector<PipelineElement>>
777 parsePipelineText(StringRef Text);
778
779 Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
780 Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
781 Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
782 Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
783 Error parseMachinePass(MachineFunctionPassManager &MFPM,
784 const PipelineElement &E);
785 bool parseAAPassName(AAManager &AA, StringRef Name);
786
787 Error parseMachinePassPipeline(MachineFunctionPassManager &MFPM,
789 Error parseLoopPassPipeline(LoopPassManager &LPM,
791 Error parseFunctionPassPipeline(FunctionPassManager &FPM,
793 Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
795 Error parseModulePassPipeline(ModulePassManager &MPM,
797
798 // Adds passes to do pre-inlining and related cleanup passes before
799 // profile instrumentation/matching (to enable better context sensitivity),
800 // and for memprof to enable better matching with missing debug frames.
801 void addPreInlinerPasses(ModulePassManager &MPM, OptimizationLevel Level,
802 ThinOrFullLTOPhase LTOPhase);
803
804 void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
805 bool RunProfileGen, bool IsCS,
806 bool AtomicCounterUpdate, std::string ProfileFile,
807 std::string ProfileRemappingFile);
808 void addPostPGOLoopRotation(ModulePassManager &MPM, OptimizationLevel Level);
809
810 bool isInstrumentedPGOUse() const;
811
812 // Extension Point callbacks
813 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
814 PeepholeEPCallbacks;
815 SmallVector<std::function<void(LoopPassManager &, OptimizationLevel)>, 2>
816 LateLoopOptimizationsEPCallbacks;
817 SmallVector<std::function<void(LoopPassManager &, OptimizationLevel)>, 2>
818 LoopOptimizerEndEPCallbacks;
819 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
820 ScalarOptimizerLateEPCallbacks;
821 SmallVector<std::function<void(CGSCCPassManager &, OptimizationLevel)>, 2>
822 CGSCCOptimizerLateEPCallbacks;
823 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
824 VectorizerStartEPCallbacks;
825 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
826 VectorizerEndEPCallbacks;
827 // Module callbacks
828 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
830 2>
831 OptimizerEarlyEPCallbacks;
832 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
834 2>
835 OptimizerLastEPCallbacks;
836 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
837 FullLinkTimeOptimizationEarlyEPCallbacks;
838 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
839 FullLinkTimeOptimizationLastEPCallbacks;
840 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
841 ThinLinkTimeOptimizationEarlyEPCallbacks;
842 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
843 ThinLinkTimeOptimizationLastEPCallbacks;
844 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
845 PipelineStartEPCallbacks;
846 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
848 2>
849 PipelineEarlySimplificationEPCallbacks;
850
851 SmallVector<std::function<void(ModuleAnalysisManager &)>, 2>
852 ModuleAnalysisRegistrationCallbacks;
853 SmallVector<std::function<bool(StringRef, ModulePassManager &,
855 2>
856 ModulePipelineParsingCallbacks;
858 std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>, 2>
859 TopLevelPipelineParsingCallbacks;
860 // CGSCC callbacks
861 SmallVector<std::function<void(CGSCCAnalysisManager &)>, 2>
862 CGSCCAnalysisRegistrationCallbacks;
863 SmallVector<std::function<bool(StringRef, CGSCCPassManager &,
865 2>
866 CGSCCPipelineParsingCallbacks;
867 // Function callbacks
868 SmallVector<std::function<void(FunctionAnalysisManager &)>, 2>
869 FunctionAnalysisRegistrationCallbacks;
870 SmallVector<std::function<bool(StringRef, FunctionPassManager &,
872 2>
873 FunctionPipelineParsingCallbacks;
874 // Loop callbacks
875 SmallVector<std::function<void(LoopAnalysisManager &)>, 2>
876 LoopAnalysisRegistrationCallbacks;
877 SmallVector<std::function<bool(StringRef, LoopPassManager &,
879 2>
880 LoopPipelineParsingCallbacks;
881 // AA callbacks
882 SmallVector<std::function<bool(StringRef Name, AAManager &AA)>, 2>
883 AAParsingCallbacks;
884 // Machine pass callbackcs
885 SmallVector<std::function<void(MachineFunctionAnalysisManager &)>, 2>
886 MachineFunctionAnalysisRegistrationCallbacks;
887 SmallVector<std::function<bool(StringRef, MachineFunctionPassManager &,
889 2>
890 MachineFunctionPipelineParsingCallbacks;
891 // Callbacks to parse `filter` parameter in register allocation passes
892 SmallVector<std::function<RegAllocFilterFunc(StringRef)>, 2>
893 RegClassFilterParsingCallbacks;
894};
895
896/// This utility template takes care of adding require<> and invalidate<>
897/// passes for an analysis to a given \c PassManager. It is intended to be used
898/// during parsing of a pass pipeline when parsing a single PipelineName.
899/// When registering a new function analysis FancyAnalysis with the pass
900/// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look
901/// like this:
902///
903/// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
904/// ArrayRef<PipelineElement> P) {
905/// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name,
906/// FPM))
907/// return true;
908/// return false;
909/// }
910template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
911 typename... ExtraArgTs>
913 StringRef AnalysisName, StringRef PipelineName,
915 if (!PipelineName.ends_with(">"))
916 return false;
917 // See if this is an invalidate<> pass name
918 if (PipelineName.starts_with("invalidate<")) {
919 PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
920 if (PipelineName != AnalysisName)
921 return false;
923 return true;
924 }
925
926 // See if this is a require<> pass name
927 if (PipelineName.starts_with("require<")) {
928 PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
929 if (PipelineName != AnalysisName)
930 return false;
931 PM.addPass(RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
932 ExtraArgTs...>());
933 return true;
934 }
935
936 return false;
937}
938
939// These are special since they are only for testing purposes.
940
941/// No-op module pass which does nothing.
947
948/// No-op module analysis.
949class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
951 LLVM_ABI static AnalysisKey Key;
952
953public:
954 struct Result {};
956};
957
958/// No-op CGSCC pass which does nothing.
965
966/// No-op CGSCC analysis.
967class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
969 LLVM_ABI static AnalysisKey Key;
970
971public:
972 struct Result {};
976};
977
978/// No-op function pass which does nothing.
984
985/// No-op function analysis.
986class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
988 LLVM_ABI static AnalysisKey Key;
989
990public:
991 struct Result {};
993};
994
995/// No-op loop nest pass which does nothing.
1002
1003/// No-op loop pass which does nothing.
1010
1011/// No-op machine function pass which does nothing.
1018
1019/// No-op loop analysis.
1020class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
1022 LLVM_ABI static AnalysisKey Key;
1023
1024public:
1025 struct Result {};
1029};
1030
1035
1037 : public cl::parser<std::optional<PrintPipelinePassesFormat>> {
1038 using cl::parser<std::optional<PrintPipelinePassesFormat>>::parser;
1039 LLVM_ABI bool parse(cl::Option &O, StringRef ArgName, StringRef ArgValue,
1040 std::optional<PrintPipelinePassesFormat> &Val);
1041};
1042
1043/// Common option used by multiple tools to print pipeline passes
1047
1049 raw_ostream &OS, StringRef Pipeline,
1051}
1052
1053#endif
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This header provides classes for managing passes over SCCs of the call graph.
#define LLVM_ABI
Definition Compiler.h:215
This header defines various interfaces for pass management in LLVM.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
This header enumerates the LLVM-provided high-level optimization levels.
Define option tunables for PGO.
ppc ctr loops PowerPC CTR Loops Verify
CGSCCAnalysisManager CGAM
LoopAnalysisManager LAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
Defines the virtual file system interface vfs::FileSystem.
static const char PassName[]
A manager for alias analyses.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
This class represents a loop nest and can be used to query its properties.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Module pass, wrapping the inliner pass.
Definition Inliner.h:65
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
No-op CGSCC analysis.
Result run(LazyCallGraph::SCC &, CGSCCAnalysisManager &, LazyCallGraph &G)
No-op function analysis.
Result run(Function &, FunctionAnalysisManager &)
No-op loop analysis.
Result run(Loop &, LoopAnalysisManager &, LoopStandardAnalysisResults &)
No-op module analysis.
Result run(Module &, ModuleAnalysisManager &)
LLVM_ABI void invokeFullLinkTimeOptimizationLastEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
LLVM_ABI ModuleInlinerWrapperPass buildInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining as well as the inlining-driven cleanups.
void registerAnalysisRegistrationCallback(const std::function< void(MachineFunctionAnalysisManager &)> &C)
LLVM_ABI void printPassNames(raw_ostream &OS)
Print pass names.
static bool checkParametrizedPassName(StringRef Name, StringRef PassName)
LLVM_ABI void invokeOptimizerEarlyEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase Phase)
LLVM_ABI ModulePassManager buildFatLTODefaultPipeline(OptimizationLevel Level, bool ThinLTO, bool EmitSummary, bool Verify=true)
Build a fat object default optimization pipeline.
LLVM_ABI void invokeVectorizerStartEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, ModulePassManager &, ArrayRef< PipelineElement >)> &C)
LLVM_ABI AAManager buildDefaultAAPipeline()
Build the default AAManager with the default alias analysis pipeline registered.
LLVM_ABI Error parseAAPipeline(AAManager &AA, StringRef PipelineText)
Parse a textual alias analysis pipeline into the provided AA manager.
void registerThinLinkTimeOptimizationEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for ThinLTO default optimizer pipeline extension point.
LLVM_ABI void invokeCGSCCOptimizerLateEPCallbacks(CGSCCPassManager &CGPM, OptimizationLevel Level)
void registerPipelineEarlySimplificationEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel, ThinOrFullLTOPhase)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI ModulePassManager buildThinLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, ThinLTO-targeting default optimization pipeline to a pass manager.
void registerAnalysisRegistrationCallback(const std::function< void(ModuleAnalysisManager &)> &C)
LLVM_ABI void addPGOInstrPassesForO0(ModulePassManager &MPM, bool RunProfileGen, bool IsCS, bool AtomicCounterUpdate, std::string ProfileFile, std::string ProfileRemappingFile)
Add PGOInstrumenation passes for O0 only.
void registerPipelineStartEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void invokeScalarOptimizerLateEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, LoopPassManager &, ArrayRef< PipelineElement >)> &C)
LLVM_ABI void registerLoopAnalyses(LoopAnalysisManager &LAM)
Registers all available loop analysis passes.
LLVM_ABI std::optional< RegAllocFilterFunc > parseRegAllocFilter(StringRef RegAllocFilterName)
Parse RegAllocFilterName to get RegAllocFilterFunc.
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
Returns PIC.
void registerLateLoopOptimizationsEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void crossRegisterProxies(LoopAnalysisManager &LAM, FunctionAnalysisManager &FAM, CGSCCAnalysisManager &CGAM, ModuleAnalysisManager &MAM, MachineFunctionAnalysisManager *MFAM=nullptr)
Cross register the analysis managers through their proxies.
void registerLoopOptimizerEndEPCallback(const std::function< void(LoopPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerOptimizerLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel, ThinOrFullLTOPhase)> &C)
Register a callback for a default optimizer pipeline extension point.
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.
void registerVectorizerStartEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerAnalysisRegistrationCallback(const std::function< void(LoopAnalysisManager &)> &C)
LLVM_ABI ModulePassManager buildPerModuleDefaultPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase=ThinOrFullLTOPhase::None)
Build a per-module default optimization pipeline.
void registerPeepholeEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI PassBuilder(TargetMachine *TM=nullptr, PipelineTuningOptions PTO=PipelineTuningOptions(), std::optional< PGOOptions > PGOOpt=std::nullopt, PassInstrumentationCallbacks *PIC=nullptr, IntrusiveRefCntPtr< vfs::FileSystem > FS=vfs::getRealFileSystem())
void registerAnalysisRegistrationCallback(const std::function< void(FunctionAnalysisManager &)> &C)
void registerScalarOptimizerLateEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
void registerAnalysisRegistrationCallback(const std::function< void(CGSCCAnalysisManager &)> &C)
{{@ Register callbacks for analysis registration with this PassBuilder instance.
LLVM_ABI void invokePipelineStartEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
LLVM_ABI void invokeVectorizerEndEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
LLVM_ABI void invokeThinLinkTimeOptimizationLastEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
IntrusiveRefCntPtr< vfs::FileSystem > getVirtualFileSystemPtr() const
Returns the virtual file system.
LLVM_ABI ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase=ThinOrFullLTOPhase::None)
Build an O0 pipeline with the minimal semantically required passes.
LLVM_ABI FunctionPassManager buildFunctionSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM function canonicalization and simplification pipeline.
void registerCGSCCOptimizerLateEPCallback(const std::function< void(CGSCCPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void invokePeepholeEPCallbacks(FunctionPassManager &FPM, OptimizationLevel Level)
LLVM_ABI void invokePipelineEarlySimplificationEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase Phase)
LLVM_ABI Error parsePassPipeline(ModulePassManager &MPM, StringRef PipelineText)
Parse a textual pass pipeline description into a ModulePassManager.
void registerThinLinkTimeOptimizationLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for ThinLTO default optimizer pipeline extension point.
LLVM_ABI void invokeLoopOptimizerEndEPCallbacks(LoopPassManager &LPM, OptimizationLevel Level)
void registerRegClassFilterParsingCallback(const std::function< RegAllocFilterFunc(StringRef)> &C)
Register callbacks to parse target specific filter field if regalloc pass needs it.
LLVM_ABI ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary)
Build an LTO default optimization pipeline to a pass manager.
LLVM_ABI ModulePassManager buildModuleInlinerPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the module pipeline that performs inlining with module inliner pass.
LLVM_ABI ModulePassManager buildThinLTODefaultPipeline(OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary)
Build a ThinLTO default optimization pipeline to a pass manager.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, CGSCCPassManager &, ArrayRef< PipelineElement >)> &C)
{{@ Register pipeline parsing callbacks with this pass builder instance.
void registerFullLinkTimeOptimizationEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void invokeLateLoopOptimizationsEPCallbacks(LoopPassManager &LPM, OptimizationLevel Level)
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, FunctionPassManager &, ArrayRef< PipelineElement >)> &C)
LLVM_ABI void registerModuleAnalyses(ModuleAnalysisManager &MAM)
Registers all available module analysis passes.
void registerFullLinkTimeOptimizationLastEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM)
Registers all available CGSCC analysis passes.
LLVM_ABI void invokeFullLinkTimeOptimizationEarlyEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
static auto parsePassParameters(ParametersParseCallableT &&Parser, StringRef Name, StringRef PassName) -> decltype(Parser(StringRef{}))
This performs customized parsing of pass name with parameters.
LLVM_ABI ModulePassManager buildModuleSimplificationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase Phase)
Construct the core LLVM module canonicalization and simplification pipeline.
void registerPipelineParsingCallback(const std::function< bool(StringRef Name, MachineFunctionPassManager &, ArrayRef< PipelineElement >)> &C)
static LLVM_ABI Expected< bool > parseSinglePassOption(StringRef Params, StringRef OptionName, StringRef PassName)
Handle passes only accept one bool-valued parameter.
void registerOptimizerEarlyEPCallback(const std::function< void(ModulePassManager &, OptimizationLevel, ThinOrFullLTOPhase Phase)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &MFAM)
Registers all available machine function analysis passes.
LLVM_ABI ModulePassManager buildModuleOptimizationPipeline(OptimizationLevel Level, ThinOrFullLTOPhase LTOPhase)
Construct the core LLVM module optimization pipeline.
LLVM_ABI void registerParseTopLevelPipelineCallback(const std::function< bool(ModulePassManager &, ArrayRef< PipelineElement >)> &C)
Register a callback for a top-level pipeline entry.
LLVM_ABI void invokeThinLinkTimeOptimizationEarlyEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level)
LLVM_ABI void invokeOptimizerLastEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level, ThinOrFullLTOPhase Phase)
void registerVectorizerEndEPCallback(const std::function< void(FunctionPassManager &, OptimizationLevel)> &C)
Register a callback for a default optimizer pipeline extension point.
LLVM_ABI ModulePassManager buildLTOPreLinkDefaultPipeline(OptimizationLevel Level)
Build a pre-link, LTO-targeting default optimization pipeline to a pass manager.
LLVM_ABI void registerFunctionAnalyses(FunctionAnalysisManager &FAM)
Registers all available function analysis passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Manages a sequence of passes over a particular unit of IR.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Tunable parameters for passes in the default pipelines.
Definition PassBuilder.h:41
unsigned LicmMssaNoAccForPromotionCap
Tuning option to disable promotion to scalars in LICM with MemorySSA, if the number of access is too ...
Definition PassBuilder.h:78
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition PassBuilder.h:56
int InlinerThreshold
Tuning option to override the default inliner threshold.
Definition PassBuilder.h:92
bool LoopFusion
Tuning option to enable/disable loop fusion. Its default value is false.
Definition PassBuilder.h:66
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
Definition PassBuilder.h:82
bool MergeFunctions
Tuning option to enable/disable function merging.
Definition PassBuilder.h:89
bool ForgetAllSCEVInLoopUnroll
Tuning option to forget all SCEV loops in LoopUnroll.
Definition PassBuilder.h:70
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
Definition PassBuilder.h:74
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
Definition PassBuilder.h:48
LLVM_ABI PipelineTuningOptions()
Constructor sets pipeline tuning defaults based on cl::opts.
bool LoopUnrolling
Tuning option to enable/disable loop unrolling. Its default value is true.
Definition PassBuilder.h:59
bool LoopInterchange
Tuning option to enable/disable loop interchange.
Definition PassBuilder.h:63
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition PassBuilder.h:52
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition StringRef.h:597
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr size_t size() const
Get the string size.
Definition StringRef.h:144
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Definition StringRef.h:270
Primary interface to the complete machine description for the target machine.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
Definition Attributor.h:165
LLVM_ABI IntrusiveRefCntPtr< FileSystem > getRealFileSystem()
Gets an vfs::FileSystem for the 'real' file system, as seen by the operating system.
This is an optimization pass for GlobalISel generic memory operations.
std::function< bool(const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, const Register Reg)> RegAllocFilterFunc
Filter function for register classes during regalloc.
LLVM_ABI cl::opt< std::optional< PrintPipelinePassesFormat >, false, PrintPipelinePassesFormatParser > PrintPipelinePasses
Common option used by multiple tools to print pipeline passes.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > CGSCCPassManager
The CGSCC pass manager.
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
Definition Pass.h:77
@ None
No LTO/ThinLTO behavior needed.
Definition Pass.h:79
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI void printFormattedPipelinePasses(raw_ostream &OS, StringRef Pipeline, PrintPipelinePassesFormat Format=PrintPipelinePassesFormat::Text)
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
PrintPipelinePassesFormat
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
A no-op pass template which simply forces a specific analysis result to be invalidated.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
No-op CGSCC pass which does nothing.
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &, LazyCallGraph &, CGSCCUpdateResult &UR)
No-op function pass which does nothing.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
No-op loop nest pass which does nothing.
PreservedAnalyses run(LoopNest &L, LoopAnalysisManager &, LoopStandardAnalysisResults &, LPMUpdater &)
No-op loop pass which does nothing.
PreservedAnalyses run(Loop &L, LoopAnalysisManager &, LoopStandardAnalysisResults &, LPMUpdater &)
No-op machine function pass which does nothing.
PreservedAnalyses run(MachineFunction &, MachineFunctionAnalysisManager &)
No-op module pass which does nothing.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
A CRTP mix-in for passes that can be skipped.
A struct to capture parsed pass pipeline names.
std::vector< PipelineElement > InnerPipeline
LLVM_ABI bool parse(cl::Option &O, StringRef ArgName, StringRef ArgValue, std::optional< PrintPipelinePassesFormat > &Val)
A utility pass template to force an analysis result to be available.