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;
39struct PassesOptions;
40
41/// Tunable parameters for passes in the default pipelines.
43public:
44 /// Constructor sets pipeline tuning defaults based on cl::opts. Each option
45 /// can be set in the PassBuilder when using a LLVM as a library.
47
48 /// Tuning option to set loop interleaving on/off, set based on opt level.
50
51 /// Tuning option to enable/disable loop vectorization, set based on opt
52 /// level.
54
55 /// Tuning option to enable/disable slp loop vectorization, set based on opt
56 /// level.
58
59 /// Tuning option to enable/disable loop unrolling. Its default value is true.
61
62 /// Tuning option to enable/disable loop interchange. Its default value is
63 /// false.
65
66 /// Tuning option to enable/disable loop fusion. Its default value is false.
68
69 /// Tuning option to forget all SCEV loops in LoopUnroll. Its default value
70 /// is that of the flag: `-forget-scev-loop-unroll`.
72
73 /// Tuning option to cap the number of calls to retrive clobbering accesses in
74 /// MemorySSA, in LICM.
76
77 /// Tuning option to disable promotion to scalars in LICM with MemorySSA, if
78 /// the number of access is too large.
80
81 /// Tuning option to enable/disable call graph profile. Its default value is
82 /// that of the flag: `-enable-npm-call-graph-profile`.
84
85 // Add LTO pipeline tuning option to enable the unified LTO pipeline.
87
88 /// Tuning option to enable/disable function merging. Its default value is
89 /// false.
91
92 /// Tuning option to override the default inliner threshold.
94
95 // Experimental option to eagerly invalidate more analyses. This has the
96 // potential to decrease max memory usage in exchange for more compile time.
97 // This may affect codegen due to either passes using analyses only when
98 // cached, or invalidating and recalculating an analysis that was
99 // stale/imprecise but still valid. Currently this invalidates all function
100 // analyses after various module->function or cgscc->function adaptors in the
101 // default pipelines.
103
104 // Tuning option to enable/disable speculative devirtualization.
105 // Its default value is false.
107};
108
113
114/// This class provides access to building LLVM's passes.
115///
116/// Its members provide the baseline state available to passes during their
117/// construction. The \c PassRegistry.def file specifies how to construct all
118/// of the built-in passes, and those may reference these members during
119/// construction.
121 const PassesOptions &Opts;
122 TargetMachine *TM;
124 std::optional<PGOOptions> PGOOpt;
127
128public:
129 /// A struct to capture parsed pass pipeline names.
130 ///
131 /// A pipeline is defined as a series of names, each of which may in itself
132 /// recursively contain a nested pipeline. A name is either the name of a pass
133 /// (e.g. "instcombine") or the name of a pipeline type (e.g. "cgscc"). If the
134 /// name is the name of a pass, the InnerPipeline is empty, since passes
135 /// cannot contain inner pipelines. See parsePassPipeline() for a more
136 /// detailed description of the textual pipeline format.
139 std::vector<PipelineElement> InnerPipeline;
140 };
141
142 LLVM_ABI explicit PassBuilder(
143 TargetMachine *TM = nullptr,
145 std::optional<PGOOptions> PGOOpt = std::nullopt,
146 PassInstrumentationCallbacks *PIC = nullptr,
148
149 /// Cross register the analysis managers through their proxies.
150 ///
151 /// This is an interface that can be used to cross register each
152 /// AnalysisManager with all the others analysis managers.
153 LLVM_ABI void
156 MachineFunctionAnalysisManager *MFAM = nullptr);
157
158 /// Registers all available module analysis passes.
159 ///
160 /// This is an interface that can be used to populate a \c
161 /// ModuleAnalysisManager with all registered module analyses. Callers can
162 /// still manually register any additional analyses. Callers can also
163 /// pre-register analyses and this will not override those.
165
166 /// Registers all available CGSCC analysis passes.
167 ///
168 /// This is an interface that can be used to populate a \c CGSCCAnalysisManager
169 /// with all registered CGSCC analyses. Callers can still manually register any
170 /// additional analyses. Callers can also pre-register analyses and this will
171 /// not override those.
173
174 /// Registers all available function analysis passes.
175 ///
176 /// This is an interface that can be used to populate a \c
177 /// FunctionAnalysisManager with all registered function analyses. Callers can
178 /// still manually register any additional analyses. Callers can also
179 /// pre-register analyses and this will not override those.
181
182 /// Registers all available loop analysis passes.
183 ///
184 /// This is an interface that can be used to populate a \c LoopAnalysisManager
185 /// with all registered loop analyses. Callers can still manually register any
186 /// additional analyses.
188
189 /// Registers all available machine function analysis passes.
190 ///
191 /// This is an interface that can be used to populate a \c
192 /// MachineFunctionAnalysisManager with all registered function analyses.
193 /// Callers can still manually register any additional analyses. Callers can
194 /// also pre-register analyses and this will not override those.
195 LLVM_ABI void
197
198 /// Construct the core LLVM function canonicalization and simplification
199 /// pipeline.
200 ///
201 /// This is a long pipeline and uses most of the per-function optimization
202 /// passes in LLVM to canonicalize and simplify the IR. It is suitable to run
203 /// repeatedly over the IR and is not expected to destroy important
204 /// information about the semantics of the IR.
205 ///
206 /// Note that \p Level cannot be `O0` here. The pipelines produced are
207 /// only intended for use when attempting to optimize code. If frontends
208 /// require some transformations for semantic reasons, they should explicitly
209 /// build them.
210 ///
211 /// \p Phase indicates the current ThinLTO phase.
214
215 /// Construct the core LLVM module canonicalization and simplification
216 /// pipeline.
217 ///
218 /// This pipeline focuses on canonicalizing and simplifying the entire module
219 /// of IR. Much like the function simplification pipeline above, it is
220 /// suitable to run repeatedly over the IR and is not expected to destroy
221 /// important information. It does, however, perform inlining and other
222 /// heuristic based simplifications that are not strictly reversible.
223 ///
224 /// Note that \p Level cannot be `O0` here. The pipelines produced are
225 /// only intended for use when attempting to optimize code. If frontends
226 /// require some transformations for semantic reasons, they should explicitly
227 /// build them.
228 ///
229 /// \p Phase indicates the current ThinLTO phase.
232
233 /// Construct the module pipeline that performs inlining as well as
234 /// the inlining-driven cleanups.
237
238 /// Construct the module pipeline that performs inlining with
239 /// module inliner pass.
242
243 /// Construct the core LLVM module optimization pipeline.
244 ///
245 /// This pipeline focuses on optimizing the execution speed of the IR. It
246 /// uses cost modeling and thresholds to balance code growth against runtime
247 /// improvements. It includes vectorization and other information destroying
248 /// transformations. It also cannot generally be run repeatedly on a module
249 /// without potentially seriously regressing either runtime performance of
250 /// the code or serious code size growth.
251 ///
252 /// Note that \p Level cannot be `O0` here. The pipelines produced are
253 /// only intended for use when attempting to optimize code. If frontends
254 /// require some transformations for semantic reasons, they should explicitly
255 /// build them.
257 OptimizationLevel Level, ThinOrFullLTOPhase LTOPhase);
258
259 /// Build a per-module default optimization pipeline.
260 ///
261 /// This provides a good default optimization pipeline for per-module
262 /// optimization and code generation without any link-time optimization. It
263 /// typically correspond to frontend "-O[123]" options for optimization
264 /// levels \c O1, \c O2 and \c O3 resp.
266 OptimizationLevel Level,
268
269 /// Build a fat object default optimization pipeline.
270 ///
271 /// This builds a pipeline that runs the LTO/ThinLTO pre-link pipeline, and
272 /// emits a section containing the pre-link bitcode along side the object code
273 /// generated in non-LTO compilation.
275 bool ThinLTO,
276 bool EmitSummary,
277 bool Verify = true);
278
279 /// Build a pre-link, ThinLTO-targeting default optimization pipeline to
280 /// a pass manager.
281 ///
282 /// This adds the pre-link optimizations tuned to prepare a module for
283 /// a ThinLTO run. It works to minimize the IR which needs to be analyzed
284 /// without making irreversible decisions which could be made better during
285 /// the LTO run.
288
289 /// Build a ThinLTO default optimization pipeline to a pass manager.
290 ///
291 /// This provides a good default optimization pipeline for link-time
292 /// optimization and code generation. It is particularly tuned to fit well
293 /// when IR coming into the LTO phase was first run through \c
294 /// buildThinLTOPreLinkDefaultPipeline, and the two coordinate closely.
296 OptimizationLevel Level, const ModuleSummaryIndex *ImportSummary);
297
298 /// Build a pre-link, LTO-targeting default optimization pipeline to a pass
299 /// manager.
300 ///
301 /// This adds the pre-link optimizations tuned to work well with a later LTO
302 /// run. It works to minimize the IR which needs to be analyzed without
303 /// making irreversible decisions which could be made better during the LTO
304 /// run.
307
308 /// Build an LTO default optimization pipeline to a pass manager.
309 ///
310 /// This provides a good default optimization pipeline for link-time
311 /// optimization and code generation. It is particularly tuned to fit well
312 /// when IR coming into the LTO phase was first run through \c
313 /// buildLTOPreLinkDefaultPipeline, and the two coordinate closely.
315 OptimizationLevel Level, ModuleSummaryIndex *ExportSummary);
316
317 /// Build an O0 pipeline with the minimal semantically required passes.
318 ///
319 /// This should only be used for non-LTO and LTO pre-link pipelines.
323
324 /// Build the default `AAManager` with the default alias analysis pipeline
325 /// registered.
326 ///
327 /// This also adds target-specific alias analyses registered via
328 /// TargetMachine::registerDefaultAliasAnalyses().
330
331 /// Parse a textual pass pipeline description into a \c
332 /// ModulePassManager.
333 ///
334 /// The format of the textual pass pipeline description looks something like:
335 ///
336 /// module(function(instcombine,sroa),dce,cgscc(inliner,function(...)),...)
337 ///
338 /// Pass managers have ()s describing the nest structure of passes. All passes
339 /// are comma separated. As a special shortcut, if the very first pass is not
340 /// a module pass (as a module pass manager is), this will automatically form
341 /// the shortest stack of pass managers that allow inserting that first pass.
342 /// So, assuming function passes 'fpassN', CGSCC passes 'cgpassN', and loop
343 /// passes 'lpassN', all of these are valid:
344 ///
345 /// fpass1,fpass2,fpass3
346 /// cgpass1,cgpass2,cgpass3
347 /// lpass1,lpass2,lpass3
348 ///
349 /// And they are equivalent to the following (resp.):
350 ///
351 /// module(function(fpass1,fpass2,fpass3))
352 /// module(cgscc(cgpass1,cgpass2,cgpass3))
353 /// module(function(loop(lpass1,lpass2,lpass3)))
354 ///
355 /// This shortcut is especially useful for debugging and testing small pass
356 /// combinations.
357 ///
358 /// The sequence of passes aren't necessarily the exact same kind of pass.
359 /// You can mix different levels implicitly if adaptor passes are defined to
360 /// make them work. For example,
361 ///
362 /// mpass1,fpass1,fpass2,mpass2,lpass1
363 ///
364 /// This pipeline uses only one pass manager: the top-level module manager.
365 /// fpass1,fpass2 and lpass1 are added into the top-level module manager
366 /// using only adaptor passes. No nested function/loop pass managers are
367 /// added. The purpose is to allow easy pass testing when the user
368 /// specifically want the pass to run under a adaptor directly. This is
369 /// preferred when a pipeline is largely of one type, but one or just a few
370 /// passes are of different types(See PassBuilder.cpp for examples).
372 StringRef PipelineText);
373
374 /// {{@ Parse a textual pass pipeline description into a specific PassManager
375 ///
376 /// Automatic deduction of an appropriate pass manager stack is not supported.
377 /// For example, to insert a loop pass 'lpass' into a FunctionPassManager,
378 /// this is the valid pipeline text:
379 ///
380 /// function(lpass)
382 StringRef PipelineText);
384 StringRef PipelineText);
386 StringRef PipelineText);
387 /// @}}
388
389 /// Parse a textual MIR pipeline into the provided \c MachineFunctionPass
390 /// manager.
391 /// The format of the textual machine pipeline is a comma separated list of
392 /// machine pass names:
393 ///
394 /// machine-funciton-pass,machine-module-pass,...
395 ///
396 /// There is no need to specify the pass nesting, and this function
397 /// currently cannot handle the pass nesting.
399 StringRef PipelineText);
400
401 /// Parse a textual alias analysis pipeline into the provided AA manager.
402 ///
403 /// The format of the textual AA pipeline is a comma separated list of AA
404 /// pass names:
405 ///
406 /// basic-aa,globals-aa,...
407 ///
408 /// The AA manager is set up such that the provided alias analyses are tried
409 /// in the order specified. See the \c AAManaager documentation for details
410 /// about the logic used. This routine just provides the textual mapping
411 /// between AA names and the analyses to register with the manager.
412 ///
413 /// Returns false if the text cannot be parsed cleanly. The specific state of
414 /// the \p AA manager is unspecified if such an error is encountered and this
415 /// returns false.
417
418 /// Parse RegAllocFilterName to get RegAllocFilterFunc.
419 LLVM_ABI std::optional<RegAllocFilterFunc>
420 parseRegAllocFilter(StringRef RegAllocFilterName);
421
422 /// Print pass names.
424
425 /// The format -print-pipeline-passes requests, or std::nullopt if it is not
426 /// given.
427 LLVM_ABI std::optional<PrintPipelinePassesFormat>
429
430 /// Register a callback for a default optimizer pipeline extension
431 /// point
432 ///
433 /// This extension point allows adding passes that perform peephole
434 /// optimizations similar to the instruction combiner. These passes will be
435 /// inserted after each instance of the instruction combiner pass.
437 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
438 PeepholeEPCallbacks.push_back(C);
439 }
440
441 /// Register a callback for a default optimizer pipeline extension
442 /// point
443 ///
444 /// This extension point allows adding late loop canonicalization and
445 /// simplification passes. This is the last point in the loop optimization
446 /// pipeline before loop deletion. Each pass added
447 /// here must be an instance of LoopPass.
448 /// This is the place to add passes that can remove loops, such as target-
449 /// specific loop idiom recognition.
451 const std::function<void(LoopPassManager &, OptimizationLevel)> &C) {
452 LateLoopOptimizationsEPCallbacks.push_back(C);
453 }
454
455 /// Register a callback for a default optimizer pipeline extension
456 /// point
457 ///
458 /// This extension point allows adding loop passes to the end of the loop
459 /// optimizer.
461 const std::function<void(LoopPassManager &, OptimizationLevel)> &C) {
462 LoopOptimizerEndEPCallbacks.push_back(C);
463 }
464
465 /// Register a callback for a default optimizer pipeline extension
466 /// point
467 ///
468 /// This extension point allows adding optimization passes after most of the
469 /// main optimizations, but before the last cleanup-ish optimizations.
471 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
472 ScalarOptimizerLateEPCallbacks.push_back(C);
473 }
474
475 /// Register a callback for a default optimizer pipeline extension
476 /// point
477 ///
478 /// This extension point allows adding CallGraphSCC passes at the end of the
479 /// main CallGraphSCC passes and before any function simplification passes run
480 /// by CGPassManager.
482 const std::function<void(CGSCCPassManager &, OptimizationLevel)> &C) {
483 CGSCCOptimizerLateEPCallbacks.push_back(C);
484 }
485
486 /// Register a callback for a default optimizer pipeline extension
487 /// point
488 ///
489 /// This extension point allows adding optimization passes before the
490 /// vectorizer and other highly target specific optimization passes are
491 /// executed.
493 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
494 VectorizerStartEPCallbacks.push_back(C);
495 }
496
497 /// Register a callback for a default optimizer pipeline extension
498 /// point
499 ///
500 /// This extension point allows adding optimization passes after the
501 /// vectorizer and other highly target specific optimization passes are
502 /// executed.
504 const std::function<void(FunctionPassManager &, OptimizationLevel)> &C) {
505 VectorizerEndEPCallbacks.push_back(C);
506 }
507
508 /// Register a callback for a default optimizer pipeline extension point.
509 ///
510 /// This extension point allows adding optimization once at the start of the
511 /// pipeline. This does not apply to 'backend' compiles (LTO and ThinLTO
512 /// link-time pipelines).
514 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
515 PipelineStartEPCallbacks.push_back(C);
516 }
517
518 /// Register a callback for a default optimizer pipeline extension point.
519 ///
520 /// This extension point allows adding optimization right after passes that do
521 /// basic simplification of the input IR.
523 const std::function<void(ModulePassManager &, OptimizationLevel,
525 PipelineEarlySimplificationEPCallbacks.push_back(C);
526 }
527
528 /// Register a callback for a default optimizer pipeline extension point
529 ///
530 /// This extension point allows adding optimizations before the function
531 /// optimization pipeline.
533 const std::function<void(ModulePassManager &, OptimizationLevel,
535 OptimizerEarlyEPCallbacks.push_back(C);
536 }
537
538 /// Register a callback for a default optimizer pipeline extension point
539 ///
540 /// This extension point allows adding optimizations at the very end of the
541 /// function optimization pipeline.
543 const std::function<void(ModulePassManager &, OptimizationLevel,
545 OptimizerLastEPCallbacks.push_back(C);
546 }
547
548 /// Register a callback for a default optimizer pipeline extension point
549 ///
550 /// This extension point allows adding optimizations at the start of the full
551 /// LTO pipeline.
553 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
554 FullLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
555 }
556
557 /// Register a callback for a default optimizer pipeline extension point
558 ///
559 /// This extension point allows adding optimizations at the end of the full
560 /// LTO pipeline.
562 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
563 FullLinkTimeOptimizationLastEPCallbacks.push_back(C);
564 }
565
566 /// Register a callback for ThinLTO default optimizer pipeline extension point
567 ///
568 /// This extension point allows adding optimizations at the start of the
569 /// thin LTO pipeline.
571 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
572 ThinLinkTimeOptimizationEarlyEPCallbacks.push_back(C);
573 }
574
575 /// Register a callback for ThinLTO default optimizer pipeline extension point
576 ///
577 /// This extension point allows adding optimizations at the end of the thin
578 /// LTO pipeline.
580 const std::function<void(ModulePassManager &, OptimizationLevel)> &C) {
581 ThinLinkTimeOptimizationLastEPCallbacks.push_back(C);
582 }
583
584 /// Register a callback for parsing an AliasAnalysis Name to populate
585 /// the given AAManager \p AA
587 const std::function<bool(StringRef Name, AAManager &AA)> &C) {
588 AAParsingCallbacks.push_back(C);
589 }
590
591 /// {{@ Register callbacks for analysis registration with this PassBuilder
592 /// instance.
593 /// Callees register their analyses with the given AnalysisManager objects.
595 const std::function<void(CGSCCAnalysisManager &)> &C) {
596 CGSCCAnalysisRegistrationCallbacks.push_back(C);
597 }
599 const std::function<void(FunctionAnalysisManager &)> &C) {
600 FunctionAnalysisRegistrationCallbacks.push_back(C);
601 }
603 const std::function<void(LoopAnalysisManager &)> &C) {
604 LoopAnalysisRegistrationCallbacks.push_back(C);
605 }
607 const std::function<void(ModuleAnalysisManager &)> &C) {
608 ModuleAnalysisRegistrationCallbacks.push_back(C);
609 }
611 const std::function<void(MachineFunctionAnalysisManager &)> &C) {
612 MachineFunctionAnalysisRegistrationCallbacks.push_back(C);
613 }
614 /// @}}
615
616 /// {{@ Register pipeline parsing callbacks with this pass builder instance.
617 /// Using these callbacks, callers can parse both a single pass name, as well
618 /// as entire sub-pipelines, and populate the PassManager instance
619 /// accordingly.
621 const std::function<bool(StringRef Name, CGSCCPassManager &,
623 CGSCCPipelineParsingCallbacks.push_back(C);
624 }
626 const std::function<bool(StringRef Name, FunctionPassManager &,
628 FunctionPipelineParsingCallbacks.push_back(C);
629 }
631 const std::function<bool(StringRef Name, LoopPassManager &,
633 LoopPipelineParsingCallbacks.push_back(C);
634 }
636 const std::function<bool(StringRef Name, ModulePassManager &,
638 ModulePipelineParsingCallbacks.push_back(C);
639 }
641 const std::function<bool(StringRef Name, MachineFunctionPassManager &,
643 MachineFunctionPipelineParsingCallbacks.push_back(C);
644 }
645 /// @}}
646
647 /// Register callbacks to parse target specific filter field if regalloc pass
648 /// needs it. E.g. AMDGPU requires regalloc passes can handle sgpr and vgpr
649 /// separately.
651 const std::function<RegAllocFilterFunc(StringRef)> &C) {
652 RegClassFilterParsingCallbacks.push_back(C);
653 }
654
655 /// Register a callback for a top-level pipeline entry.
656 ///
657 /// If the PassManager type is not given at the top level of the pipeline
658 /// text, this Callback should be used to determine the appropriate stack of
659 /// PassManagers and populate the passed ModulePassManager.
661 const std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>
662 &C);
663
664 /// Add PGOInstrumenation passes for O0 only.
666 bool RunProfileGen, bool IsCS,
667 bool AtomicCounterUpdate,
668 std::string ProfileFile,
669 std::string ProfileRemappingFile);
670
671 /// Returns PIC. External libraries can use this to register pass
672 /// instrumentation callbacks.
676
677 /// Returns the virtual file system.
681
682 // Invoke the callbacks registered for the various extension points.
683 // Custom pipelines should use these to invoke the callbacks registered
684 // by TargetMachines and other clients.
686 OptimizationLevel Level);
688 OptimizationLevel Level);
690 OptimizationLevel Level);
692 OptimizationLevel Level);
694 OptimizationLevel Level);
696 OptimizationLevel Level);
698 OptimizationLevel Level);
700 OptimizationLevel Level,
703 OptimizationLevel Level,
705 LLVM_ABI void
707 OptimizationLevel Level);
708 LLVM_ABI void
710 OptimizationLevel Level);
711 LLVM_ABI void
713 OptimizationLevel Level);
714 LLVM_ABI void
716 OptimizationLevel Level);
718 OptimizationLevel Level);
719 LLVM_ABI void
721 OptimizationLevel Level,
723
725 if (!Name.consume_front(PassName))
726 return false;
727 // normal pass name w/o parameters == default parameters
728 if (Name.empty())
729 return true;
730 return Name.starts_with("<") && Name.ends_with(">");
731 }
732
733 /// This performs customized parsing of pass name with parameters.
734 ///
735 /// We do not need parametrization of passes in textual pipeline very often,
736 /// yet on a rare occasion ability to specify parameters right there can be
737 /// useful.
738 ///
739 /// \p Name - parameterized specification of a pass from a textual pipeline
740 /// is a string in a form of :
741 /// PassName '<' parameter-list '>'
742 ///
743 /// Parameter list is being parsed by the parser callable argument, \p Parser,
744 /// It takes a string-ref of parameters and returns either StringError or a
745 /// parameter list in a form of a custom parameters type, all wrapped into
746 /// Expected<> template class.
747 ///
748 template <typename ParametersParseCallableT>
749 static auto parsePassParameters(ParametersParseCallableT &&Parser,
751 -> decltype(Parser(StringRef{})) {
752 using ParametersT = typename decltype(Parser(StringRef{}))::value_type;
753
754 StringRef Params = Name;
755 if (!Params.consume_front(PassName)) {
757 "unable to strip pass name from parametrized pass specification");
758 }
759 if (!Params.empty() &&
760 (!Params.consume_front("<") || !Params.consume_back(">"))) {
761 llvm_unreachable("invalid format for parametrized pass name");
762 }
763
764 Expected<ParametersT> Result = Parser(Params);
765 assert((Result || Result.template errorIsA<StringError>()) &&
766 "Pass parameter parser can only return StringErrors.");
767 return Result;
768 }
769
770 /// Handle passes only accept one bool-valued parameter.
771 ///
772 /// \return false when Params is empty.
773 LLVM_ABI static Expected<bool> parseSinglePassOption(StringRef Params,
774 StringRef OptionName,
775 StringRef PassName);
776
777private:
778 // O1 pass pipeline
780 buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
782
783 void addRequiredLTOPreLinkPasses(ModulePassManager &MPM);
784
785 void addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM,
786 ThinOrFullLTOPhase LTOPhase);
787
788 static std::optional<std::vector<PipelineElement>>
789 parsePipelineText(StringRef Text);
790
791 Error parseModulePass(ModulePassManager &MPM, const PipelineElement &E);
792 Error parseCGSCCPass(CGSCCPassManager &CGPM, const PipelineElement &E);
793 Error parseFunctionPass(FunctionPassManager &FPM, const PipelineElement &E);
794 Error parseLoopPass(LoopPassManager &LPM, const PipelineElement &E);
795 Error parseMachinePass(MachineFunctionPassManager &MFPM,
796 const PipelineElement &E);
797 bool parseAAPassName(AAManager &AA, StringRef Name);
798
799 Error parseMachinePassPipeline(MachineFunctionPassManager &MFPM,
801 Error parseLoopPassPipeline(LoopPassManager &LPM,
803 Error parseFunctionPassPipeline(FunctionPassManager &FPM,
805 Error parseCGSCCPassPipeline(CGSCCPassManager &CGPM,
807 Error parseModulePassPipeline(ModulePassManager &MPM,
809
810 // Adds passes to do pre-inlining and related cleanup passes before
811 // profile instrumentation/matching (to enable better context sensitivity),
812 // and for memprof to enable better matching with missing debug frames.
813 void addPreInlinerPasses(ModulePassManager &MPM, OptimizationLevel Level,
814 ThinOrFullLTOPhase LTOPhase);
815
816 void addPGOInstrPasses(ModulePassManager &MPM, OptimizationLevel Level,
817 bool RunProfileGen, bool IsCS,
818 bool AtomicCounterUpdate, std::string ProfileFile,
819 std::string ProfileRemappingFile);
820 void addPostPGOLoopRotation(ModulePassManager &MPM, OptimizationLevel Level);
821
822 bool isInstrumentedPGOUse() const;
823
824 // Extension Point callbacks
825 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
826 PeepholeEPCallbacks;
827 SmallVector<std::function<void(LoopPassManager &, OptimizationLevel)>, 2>
828 LateLoopOptimizationsEPCallbacks;
829 SmallVector<std::function<void(LoopPassManager &, OptimizationLevel)>, 2>
830 LoopOptimizerEndEPCallbacks;
831 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
832 ScalarOptimizerLateEPCallbacks;
833 SmallVector<std::function<void(CGSCCPassManager &, OptimizationLevel)>, 2>
834 CGSCCOptimizerLateEPCallbacks;
835 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
836 VectorizerStartEPCallbacks;
837 SmallVector<std::function<void(FunctionPassManager &, OptimizationLevel)>, 2>
838 VectorizerEndEPCallbacks;
839 // Module callbacks
840 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
842 2>
843 OptimizerEarlyEPCallbacks;
844 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
846 2>
847 OptimizerLastEPCallbacks;
848 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
849 FullLinkTimeOptimizationEarlyEPCallbacks;
850 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
851 FullLinkTimeOptimizationLastEPCallbacks;
852 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
853 ThinLinkTimeOptimizationEarlyEPCallbacks;
854 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
855 ThinLinkTimeOptimizationLastEPCallbacks;
856 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel)>, 2>
857 PipelineStartEPCallbacks;
858 SmallVector<std::function<void(ModulePassManager &, OptimizationLevel,
860 2>
861 PipelineEarlySimplificationEPCallbacks;
862
863 SmallVector<std::function<void(ModuleAnalysisManager &)>, 2>
864 ModuleAnalysisRegistrationCallbacks;
865 SmallVector<std::function<bool(StringRef, ModulePassManager &,
867 2>
868 ModulePipelineParsingCallbacks;
870 std::function<bool(ModulePassManager &, ArrayRef<PipelineElement>)>, 2>
871 TopLevelPipelineParsingCallbacks;
872 // CGSCC callbacks
873 SmallVector<std::function<void(CGSCCAnalysisManager &)>, 2>
874 CGSCCAnalysisRegistrationCallbacks;
875 SmallVector<std::function<bool(StringRef, CGSCCPassManager &,
877 2>
878 CGSCCPipelineParsingCallbacks;
879 // Function callbacks
880 SmallVector<std::function<void(FunctionAnalysisManager &)>, 2>
881 FunctionAnalysisRegistrationCallbacks;
882 SmallVector<std::function<bool(StringRef, FunctionPassManager &,
884 2>
885 FunctionPipelineParsingCallbacks;
886 // Loop callbacks
887 SmallVector<std::function<void(LoopAnalysisManager &)>, 2>
888 LoopAnalysisRegistrationCallbacks;
889 SmallVector<std::function<bool(StringRef, LoopPassManager &,
891 2>
892 LoopPipelineParsingCallbacks;
893 // AA callbacks
894 SmallVector<std::function<bool(StringRef Name, AAManager &AA)>, 2>
895 AAParsingCallbacks;
896 // Machine pass callbackcs
897 SmallVector<std::function<void(MachineFunctionAnalysisManager &)>, 2>
898 MachineFunctionAnalysisRegistrationCallbacks;
899 SmallVector<std::function<bool(StringRef, MachineFunctionPassManager &,
901 2>
902 MachineFunctionPipelineParsingCallbacks;
903 // Callbacks to parse `filter` parameter in register allocation passes
904 SmallVector<std::function<RegAllocFilterFunc(StringRef)>, 2>
905 RegClassFilterParsingCallbacks;
906};
907
908/// This utility template takes care of adding require<> and invalidate<>
909/// passes for an analysis to a given \c PassManager. It is intended to be used
910/// during parsing of a pass pipeline when parsing a single PipelineName.
911/// When registering a new function analysis FancyAnalysis with the pass
912/// pipeline name "fancy-analysis", a matching ParsePipelineCallback could look
913/// like this:
914///
915/// static bool parseFunctionPipeline(StringRef Name, FunctionPassManager &FPM,
916/// ArrayRef<PipelineElement> P) {
917/// if (parseAnalysisUtilityPasses<FancyAnalysis>("fancy-analysis", Name,
918/// FPM))
919/// return true;
920/// return false;
921/// }
922template <typename AnalysisT, typename IRUnitT, typename AnalysisManagerT,
923 typename... ExtraArgTs>
925 StringRef AnalysisName, StringRef PipelineName,
927 if (!PipelineName.ends_with(">"))
928 return false;
929 // See if this is an invalidate<> pass name
930 if (PipelineName.starts_with("invalidate<")) {
931 PipelineName = PipelineName.substr(11, PipelineName.size() - 12);
932 if (PipelineName != AnalysisName)
933 return false;
935 return true;
936 }
937
938 // See if this is a require<> pass name
939 if (PipelineName.starts_with("require<")) {
940 PipelineName = PipelineName.substr(8, PipelineName.size() - 9);
941 if (PipelineName != AnalysisName)
942 return false;
943 PM.addPass(RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
944 ExtraArgTs...>());
945 return true;
946 }
947
948 return false;
949}
950
951// These are special since they are only for testing purposes.
952
953/// No-op module pass which does nothing.
959
960/// No-op module analysis.
961class NoOpModuleAnalysis : public AnalysisInfoMixin<NoOpModuleAnalysis> {
963 LLVM_ABI static AnalysisKey Key;
964
965public:
966 struct Result {};
968};
969
970/// No-op CGSCC pass which does nothing.
977
978/// No-op CGSCC analysis.
979class NoOpCGSCCAnalysis : public AnalysisInfoMixin<NoOpCGSCCAnalysis> {
981 LLVM_ABI static AnalysisKey Key;
982
983public:
984 struct Result {};
988};
989
990/// No-op function pass which does nothing.
996
997/// No-op function analysis.
998class NoOpFunctionAnalysis : public AnalysisInfoMixin<NoOpFunctionAnalysis> {
1000 LLVM_ABI static AnalysisKey Key;
1001
1002public:
1003 struct Result {};
1005};
1006
1007/// No-op loop nest pass which does nothing.
1014
1015/// No-op loop pass which does nothing.
1022
1023/// No-op machine function pass which does nothing.
1030
1031/// No-op loop analysis.
1032class NoOpLoopAnalysis : public AnalysisInfoMixin<NoOpLoopAnalysis> {
1034 LLVM_ABI static AnalysisKey Key;
1035
1036public:
1037 struct Result {};
1041};
1042
1044 raw_ostream &OS, StringRef Pipeline,
1046}
1047
1048#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.
LLVM_ABI std::optional< PrintPipelinePassesFormat > getPrintPipelinePasses() const
The format -print-pipeline-passes requests, or std::nullopt if it is not given.
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:42
unsigned LicmMssaNoAccForPromotionCap
Tuning option to disable promotion to scalars in LICM with MemorySSA, if the number of access is too ...
Definition PassBuilder.h:79
bool SLPVectorization
Tuning option to enable/disable slp loop vectorization, set based on opt level.
Definition PassBuilder.h:57
int InlinerThreshold
Tuning option to override the default inliner threshold.
Definition PassBuilder.h:93
bool LoopFusion
Tuning option to enable/disable loop fusion. Its default value is false.
Definition PassBuilder.h:67
bool CallGraphProfile
Tuning option to enable/disable call graph profile.
Definition PassBuilder.h:83
bool MergeFunctions
Tuning option to enable/disable function merging.
Definition PassBuilder.h:90
bool ForgetAllSCEVInLoopUnroll
Tuning option to forget all SCEV loops in LoopUnroll.
Definition PassBuilder.h:71
unsigned LicmMssaOptCap
Tuning option to cap the number of calls to retrive clobbering accesses in MemorySSA,...
Definition PassBuilder.h:75
bool LoopInterleaving
Tuning option to set loop interleaving on/off, set based on opt level.
Definition PassBuilder.h:49
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:60
bool LoopInterchange
Tuning option to enable/disable loop interchange.
Definition PassBuilder.h:64
bool LoopVectorization
Tuning option to enable/disable loop vectorization, set based on opt level.
Definition PassBuilder.h:53
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.
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
A utility pass template to force an analysis result to be available.