MLIR  16.0.0git
Classes | Public Types | Public Member Functions | List of all members
mlir::PassManager Class Reference

The main pass manager and pipeline builder. More...

#include "mlir/Pass/PassManager.h"

+ Inheritance diagram for mlir::PassManager:
+ Collaboration diagram for mlir::PassManager:

Classes

class  IRPrinterConfig
 A configuration struct provided to the IR printer instrumentation. More...
 
struct  ReproducerStream
 Streams on which to output crash reproducer. More...
 

Public Types

using ReproducerStreamFactory = std::function< std::unique_ptr< ReproducerStream >(std::string &error)>
 Method type for constructing ReproducerStream. More...
 
- Public Types inherited from mlir::OpPassManager
enum  Nesting { Nesting::Implicit, Nesting::Explicit }
 This enum represents the nesting behavior of the pass manager. More...
 
using pass_iterator = llvm::pointee_iterator< MutableArrayRef< std::unique_ptr< Pass > >::iterator >
 Iterator over the passes in this pass manager. More...
 
using const_pass_iterator = llvm::pointee_iterator< ArrayRef< std::unique_ptr< Pass > >::const_iterator >
 

Public Member Functions

 PassManager (MLIRContext *ctx, Nesting nesting=Nesting::Explicit, StringRef operationName="builtin.module")
 Create a new pass manager under the given context with a specific nesting style. More...
 
 PassManager (MLIRContext *ctx, StringRef operationName)
 
 ~PassManager ()
 
LogicalResult run (Operation *op)
 Run the passes within this manager on the provided operation. More...
 
MLIRContextgetContext () const
 Return an instance of the context. More...
 
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 failure. More...
 
void enableCrashReproducerGeneration (ReproducerStreamFactory factory, bool genLocalReproducer=false)
 Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure. More...
 
void enableVerifier (bool enabled=true)
 Runs the verifier after each individual pass. More...
 
void addInstrumentation (std::unique_ptr< PassInstrumentation > pi)
 Add the provided instrumentation to the pass manager. More...
 
void enableIRPrinting (std::unique_ptr< IRPrinterConfig > config)
 Add an instrumentation to print the IR before and after pass execution, using the provided configuration. More...
 
void enableIRPrinting (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, raw_ostream &out=llvm::errs(), OpPrintingFlags opPrintingFlags=OpPrintingFlags())
 Add an instrumentation to print the IR before and after pass execution, using the provided fields to generate a default configuration: More...
 
void enableTiming (TimingScope &timingScope)
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableTiming (std::unique_ptr< TimingManager > tm)
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableTiming ()
 Add an instrumentation to time the execution of passes and the computation of analyses. More...
 
void enableStatistics (PassDisplayMode displayMode=PassDisplayMode::Pipeline)
 Prompts the pass manager to print the statistics collected for each of the held passes after each call to 'run'. More...
 
- Public Member Functions inherited from mlir::OpPassManager
 OpPassManager (Nesting nesting=Nesting::Explicit)
 Construct a new op-agnostic ("any") pass manager with the given operation type and nesting behavior. More...
 
 OpPassManager (StringRef name, Nesting nesting=Nesting::Explicit)
 Construct a new pass manager with the given anchor operation type and nesting behavior. More...
 
 OpPassManager (OperationName name, Nesting nesting=Nesting::Explicit)
 
 OpPassManager (OpPassManager &&rhs)
 
 OpPassManager (const OpPassManager &rhs)
 
 ~OpPassManager ()
 
OpPassManageroperator= (const OpPassManager &rhs)
 
pass_iterator begin ()
 
pass_iterator end ()
 
iterator_range< pass_iteratorgetPasses ()
 
const_pass_iterator begin () const
 
const_pass_iterator end () const
 
iterator_range< const_pass_iteratorgetPasses () const
 
bool empty () const
 Returns true if the pass manager has no passes. More...
 
OpPassManagernest (OperationName nestedName)
 Nest a new operation pass manager for the given operation kind under this pass manager. More...
 
