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