MLIR 24.0.0git
PassManager.h
Go to the documentation of this file.
1//===- PassManager.h - Pass Management Interface ----------------*- 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
9#ifndef MLIR_PASS_PASSMANAGER_H
10#define MLIR_PASS_PASSMANAGER_H
11
12#include "mlir/IR/Dialect.h"
14#include "mlir/Support/Timing.h"
15#include "llvm/ADT/SmallVector.h"
16#include "llvm/ADT/iterator.h"
17#include "llvm/Support/raw_ostream.h"
18
19#include <functional>
20#include <optional>
21
22namespace mlir {
23class AnalysisManager;
24class MLIRContext;
25class Operation;
26class Pass;
29
30namespace detail {
35} // namespace detail
36
37//===----------------------------------------------------------------------===//
38// OpPassManager
39//===----------------------------------------------------------------------===//
40
41/// This class represents a pass manager that runs passes on either a specific
42/// operation type, or any isolated operation. This pass manager can not be run
43/// on an operation directly, but must be run either as part of a top-level
44/// `PassManager`(e.g. when constructed via `nest` calls), or dynamically within
45/// a pass by using the `Pass::runPipeline` API.
47public:
48 /// This enum represents the nesting behavior of the pass manager.
49 enum class Nesting {
50 /// Implicit nesting behavior. This allows for adding passes operating on
51 /// operations different from this pass manager, in which case a new pass
52 /// manager is implicitly nested for the operation type of the new pass.
54 /// Explicit nesting behavior. This requires that any passes added to this
55 /// pass manager support its operation type.
57 };
58
59 /// Construct a new op-agnostic ("any") pass manager with the given operation
60 /// type and nesting behavior. This is the same as invoking:
61 /// `OpPassManager(getAnyOpAnchorName(), nesting)`.
62 OpPassManager(Nesting nesting = Nesting::Explicit);
63
64 /// Construct a new pass manager with the given anchor operation type and
65 /// nesting behavior.
66 OpPassManager(StringRef name, Nesting nesting = Nesting::Explicit);
67 OpPassManager(OperationName name, Nesting nesting = Nesting::Explicit);
69 OpPassManager(const OpPassManager &rhs);
73
74 /// Iterator over the passes in this pass manager.
76 llvm::pointee_iterator<MutableArrayRef<std::unique_ptr<Pass>>::iterator>;
80
82 llvm::pointee_iterator<ArrayRef<std::unique_ptr<Pass>>::const_iterator>;
86 return {begin(), end()};
87 }
88
89 /// Returns true if the pass manager has no passes.
90 bool empty() const { return begin() == end(); }
91
92 /// Nest a new operation pass manager for the given operation kind under this
93 /// pass manager.
94 OpPassManager &nest(OperationName nestedName);
95 OpPassManager &nest(StringRef nestedName);
96 template <typename OpT>
98 return nest(OpT::getOperationName());
99 }
100
101 /// Nest a new op-agnostic ("any") pass manager under this pass manager.
102 /// Note: This is the same as invoking `nest(getAnyOpAnchorName())`.
104
105 /// Add the given pass to this pass manager. If this pass has a concrete
106 /// operation type, it must be the same type as this pass manager.
107 void addPass(std::unique_ptr<Pass> pass);
108
109 /// Clear the pipeline, but not the other options set on this OpPassManager.
110 void clear();
111
112 /// Add the given pass to a nested pass manager for the given operation kind
113 /// `OpT`.
114 template <typename OpT>
115 void addNestedPass(std::unique_ptr<Pass> pass) {
116 nest<OpT>().addPass(std::move(pass));
117 }
118
119 /// Returns the number of passes held by this manager.
120 size_t size() const;
121
122 /// Return the operation name that this pass manager operates on, or
123 /// std::nullopt if this is an op-agnostic pass manager.
124 std::optional<OperationName> getOpName(MLIRContext &context) const;
125
126 /// Return the operation name that this pass manager operates on, or
127 /// std::nullopt if this is an op-agnostic pass manager.
128 std::optional<StringRef> getOpName() const;
129
130 /// Return the name used to anchor this pass manager. This is either the name
131 /// of an operation, or the result of `getAnyOpAnchorName()` in the case of an
132 /// op-agnostic pass manager.
133 StringRef getOpAnchorName() const;
134
135 /// Return the string name used to anchor op-agnostic pass managers that
136 /// operate generically on any viable operation.
137 static StringRef getAnyOpAnchorName() { return "any"; }
138
139 /// Returns the internal implementation instance.
141
142 /// Prints out the passes of the pass manager as the textual representation
143 /// of pipelines. When `pretty` is true, the printed pipeline is formatted
144 /// for readability.
145 ///
146 /// Note: The quality of the string representation depends entirely on the
147 /// the correctness of per-pass overrides of Pass::printAsTextualPipeline.
148 void printAsTextualPipeline(raw_ostream &os, bool pretty = false) const;
149
150 /// Raw dump of the pass manager to llvm::errs().
151#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
152 LLVM_DUMP_METHOD void dump();
153#endif
154
155 /// Merge the pass statistics of this class into 'other'.
157
158 /// Register dependent dialects for the current pass manager.
159 /// This is forwarding to every pass in this PassManager, see the
160 /// documentation for the same method on the Pass class.
161 void getDependentDialects(DialectRegistry &dialects) const;
162
163 /// Enable or disable the implicit nesting on this particular PassManager.
164 /// This will also apply to any newly nested PassManager built from this
165 /// instance.
166 void setNesting(Nesting nesting);
167
168 /// Return the current nesting mode.
169 Nesting getNesting();
170
171private:
172 /// Initialize all of the passes within this pass manager with the given
173 /// initialization generation. The initialization generation is used to detect
174 /// if a pass manager has already been initialized.
175 LogicalResult initialize(MLIRContext *context, unsigned newInitGeneration);
176
177 /// Compute a hash of the pipeline, so that we can detect changes (a pass is
178 /// added...).
179 llvm::hash_code hash();
180
181 /// A pointer to an internal implementation instance.
182 std::unique_ptr<detail::OpPassManagerImpl> impl;
183
184 /// Allow access to initialize.
186
187 /// Allow access to the constructor.
188 friend class PassManager;
189 friend class Pass;
190
191 /// Allow access.
193};
194
195//===----------------------------------------------------------------------===//
196// PassManager
197//===----------------------------------------------------------------------===//
198
199/// An enum describing the different display modes for the information within
200/// the pass manager.
201enum class PassDisplayMode {
202 // In this mode the results are displayed in a list sorted by total,
203 // with each pass/analysis instance aggregated into one unique result.
205
206 // In this mode the results are displayed in a nested pipeline view that
207 // mirrors the internal pass pipeline that is being executed in the pass
208 // manager.
210};
211
212/// Streams on which to output crash reproducer.
214 virtual ~ReproducerStream() = default;
215
216 /// Description of the reproducer stream.
217 virtual StringRef description() = 0;
218
219 /// Stream on which to output reproducer.
220 virtual raw_ostream &os() = 0;
221};
222
223/// Method type for constructing ReproducerStream.
225 std::function<std::unique_ptr<ReproducerStream>(std::string &error)>;
226
227std::string
228makeReproducer(StringRef anchorName,
230 Operation *op, StringRef outputFile, bool disableThreads = false,
231 bool verifyPasses = false);
232
233/// The main pass manager and pipeline builder.
235public:
236 /// Create a new pass manager under the given context with a specific nesting
237 /// style. The created pass manager can schedule operations that match
238 /// `operationName`.
240 StringRef operationName = PassManager::getAnyOpAnchorName(),
241 Nesting nesting = Nesting::Explicit);
242 PassManager(OperationName operationName, Nesting nesting = Nesting::Explicit);
244
245 /// Create a new pass manager under the given context with a specific nesting
246 /// style. The created pass manager can schedule operations that match
247 /// `OperationTy`.
248 template <typename OperationTy>
250 return PassManager(ctx, OperationTy::getOperationName(), nesting);
251 }
252
253 /// Run the passes within this manager on the provided operation. The
254 /// specified operation must have the same name as the one provided the pass
255 /// manager on construction.
256 LogicalResult run(Operation *op);
257
258 /// Return an instance of the context.
259 MLIRContext *getContext() const { return context; }
260
261 /// Enable support for the pass manager to generate a reproducer on the event
262 /// of a crash or a pass failure. `outputFile` is a .mlir filename used to
263 /// write the generated reproducer. If `genLocalReproducer` is true, the pass
264 /// manager will attempt to generate a local reproducer that contains the
265 /// smallest pipeline.
266 void enableCrashReproducerGeneration(StringRef outputFile,
267 bool genLocalReproducer = false);
268
269 /// Enable support for the pass manager to generate a reproducer on the event
270 /// of a crash or a pass failure. `factory` is used to construct the streams
271 /// to write the generated reproducer to. If `genLocalReproducer` is true, the
272 /// pass manager will attempt to generate a local reproducer that contains the
273 /// smallest pipeline.
275 bool genLocalReproducer = false);
276
277 /// Runs the verifier after each individual pass.
278 void enableVerifier(bool enabled = true);
279
280 //===--------------------------------------------------------------------===//
281 // Instrumentations
282 //===--------------------------------------------------------------------===//
283
284 /// Add the provided instrumentation to the pass manager.
285 void addInstrumentation(std::unique_ptr<PassInstrumentation> pi);
286
287 //===--------------------------------------------------------------------===//
288 // IR Printing
289
290 /// A configuration struct provided to the IR printer instrumentation.
292 public:
294
295 /// Initialize the configuration.
296 /// * 'printModuleScope' signals if the top-level module IR should always be
297 /// printed. This should only be set to true when multi-threading is
298 /// disabled, otherwise we may try to print IR that is being modified
299 /// asynchronously.
300 /// * 'printAfterOnlyOnChange' signals that when printing the IR after a
301 /// pass, in the case of a non-failure, we should first check if any
302 /// potential mutations were made. This allows for reducing the number of
303 /// logs that don't contain meaningful changes.
304 /// * 'printAfterOnlyOnFailure' signals that when printing the IR after a
305 /// pass, we only print in the case of a failure.
306 /// - This option should *not* be used with the other `printAfter` flags
307 /// above.
308 /// * 'opPrintingFlags' sets up the printing flags to use when printing the
309 /// IR.
310 explicit IRPrinterConfig(
311 bool printModuleScope = false, bool printAfterOnlyOnChange = false,
312 bool printAfterOnlyOnFailure = false,
313 OpPrintingFlags opPrintingFlags = OpPrintingFlags());
315
316 /// A hook that may be overridden by a derived config that checks if the IR
317 /// of 'operation' should be dumped *before* the pass 'pass' has been
318 /// executed. If the IR should be dumped, 'printCallback' should be invoked
319 /// with the stream to dump into.
320 virtual void printBeforeIfEnabled(Pass *pass, Operation *operation,
321 PrintCallbackFn printCallback);
322
323 /// A hook that may be overridden by a derived config that checks if the IR
324 /// of 'operation' should be dumped *after* the pass 'pass' has been
325 /// executed. If the IR should be dumped, 'printCallback' should be invoked
326 /// with the stream to dump into.
327 virtual void printAfterIfEnabled(Pass *pass, Operation *operation,
328 PrintCallbackFn printCallback);
329
330 /// Returns true if the IR should always be printed at the top-level scope.
331 bool shouldPrintAtModuleScope() const { return printModuleScope; }
332
333 /// Returns true if the IR should only printed after a pass if the IR
334 /// "changed".
335 bool shouldPrintAfterOnlyOnChange() const { return printAfterOnlyOnChange; }
336
337 /// Returns true if the IR should only printed after a pass if the pass
338 /// "failed".
340 return printAfterOnlyOnFailure;
341 }
342
343 /// Returns the printing flags to be used to print the IR.
344 OpPrintingFlags getOpPrintingFlags() const { return opPrintingFlags; }
345
346 private:
347 /// A flag that indicates if the IR should be printed at module scope.
348 bool printModuleScope;
349
350 /// A flag that indicates that the IR after a pass should only be printed if
351 /// a change is detected.
352 bool printAfterOnlyOnChange;
353
354 /// A flag that indicates that the IR after a pass should only be printed if
355 /// the pass failed.
356 bool printAfterOnlyOnFailure;
357
358 /// Flags to control printing behavior.
359 OpPrintingFlags opPrintingFlags;
360 };
361
362 /// Add an instrumentation to print the IR before and after pass execution,
363 /// using the provided configuration.
364 void enableIRPrinting(std::unique_ptr<IRPrinterConfig> config);
365
366 /// Add an instrumentation to print the IR before and after pass execution,
367 /// using the provided fields to generate a default configuration:
368 /// * 'shouldPrintBeforePass' and 'shouldPrintAfterPass' correspond to filter
369 /// functions that take a 'Pass *' and `Operation *`. These function should
370 /// return true if the IR should be printed or not.
371 /// * 'printModuleScope' signals if the module IR should be printed, even
372 /// for non module passes.
373 /// * 'printAfterOnlyOnChange' signals that when printing the IR after a
374 /// pass, in the case of a non-failure, we should first check if any
375 /// potential mutations were made.
376 /// * 'printAfterOnlyOnFailure' signals that when printing the IR after a
377 /// pass, we only print in the case of a failure.
378 /// - This option should *not* be used with the other `printAfter` flags
379 /// above.
380 /// * 'out' corresponds to the stream to output the printed IR to.
381 /// * 'opPrintingFlags' sets up the printing flags to use when printing the
382 /// IR.
383 void enableIRPrinting(
384 std::function<bool(Pass *, Operation *)> shouldPrintBeforePass =
385 [](Pass *, Operation *) { return true; },
386 std::function<bool(Pass *, Operation *)> shouldPrintAfterPass =
387 [](Pass *, Operation *) { return true; },
388 bool printModuleScope = true, bool printAfterOnlyOnChange = true,
389 bool printAfterOnlyOnFailure = false, raw_ostream &out = llvm::errs(),
390 OpPrintingFlags opPrintingFlags = OpPrintingFlags());
391
392 /// Similar to `enableIRPrinting` above, except that instead of printing
393 /// the IR to a single output stream, the instrumentation will print the
394 /// output of each pass to a separate file. The files will be organized into a
395 /// directory tree rooted at `printTreeDir`. The directories mirror the
396 /// nesting structure of the IR. For example, if the IR is congruent to the
397 /// pass-pipeline "builtin.module(passA,passB,func.func(passC,passD),passE)",
398 /// and `printTreeDir=/tmp/pipeline_output`, then then the tree file tree
399 /// created will look like:
400 ///
401 /// ```
402 /// /tmp/pass_output
403 /// ├── builtin_module_the_symbol_name
404 /// │ ├── 0_passA.mlir
405 /// │ ├── 1_passB.mlir
406 /// │ ├── 2_passE.mlir
407 /// │ ├── func_func_my_func_name
408 /// │ │ ├── 1_0_passC.mlir
409 /// │ │ ├── 1_1__passD.mlir
410 /// │ ├── func_func_my_other_func_name
411 /// │ │ ├── 1_0_passC.mlir
412 /// │ │ ├── 1_1_passD.mlir
413 /// ```
414 ///
415 /// The subdirectories are given names that reflect the parent operation name
416 /// and symbol name (if present). The output MLIR files are prefixed using an
417 /// atomic counter to indicate the order the passes were printed in and to
418 /// prevent any potential name collisions.
420 std::function<bool(Pass *, Operation *)> shouldPrintBeforePass =
421 [](Pass *, Operation *) { return true; },
422 std::function<bool(Pass *, Operation *)> shouldPrintAfterPass =
423 [](Pass *, Operation *) { return true; },
424 bool printModuleScope = true, bool printAfterOnlyOnChange = true,
425 bool printAfterOnlyOnFailure = false,
426 llvm::StringRef printTreeDir = ".pass_manager_output",
427 OpPrintingFlags opPrintingFlags = OpPrintingFlags());
428
429 //===--------------------------------------------------------------------===//
430 // Pass Timing
431
432 /// Add an instrumentation to time the execution of passes and the computation
433 /// of analyses. Timing will be reported by nesting timers into the provided
434 /// `timingScope`.
435 ///
436 /// Note: Timing should be enabled after all other instrumentations to avoid
437 /// any potential "ghost" timing from other instrumentations being
438 /// unintentionally included in the timing results.
439 void enableTiming(TimingScope &timingScope);
440
441 /// Add an instrumentation to time the execution of passes and the computation
442 /// of analyses. The pass manager will take ownership of the timing manager
443 /// passed to the function and timing will be reported by nesting timers into
444 /// the timing manager's root scope.
445 ///
446 /// Note: Timing should be enabled after all other instrumentations to avoid
447 /// any potential "ghost" timing from other instrumentations being
448 /// unintentionally included in the timing results.
449 void enableTiming(std::unique_ptr<TimingManager> tm);
450
451 /// Add an instrumentation to time the execution of passes and the computation
452 /// of analyses. Creates a temporary TimingManager owned by this PassManager
453 /// which will be used to report timing.
454 ///
455 /// Note: Timing should be enabled after all other instrumentations to avoid
456 /// any potential "ghost" timing from other instrumentations being
457 /// unintentionally included in the timing results.
458 void enableTiming();
459
460 //===--------------------------------------------------------------------===//
461 // Pass Statistics
462
463 /// Prompts the pass manager to print the statistics collected for each of the
464 /// held passes after each call to 'run'.
465 void
467
468private:
469 /// Dump the statistics of the passes within this pass manager.
470 void dumpStatistics();
471
472 /// Run the pass manager with crash recovery enabled.
473 LogicalResult runWithCrashRecovery(Operation *op, AnalysisManager am);
474
475 /// Run the passes of the pass manager, and return the result.
476 LogicalResult runPasses(Operation *op, AnalysisManager am);
477
478 /// Context this PassManager was initialized with.
479 MLIRContext *context;
480
481 /// Flag that specifies if pass statistics should be dumped.
482 std::optional<PassDisplayMode> passStatisticsMode;
483
484 /// A manager for pass instrumentations.
485 std::unique_ptr<PassInstrumentor> instrumentor;
486
487 /// An optional crash reproducer generator, if this pass manager is setup to
488 /// generate reproducers.
489 std::unique_ptr<detail::PassCrashReproducerGenerator> crashReproGenerator;
490
491 /// Hash keys used to detect when reinitialization is necessary.
492 llvm::hash_code initializationKey = llvm::hash_code(static_cast<size_t>(-1));
493 llvm::hash_code pipelineInitializationKey =
494 llvm::hash_code(static_cast<size_t>(-1));
495
496 /// Flag that specifies if pass timing is enabled.
497 bool passTiming : 1;
498
499 /// A flag that indicates if the IR should be verified in between passes.
500 bool verifyPasses : 1;
501};
502
503/// Register a set of useful command-line options that can be used to configure
504/// a pass manager. The values of these options can be applied via the
505/// 'applyPassManagerCLOptions' method below.
507
508/// Apply any values provided to the pass manager options that were registered
509/// with 'registerPassManagerOptions'.
510LogicalResult applyPassManagerCLOptions(PassManager &pm);
511
512/// Apply any values provided to the timing manager options that were registered
513/// with `registerDefaultTimingManagerOptions`. This is a handy helper function
514/// if you do not want to bother creating your own timing manager and passing it
515/// to the pass manager.
517
518} // namespace mlir
519
520#endif // MLIR_PASS_PASSMANAGER_H
LogicalResult initialize(unsigned origNumLoops, ArrayRef< ReassociationIndices > foldedIterationDims)
static size_t hash(const T &value)
Local helper to compute std::hash for a value.
Definition IRCore.cpp:57
This class represents an analysis manager for a particular operation instance.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:71
This class represents a pass manager that runs passes on either a specific operation type,...
Definition PassManager.h:46
iterator_range< const_pass_iterator > getPasses() const
Definition PassManager.h:85
void mergeStatisticsInto(OpPassManager &other)
Merge the pass statistics of this class into 'other'.
void printAsTextualPipeline(raw_ostream &os, bool pretty=false) const
Prints out the passes of the pass manager as the textual representation of pipelines.
Definition Pass.cpp:453
OpPassManager & operator=(const OpPassManager &rhs)
Definition Pass.cpp:356
friend class PassManager
Allow access to the constructor.
OpPassManager(Nesting nesting=Nesting::Explicit)
Construct a new op-agnostic ("any") pass manager with the given operation type and nesting behavior.
Definition Pass.cpp:348
friend class Pass
void setNesting(Nesting nesting)
Enable or disable the implicit nesting on this particular PassManager.
Definition Pass.cpp:481
bool empty() const
Returns true if the pass manager has no passes.
Definition PassManager.h:90
size_t size() const
Returns the number of passes held by this manager.
Definition Pass.cpp:400
detail::OpPassManagerImpl & getImpl()
Returns the internal implementation instance.
Definition Pass.cpp:403
void addPass(std::unique_ptr< Pass > pass)
Add the given pass to this pass manager.
Definition Pass.cpp:393
Nesting getNesting()
Return the current nesting mode.
Definition Pass.cpp:483
Nesting
This enum represents the nesting behavior of the pass manager.
Definition PassManager.h:49
@ Implicit
Implicit nesting behavior.
Definition PassManager.h:53
@ Explicit
Explicit nesting behavior.
Definition PassManager.h:56
LLVM_DUMP_METHOD void dump()
Raw dump of the pass manager to llvm::errs().
Definition Pass.cpp:464
llvm::pointee_iterator< MutableArrayRef< std::unique_ptr< Pass > >::iterator > pass_iterator
Iterator over the passes in this pass manager.
Definition PassManager.h:75
void addNestedPass(std::unique_ptr< Pass > pass)
Add the given pass to a nested pass manager for the given operation kind OpT.
void getDependentDialects(DialectRegistry &dialects) const
Register dependent dialects for the current pass manager.
Definition Pass.cpp:477
StringRef getOpAnchorName() const
Return the name used to anchor this pass manager.
Definition Pass.cpp:416
std::optional< StringRef > getOpName() const
Return the operation name that this pass manager operates on, or std::nullopt if this is an op-agnost...
Definition Pass.cpp:406
iterator_range< pass_iterator > getPasses()
Definition PassManager.h:79
OpPassManager & nestAny()
Nest a new op-agnostic ("any") pass manager under this pass manager.
Definition Pass.cpp:389
OpPassManager & nest()
Definition PassManager.h:97
llvm::pointee_iterator< ArrayRef< std::unique_ptr< Pass > >::const_iterator > const_pass_iterator
Definition PassManager.h:81
static StringRef getAnyOpAnchorName()
Return the string name used to anchor op-agnostic pass managers that operate generically on any viabl...
void clear()
Clear the pipeline, but not the other options set on this OpPassManager.
Definition Pass.cpp:397
pass_iterator begin()
Definition Pass.cpp:367
pass_iterator end()
Definition Pass.cpp:370
Set of flags used to control the behavior of the various IR print methods (e.g.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
PassInstrumentation provides several entry points into the pass manager infrastructure.
This class holds a collection of PassInstrumentation objects, and invokes their respective call backs...
IRPrinterConfig(bool printModuleScope=false, bool printAfterOnlyOnChange=false, bool printAfterOnlyOnFailure=false, OpPrintingFlags opPrintingFlags=OpPrintingFlags())
Initialize the configuration.
function_ref< void(raw_ostream &)> PrintCallbackFn
bool shouldPrintAfterOnlyOnFailure() const
Returns true if the IR should only printed after a pass if the pass "failed".
virtual void printBeforeIfEnabled(Pass *pass, Operation *operation, PrintCallbackFn printCallback)
A hook that may be overridden by a derived config that checks if the IR of 'operation' should be dump...
bool shouldPrintAtModuleScope() const
Returns true if the IR should always be printed at the top-level scope.
virtual void printAfterIfEnabled(Pass *pass, Operation *operation, PrintCallbackFn printCallback)
A hook that may be overridden by a derived config that checks if the IR of 'operation' should be dump...
OpPrintingFlags getOpPrintingFlags() const
Returns the printing flags to be used to print the IR.
bool shouldPrintAfterOnlyOnChange() const
Returns true if the IR should only printed after a pass if the IR "changed".
The main pass manager and pipeline builder.
void enableStatistics(PassDisplayMode displayMode=PassDisplayMode::Pipeline)
Prompts the pass manager to print the statistics collected for each of the held passes after each cal...
PassManager(MLIRContext *ctx, StringRef operationName=PassManager::getAnyOpAnchorName(), Nesting nesting=Nesting::Explicit)
Create a new pass manager under the given context with a specific nesting style.
Definition Pass.cpp:1016
void enableTiming()
Add an instrumentation to time the execution of passes and the computation of analyses.
void enableIRPrinting(std::unique_ptr< IRPrinterConfig > config)
Add an instrumentation to print the IR before and after pass execution, using the provided configurat...
MLIRContext * getContext() const
Return an instance of the context.
LogicalResult run(Operation *op)
Run the passes within this manager on the provided operation.
Definition Pass.cpp:1031
void enableIRPrintingToFileTree(std::function< bool(Pass *, Operation *)> shouldPrintBeforePass=[](Pass *, Operation *) { return true;}, std::function< bool(Pass *, Operation *)> shouldPrintAfterPass=[](Pass *, Operation *) { return true;}, bool printModuleScope=true, bool printAfterOnlyOnChange=true, bool printAfterOnlyOnFailure=false, llvm::StringRef printTreeDir=".pass_manager_output", OpPrintingFlags opPrintingFlags=OpPrintingFlags())
Similar to enableIRPrinting above, except that instead of printing the IR to a single output stream,...
static PassManager on(MLIRContext *ctx, Nesting nesting=Nesting::Explicit)
Create a new pass manager under the given context with a specific nesting style.
void addInstrumentation(std::unique_ptr< PassInstrumentation > pi)
Add the provided instrumentation to the pass manager.
Definition Pass.cpp:1115
void enableCrashReproducerGeneration(StringRef outputFile, bool genLocalReproducer=false)
Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failur...
void enableVerifier(bool enabled=true)
Runs the verifier after each individual pass.
Definition Pass.cpp:1028
The abstract base pass class.
Definition Pass.h:52
An adaptor pass used to run operation passes over nested operations.
Definition PassDetail.h:26
AttrTypeReplacer.
Include the generated interface declarations.
LogicalResult applyPassManagerCLOptions(PassManager &pm)
Apply any values provided to the pass manager options that were registered with 'registerPassManagerO...
std::string makeReproducer(StringRef anchorName, const llvm::iterator_range< OpPassManager::pass_iterator > &passes, Operation *op, StringRef outputFile, bool disableThreads=false, bool verifyPasses=false)
void registerPassManagerCLOptions()
Register a set of useful command-line options that can be used to configure a pass manager.
std::function< std::unique_ptr< ReproducerStream >(std::string &error)> ReproducerStreamFactory
Method type for constructing ReproducerStream.
PassDisplayMode
An enum describing the different display modes for the information within the pass manager.
void applyDefaultTimingPassManagerCLOptions(PassManager &pm)
Apply any values provided to the timing manager options that were registered with registerDefaultTimi...
llvm::function_ref< Fn > function_ref
Definition LLVM.h:155
Streams on which to output crash reproducer.
virtual raw_ostream & os()=0
Stream on which to output reproducer.
virtual StringRef description()=0
Description of the reproducer stream.
virtual ~ReproducerStream()=default
The state for a single execution of a pass.
Definition Pass.h:27