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