<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58771>58771</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] Improve pass pipeline parsing error messages
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rkayaith
      </td>
    </tr>
</table>

<pre>
    The errors when parsing pipelines has some inconsistent/weird formatting, e.g.:
```console
$ echo | mlir-opt -pass-pipeline='cse'
<unknown>:0: error: expected pass pipeline to be wrapped with the anchor operation type, e.g. 'builtin.module(...)'

$ echo | mlir-opt -pass-pipeline='builtin.module(func.func(invalid))'
<unknown>:0: error: MLIR Textual PassPipeline Parser:1:11: error: 'invalid' does not refer to a registered pass or pass pipeline
func.func(invalid)
          ^
```
The `<unknown>` location is odd, `MLIR Textual PassPipeline Parser` just adds noise, and in the second error only part of the pipeline is actually shown in the message. The error should probably look more like:
```
mlir-opt: error: 'invalid' does not refer to a registered pass or pass pipeline:
builtin.module(func.func(invalid))
                         ^
```

The message is also returned by the the [C](https://github.com/llvm/llvm-project/blob/001d18664f8bcf63af64f10688809f7681dfbf0b/mlir/test/CAPI/pass.c#L246) and [python](https://github.com/llvm/llvm-project/blob/001d18664f8bcf63af64f10688809f7681dfbf0b/mlir/test/python/pass_manager.py#L58-L62) API, so should consider how it looks there as well.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVF1vnDgU_TXwYg0yMBjmgYfspJUiZaWo6ntl48vgxtjINpnOv99rGCZKqqqNVGkRxjb-uOece2xh5aX9OgAB56zz5DyAIRN3XpkTmdQEWhnwZOCeeDsCUaazxisfwISk-HwG5STprRt5CLgkKY4EslOWlHcJvU_oXcLo-sZlVsP1b7En0A2WJPWRjFq5nZ0C2U3c-90WNCnvk6LuPOD3uqo8zubZ2LNJyk8YgWJ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