OpPassManagernest (StringRef nestedName)
 
template<typename OpT >
OpPassManagernest ()
 
OpPassManagernestAny ()
 Nest a new op-agnostic ("any") pass manager under this pass manager. More...
 
void addPass (std::unique_ptr< Pass > pass)
 Add the given pass to this pass manager. More...
 
void clear ()
 Clear the pipeline, but not the other options set on this OpPassManager. More...
 
template<typename OpT >
void addNestedPass (std::unique_ptr< Pass > pass)
 Add the given pass to a nested pass manager for the given operation kind OpT. More...
 
size_t size () const
 Returns the number of passes held by this manager. More...
 
Optional< OperationNamegetOpName (MLIRContext &context) const
 Return the operation name that this pass manager operates on, or None if this is an op-agnostic pass manager. More...
 
Optional< StringRef > getOpName () const
 Return the operation name that this pass manager operates on, or None if this is an op-agnostic pass manager. More...
 
StringRef getOpAnchorName () const
 Return the name used to anchor this pass manager. More...
 
detail::OpPassManagerImplgetImpl ()
 Returns the internal implementation instance. More...
 
void printAsTextualPipeline (raw_ostream &os) const
 Prints out the passes of the pass manager as the textual representation of pipelines. More...
 
void dump ()
 Raw dump of the pass manager to llvm::errs(). More...
 
void mergeStatisticsInto (OpPassManager &other)
 Merge the pass statistics of this class into 'other'. More...
 
void getDependentDialects (DialectRegistry &dialects) const
 Register dependent dialects for the current pass manager. More...
 
void setNesting (Nesting nesting)
 Enable or disable the implicit nesting on this particular PassManager. More...
 
Nesting getNesting ()
 Return the current nesting mode. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from mlir::OpPassManager
static StringRef getAnyOpAnchorName ()
 Return the string name used to anchor op-agnostic pass managers that operate generically on any viable operation. More...
 

Detailed Description

The main pass manager and pipeline builder.

Definition at line 210 of file PassManager.h.

Member Typedef Documentation

◆ ReproducerStreamFactory

using mlir::PassManager::ReproducerStreamFactory = std::function<std::unique_ptr<ReproducerStream>(std::string &error)>

Method type for constructing ReproducerStream.

Definition at line 252 of file PassManager.h.

Constructor & Destructor Documentation

◆ PassManager() [1/2]

PassManager::PassManager ( MLIRContext ctx,
Nesting  nesting = Nesting::Explicit,
StringRef  operationName = "builtin.module" 
)

Create a new pass manager under the given context with a specific nesting style.

The created pass manager can schedule operations that match operationName. FIXME: We should make the specification of builtin.module explicit here, so that we can have top-level op-agnostic pass managers.

Definition at line 772 of file Pass.cpp.

References ~PassManager().

◆ PassManager() [2/2]

mlir::PassManager::PassManager ( MLIRContext ctx,
StringRef  operationName 
)
inline

Definition at line 219 of file PassManager.h.

◆ ~PassManager()

PassManager::~PassManager ( )
default

Referenced by PassManager().

Member Function Documentation

◆ addInstrumentation()

void PassManager::addInstrumentation ( std::unique_ptr< PassInstrumentation pi)

Add the provided instrumentation to the pass manager.

Definition at line 829 of file Pass.cpp.

References mlir::PassInstrumentor::addInstrumentation().

Referenced by enableIRPrinting().

◆ enableCrashReproducerGeneration() [1/2]

void PassManager::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 failure.

outputFile is a .mlir filename used to write the generated reproducer. If genLocalReproducer is true, the pass manager will attempt to generate a local reproducer that contains the smallest pipeline.

Definition at line 409 of file PassCrashRecovery.cpp.

References mlir::openOutputFile().

Referenced by mlir::applyPassManagerCLOptions().

◆ enableCrashReproducerGeneration() [2/2]

void PassManager::enableCrashReproducerGeneration ( ReproducerStreamFactory  factory,
bool  genLocalReproducer = false 
)

