summaryrefslogtreecommitdiff
path: root/mlir/lib/Pass/PassManagerOptions.cpp
AgeCommit message (Collapse)Author
2025-06-20[MLIR] Print more user-friendly error message when generating local ↵Artemiy Bulavin
reproducer and threading is enabled (#144905)
2024-08-01Add a tutorial on mlir-opt (#96105)Jeremy Kun
This tutorial gives an introduction to the `mlir-opt` tool, focusing on how to run basic passes with and without options, run pass pipelines from the CLI, and point out particularly useful flags. --------- Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com> Co-authored-by: Mehdi Amini <joker.eph@gmail.com>
2024-05-24[mlir][Pass] Add new FileTreeIRPrinterConfig (#67840)Christopher Bate
This change expands the existing instrumentation that prints the IR before/after each pass to an output stream (usually stderr). It adds a new configuration that will print the output of each pass to a separate file. The files will be organized into a directory tree rooted at a specified directory. For existing tools, a CL option `-mlir-print-ir-tree-dir` is added to specify this directory and activate the new printing config. The created directory tree mirrors the nesting structure of the IR. For example, if the IR is congruent to the pass-pipeline "builtin.module(pass1,pass2,func.func(pass3,pass4),pass5)", and `-mlir-print-ir-tree-dir=/tmp/pipeline_output`, then then the tree file tree created will look like: ``` /tmp/pass_output ├── builtin_module_the_symbol_name │ ├── 0_pass1.mlir │ ├── 1_pass2.mlir │ ├── 2_pass5.mlir │ ├── func_func_my_func_name │ │ ├── 1_0_pass3.mlir │ │ ├── 1_1_pass4.mlir │ ├── func_func_my_other_func_name │ │ ├── 1_0_pass3.mlir │ │ ├── 1_1_pass4.mlir ``` The subdirectories are named by concatenating the relevant parent operation names and symbol name (if present). The printer keeps a counter associated with ops that are targeted by passes and their isolated-from-above parents. Each filename is given a numeric prefix using the counter value for the op that the pass is targeting and then prepending the counter values for each parent. This gives a naming where it is easy to distinguish which passes may have run concurrently vs. which have a clear ordering. In the above example, for both `1_1_pass4.mlir` files, the first `1` refers to the counter for the parent op, and the second refers to the counter for the respective function.
2023-04-02[mlir] Catch the case using ir print without disabling multithreadKai Sasaki
-mlir-print-ir-module-scope option cannot be used without disabling multithread for pass manager. For the usability, we can throw a validation error in mlir-opt instead of assertion failure. Issue: https://github.com/llvm/llvm-project/issues/61578 Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D146785
2022-04-17Revert "[MLIR] Provide a way to print ops in custom form on pass failure"Mehdi Amini
This reverts commit daabcf5f04bbd13ac53f76ca3cc43b0d1ef64f5a. This patch still had on-going discussion that should be closed before committing.
2022-04-17[MLIR] Provide a way to print ops in custom form on pass failureUday Bondhugula
The generic form of the op is too verbose and in some cases not readable. On pass failure, ops have been so far printed in generic form to provide a (stronger) guarantee that the IR print succeeds. However, in a large number of pass failure cases, the IR is still valid and the custom printers for the ops will succeed. In fact, readability is highly desirable post pass failure. This revision provides an option to print ops in their custom/pretty-printed form on IR failure -- this option is unsafe and there is no guarantee it will succeed. It's disabled by default and can be turned on only if needed. Differential Revision: https://reviews.llvm.org/D123893
2022-04-12[mlir] Prefix pass manager options with `mlir-`Andrzej Warzynski
With this change, there's going to be a clear distinction between LLVM and MLIR pass maanger options (e.g. `-mlir-print-after-all` vs `-print-after-all`). This change is desirable from the point of view of projects that depend on both LLVM and MLIR, e.g. Flang. For consistency, all pass manager options in MLIR are prefixed with `mlir-`, even options that don't have equivalents in LLVM . Differential Revision: https://reviews.llvm.org/D123495
2021-12-08Adjust "end namespace" comment in MLIR to match new agree'd coding styleMehdi Amini
See D115115 and this mailing list discussion: https://lists.llvm.org/pipermail/llvm-dev/2021-December/154199.html Differential Revision: https://reviews.llvm.org/D115309
2021-05-19[mlir] Add a new `print-ir-after-failure` IR pass printing flagRiver Riddle
This flag will print the IR after a pass only in the case where the pass failed. This can be useful to more easily view the invalid IR, without needing to print after every pass in the pipeline. Differential Revision: https://reviews.llvm.org/D101853
2021-05-12[MLIR] Factor pass timing out into a dedicated timing managerFabian Schuiki
This factors out the pass timing code into a separate `TimingManager` that can be plugged into the `PassManager` from the outside. Users are able to provide their own implementation of this manager, and use it to time additional code paths outside of the pass manager. Also allows for multiple `PassManager`s to run and contribute to a single timing report. More specifically, moves most of the existing infrastructure in `Pass/PassTiming.cpp` into a new `Support/Timing.cpp` file and adds a public interface in `Support/Timing.h`. The `PassTiming` instrumentation becomes a wrapper around the new timing infrastructure which adapts the instrumentation callbacks to the new timers. Reviewed By: rriddle, lattner Differential Revision: https://reviews.llvm.org/D100647
2020-12-15[mlir][Pass] Add a new PassNameCLParser specifically for parsing lists of ↵River Riddle
pass names This parser does not include the general `pass_pipeline` option, the pass pipeline entries, or the options of pass entries. This is useful for cases such as `print-ir-after` that just want the user to select specific pass types. This revision greatly reduces the amount of text in --help for several MLIR based tools. Fixes PR#45495 Differential Revision: https://reviews.llvm.org/D92987
2020-12-03[mlir][Pass] Remove the restriction that PassManager can only run on ModuleOpRiver Riddle
This was a somewhat important restriction in the past when ModuleOp was distinctly the top-level container operation, as well as before the pass manager had support for running nested pass managers natively. With these two issues fading away, there isn't really a good reason to enforce that a ModuleOp is the thing running within a pass manager. As such, this revision removes the restriction and allows for users to pass in the name of the operation that the pass manager will be scheduled on. The only remaining dependency on BuiltinOps from Pass after this revision is due to FunctionPass, which will be resolved in a followup revision. Differential Revision: https://reviews.llvm.org/D92450
2020-05-02[mlir] Add a new context flag for disabling/enabling multi-threadingRiver Riddle
This is useful for several reasons: * In some situations the user can guarantee that thread-safety isn't necessary and don't want to pay the cost of synchronization, e.g., when parsing a very large module. * For things like logging threading is not desirable as the output is not guaranteed to be in stable order. This flag also subsumes the pass manager flag for multi-threading. Differential Revision: https://reviews.llvm.org/D79266
2020-04-29[mlir][Pass] Add support for generating local crash reproducersRiver Riddle
This revision adds a mode to the crash reproducer generator to attempt to generate a more local reproducer. This will attempt to generate a reproducer right before the offending pass that fails. This is useful for the majority of failures that are specific to a single pass, and situations where some passes in the pipeline are not registered with a specific tool. Differential Revision: https://reviews.llvm.org/D78314
2020-04-28Make MLIR Pass Timing output configurable through injectionMehdi Amini
This makes it possible for the client to control where the pass timings will be printed. Differential Revision: https://reviews.llvm.org/D78891
2020-04-11[mlir][IR] Manually register command line options for MLIRContext and AsmPrinterRiver Riddle
Summary: This revision makes the registration of command line options for these two files manual with `registerMLIRContextCLOptions` and `registerAsmPrinterCLOptions` methods. This removes the last remaining static constructors within lib/. Differential Revision: https://reviews.llvm.org/D77960
2020-01-26Mass update the MLIR license header to mention "Part of the LLVM project"Mehdi Amini
This is an artifact from merging MLIR into LLVM, the file headers are now aligned with the rest of the project.
2019-12-23Adjust License.txt file to use the LLVM licenseMehdi Amini
PiperOrigin-RevId: 286906740
2019-12-18NFC: Remove unnecessary 'llvm::' prefix from uses of llvm symbols declared ↵River Riddle
in `mlir` namespace. Aside from being cleaner, this also makes the codebase more consistent. PiperOrigin-RevId: 286206974
2019-12-06Add a flag to the IRPrinter instrumentation to only print after a pass if ↵River Riddle
there is a change to the IR. This adds an additional filtering mode for printing after a pass that checks to see if the pass actually changed the IR before printing it. This "change" detection is implemented using a SHA1 hash of the current operation and its children. PiperOrigin-RevId: 284291089
2019-12-05Refactor the IRPrinting instrumentation to take a derivable config.River Riddle
This allows for more interesting behavior from users, e.g. enabling the ability to dump the IR to a separate file for each pass invocation. PiperOrigin-RevId: 284059447
2019-12-05Add support for instance specific pass statistics.River Riddle
Statistics are a way to keep track of what the compiler is doing and how effective various optimizations are. It is useful to see what optimizations are contributing to making a particular program run faster. Pass-instance specific statistics take this even further as you can see the effect of placing a particular pass at specific places within the pass pipeline, e.g. they could help answer questions like "what happens if I run CSE again here". Statistics can be added to a pass by simply adding members of type 'Pass::Statistics'. This class takes as a constructor arguments: the parent pass pointer, a name, and a description. Statistics can be dumped by the pass manager in a similar manner to how pass timing information is dumped, i.e. via PassManager::enableStatistics programmatically; or -pass-statistics and -pass-statistics-display via the command line pass manager options. Below is an example: struct MyPass : public OperationPass<MyPass> { Statistic testStat{this, "testStat", "A test statistic"}; void runOnOperation() { ... ++testStat; ... } }; $ mlir-opt -pass-pipeline='func(my-pass,my-pass)' foo.mlir -pass-statistics Pipeline Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== 'func' Pipeline MyPass (S) 15 testStat - A test statistic MyPass (S) 6 testStat - A test statistic List Display: ===-------------------------------------------------------------------------=== ... Pass statistics report ... ===-------------------------------------------------------------------------=== MyPass (S) 21 testStat - A test statistic PiperOrigin-RevId: 284022014
2019-10-10Add support for generating reproducers on pass crash and failure.River Riddle
This cl adds support for generating a .mlir file containing a reproducer for crashes and failures that happen during pass execution. The reproducer contains a comment detailing the configuration of the pass manager(e.g. the textual description of the pass pipeline that the pass manager was executing), along with the original input module. Example Output: // configuration: -pass-pipeline='func(cse, canonicalize), inline' // note: verifyPasses=false module { ... } PiperOrigin-RevId: 274088134
2019-10-10NFC: Initialize pass manager option fields inline instead of the class ↵River Riddle
constructor. PiperOrigin-RevId: 274087577
2019-09-14Update the IRPrinter instrumentation to work on non function/module operations.River Riddle
This is necessary now that the pass manager may work on different types of operations. PiperOrigin-RevId: 269139669
2019-09-13Refactor pass pipeline command line parsing to support explicit pipeline ↵River Riddle
strings. This allows for explicitly specifying the pipeline to add to the pass manager. This includes the nesting structure, as well as the passes/pipelines to run. A textual pipeline string is defined as a series of names, each of which may in itself recursively contain a nested pipeline description. A name is either the name of a registered pass, or pass pipeline, (e.g. "cse") or the name of an operation type (e.g. "func"). For example, the following pipeline: $ mlir-opt foo.mlir -cse -canonicalize -lower-to-llvm Could now be specified as: $ mlir-opt foo.mlir -pass-pipeline='func(cse, canonicalize), lower-to-llvm' This will allow for running pipelines on nested operations, like say spirv modules. This does not remove any of the current functionality, and in fact can be used in unison. The new option is available via 'pass-pipeline'. PiperOrigin-RevId: 268954279
2019-07-08NFC: Make the 'disable-pass-threading' flag a PassManagerOption.River Riddle
This also adds the ability to programmatically disable threading. PiperOrigin-RevId: 257051809
2019-03-29Moving the IR printing and execution timing options out of mlir-opt and into ↵River Riddle
lib/Pass. We now expose two methods: registerPassManagerCLOptions and applyPassManagerCLOptions; to allow for multiple different users (mlir-opt, etc.) to opt-in to this common functionality. PiperOrigin-RevId: 238836911