[Mlir-commits] [mlir] [mlir][Pass] Add new FileTreeIRPrinterConfig (PR #67840)

Mehdi Amini llvmlistbot at llvm.org
Mon Oct 2 14:37:02 PDT 2023


================
@@ -381,6 +381,42 @@ class PassManager : public OpPassManager {
       bool printAfterOnlyOnFailure = false, raw_ostream &out = llvm::errs(),
       OpPrintingFlags opPrintingFlags = OpPrintingFlags());
 
+  /// Similar to `enableIRPrinting` above, except that instead of printing
+  /// the IR to a single output stream, the instrumentation will print the
+  /// output of each pass to a separate file. The files will be organized into a
+  /// directory tree rooted at `printTreeDir`. The directories mirror 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)))", and
+  /// `printTreeDir=/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
+  /// │   ├── func_func_my_func_name
+  /// │   │   ├── 2_pass3.mlir
+  /// │   │   ├── 3_pass4.mlir
+  /// │   ├── func_func_my_other_func_name
+  /// │   │   ├── 4_pass3.mlir
+  /// │   │   ├── 5_pass4.mlir
----------------
joker-eph wrote:

```suggestion
  /// │   ├── func_func_my_func_name
  /// │   │   ├── 2_passA.mlir
  /// │   │   ├── 5_passB.mlir
  /// │   ├── func_func_my_other_func_name
  /// │   │   ├── 3_passA.mlir
  /// │   │   ├── 4_passB.mlir
```

Use names instead of numbers for the passes.

Also I'd use counter that aren't in sequence to illustrate that parallelism makes this non-deterministic.
And by the way, that seems kind of an issue, I wonder if we could do better, for example prefix instead:

```
├── builtin_module_the_symbol_name
   /// │   ├── 0_pass1.mlir
   /// │   ├── 1_pass2.mlir
   /// │   ├── func_func_my_func_name
   /// │   │   ├── 0_1_pass3.mlir
   /// │   │   ├── 0_2_pass4.mlir
   /// │   ├── func_func_my_other_func_name
   /// │   │   ├── 1_1_pass3.mlir
   /// │   │   ├── 1_2_pass4.mlir
```

That is every time we get into a new nesting we prepend with a prefix that is the operation position in the parent (here `0` and `1` for each function) and restart with a local counter instead of a shared one.


https://github.com/llvm/llvm-project/pull/67840


More information about the Mlir-commits mailing list