[mlir][Pass] Report error when passing options to pipelines via shorthand syntax (#185738)

When passing options to a pass pipeline that doesn't accept options,
mlir-opt exits with error code 1, but prints no error message when using
shorthand CLI syntax:

```
# Silent failure (no error message):
$ mlir-opt --tosa-to-linalg-pipeline=foo /dev/null
$ echo $?
1

# Same pipeline via --pass-pipeline syntax reports error:
$ mlir-opt --pass-pipeline='builtin.module(tosa-to-linalg-pipeline{foo})' /dev/null
<unknown>:0: error: failed to add `tosa-to-linalg-pipeline` with options `foo`
```

This PR adds replaces the silent call to `failure` with `errorHandler`
in `PassPipelineCLParser::addToPipeline`, matching the existing pattern
in `TextualPipeline::addToPipeline`.
This commit is contained in:
John Paul Jepko 2026-03-10 15:44:10 -05:00 committed by GitHub
parent 6bdd17da22
commit 3829fdb8af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -1022,7 +1022,9 @@ LogicalResult PassPipelineCLParser::addToPipeline(
for (auto &passIt : impl->passList) {
if (failed(passIt.registryEntry->addToPipeline(pm, passIt.options,
errorHandler)))
return failure();
return errorHandler("failed to add `" +
passIt.registryEntry->getPassArgument() +
"` with options `" + passIt.options + "`");
}
return success();
}

View File

@ -1,9 +1,11 @@
// RUN: not mlir-opt %s -pass-pipeline='builtin.module(builtin.module(test-module-pass{test-option=a}))' 2>&1 | FileCheck %s
// RUN: not mlir-opt %s -mlir-print-ir-module-scope -mlir-print-ir-before=cse 2>&1 | FileCheck -check-prefix=PRINT_MODULE_IR_WITH_MULTITHREAD %s
// RUN: not mlir-opt %s --tosa-to-linalg-pipeline=foo 2>&1 | FileCheck -check-prefix=SHORTHAND %s
// CHECK: <Pass-Options-Parser>: no such option test-option
// CHECK: failed to add `test-module-pass` with options `test-option=a`
// CHECK: failed to add `builtin.module` with options `` to inner pipeline
// SHORTHAND: failed to add `tosa-to-linalg-pipeline` with options `foo`
module {}
// PRINT_MODULE_IR_WITH_MULTITHREAD: IR print for module scope can't be setup on a pass-manager without disabling multi-threading first.