Enable support for the pass manager to generate a reproducer on the event of a crash or a pass failure.

factory is used to construct the streams to write the generated reproducer to. If genLocalReproducer is true, the pass manager will attempt to generate a local reproducer that contains the smallest pipeline.

Definition at line 427 of file PassCrashRecovery.cpp.

◆ enableIRPrinting() [1/2]

void PassManager::enableIRPrinting ( std::unique_ptr< IRPrinterConfig config)

Add an instrumentation to print the IR before and after pass execution, using the provided configuration.

Definition at line 259 of file IRPrinting.cpp.

References addInstrumentation(), getContext(), and mlir::MLIRContext::isMultithreadingEnabled().

Referenced by enableIRPrinting().

◆ enableIRPrinting() [2/2]

void PassManager::enableIRPrinting ( 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,
raw_ostream &  out = llvm::errs(),
OpPrintingFlags  opPrintingFlags = OpPrintingFlags() 
)

Add an instrumentation to print the IR before and after pass execution, using the provided fields to generate a default configuration:

Add an instrumentation to print the IR before and after pass execution.

  • 'shouldPrintBeforePass' and 'shouldPrintAfterPass' correspond to filter functions that take a 'Pass *' and Operation *. These function should return true if the IR should be printed or not.
  • 'printModuleScope' signals if the module IR should be printed, even for non module passes.
  • 'printAfterOnlyOnChange' signals that when printing the IR after a pass, in the case of a non-failure, we should first check if any potential mutations were made.
  • 'printAfterOnlyOnFailure' signals that when printing the IR after a pass, we only print in the case of a failure.
    • This option should not be used with the other printAfter flags above.
  • 'out' corresponds to the stream to output the printed IR to.
  • 'opPrintingFlags' sets up the printing flags to use when printing the IR.

Definition at line 269 of file IRPrinting.cpp.

References enableIRPrinting().

◆ enableStatistics()

void PassManager::enableStatistics ( PassDisplayMode  displayMode = PassDisplayMode::Pipeline)

Prompts the pass manager to print the statistics collected for each of the held passes after each call to 'run'.

Dump the statistics for each pass after running.

Definition at line 248 of file PassStatistics.cpp.

Referenced by mlir::applyPassManagerCLOptions().

◆ enableTiming() [1/3]

void PassManager::enableTiming ( TimingScope timingScope)

Add an instrumentation to time the execution of passes and the computation of analyses.

Timing will be reported by nesting timers into the provided timingScope.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 150 of file PassTiming.cpp.

Referenced by mlir::applyDefaultTimingPassManagerCLOptions(), and performActions().

◆ enableTiming() [2/3]

void PassManager::enableTiming ( std::unique_ptr< TimingManager tm)

Add an instrumentation to time the execution of passes and the computation of analyses.

The pass manager will take ownership of the timing manager passed to the function and timing will be reported by nesting timers into the timing manager's root scope.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 158 of file PassTiming.cpp.

◆ enableTiming() [3/3]

void PassManager::enableTiming ( )

Add an instrumentation to time the execution of passes and the computation of analyses.

Creates a temporary TimingManager owned by this PassManager which will be used to report timing.

Note: Timing should be enabled after all other instrumentations to avoid any potential "ghost" timing from other instrumentations being unintentionally included in the timing results.

Definition at line 166 of file PassTiming.cpp.

◆ enableVerifier()

void PassManager::enableVerifier ( bool  enabled = true)

Runs the verifier after each individual pass.

Definition at line 780 of file Pass.cpp.

Referenced by mlir::attachPassReproducerAsmResource(), convertPDLToPDLInterp(), and performActions().

◆ getContext()

MLIRContext* mlir::PassManager::getContext ( ) const
inline

Return an instance of the context.

Definition at line 229 of file PassManager.h.

Referenced by enableIRPrinting(), and run().

◆ run()

LogicalResult PassManager::run ( Operation op)

The documentation for this class was generated from the following files: