[Mlir-commits] [mlir] 5fd2b3a - [mlir] Add error message when failing to add pass
Jacques Pienaar
llvmlistbot at llvm.org
Tue Dec 29 14:20:34 PST 2020
Author: Jacques Pienaar
Date: 2020-12-29T14:20:19-08:00
New Revision: 5fd2b3a1246fee0ce1613931fcf1ed51412a6b3f
URL: https://github.com/llvm/llvm-project/commit/5fd2b3a1246fee0ce1613931fcf1ed51412a6b3f
DIFF: https://github.com/llvm/llvm-project/commit/5fd2b3a1246fee0ce1613931fcf1ed51412a6b3f.diff
LOG: [mlir] Add error message when failing to add pass
Ran into failure without any error message previously here.
Differential Revision: https://reviews.llvm.org/D93910
Added:
mlir/test/Pass/invalid-pass.mlir
Modified:
mlir/lib/Pass/PassRegistry.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index f41ca72d7838..091fee5fcd9b 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -452,12 +452,15 @@ LogicalResult TextualPipeline::addToPipeline(
function_ref<LogicalResult(const Twine &)> errorHandler) const {
for (auto &elt : elements) {
if (elt.registryEntry) {
- if (failed(
- elt.registryEntry->addToPipeline(pm, elt.options, errorHandler)))
- return failure();
+ if (failed(elt.registryEntry->addToPipeline(pm, elt.options,
+ errorHandler))) {
+ return errorHandler("failed to add `" + elt.name + "` with options `" +
+ elt.options + "`");
+ }
} else if (failed(addToPipeline(elt.innerPipeline, pm.nest(elt.name),
errorHandler))) {
- return failure();
+ return errorHandler("failed to add `" + elt.name + "` with options `" +
+ elt.options + "` to inner pipeline");
}
}
return success();
diff --git a/mlir/test/Pass/invalid-pass.mlir b/mlir/test/Pass/invalid-pass.mlir
new file mode 100644
index 000000000000..2453b8d99ec9
--- /dev/null
+++ b/mlir/test/Pass/invalid-pass.mlir
@@ -0,0 +1,6 @@
+// RUN: not mlir-opt %s -pass-pipeline='module(test-module-pass{test-option=a})' 2>&1 | FileCheck %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 `module` with options `` to inner pipeline
+module {}
More information about the Mlir-commits
mailing list