aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Pass/PassRegistry.cpp
diff options
context:
space:
mode:
authorIvan Butygin <ivan.butygin@gmail.com>2024-04-02 02:43:04 +0300
committerGitHub <noreply@github.com>2024-04-02 02:43:04 +0300
commit1079fc4f543c42bb09a33d2d79d90edd9c0bac91 (patch)
tree4f66054645498489cdb9d99dca6295a44637c918 /mlir/lib/Pass/PassRegistry.cpp
parent9df19ce40281551bd348b262a131085cf98dadf5 (diff)
downloadllvm-1079fc4f543c42bb09a33d2d79d90edd9c0bac91.zip
llvm-1079fc4f543c42bb09a33d2d79d90edd9c0bac91.tar.gz
llvm-1079fc4f543c42bb09a33d2d79d90edd9c0bac91.tar.bz2
[mlir][pass] Add `errorHandler` param to `Pass::initializeOptions` (#87289)
There is no good way to report detailed errors from inside `Pass::initializeOptions` function as context may not be available at this point and writing directly to `llvm::errs()` is not composable. See https://github.com/llvm/llvm-project/pull/87166#discussion_r1546426763 * Add error handler callback to `Pass::initializeOptions` * Update `PassOptions::parseFromString` to support custom error stream instead of using `llvm::errs()` directly. * Update default `Pass::initializeOptions` implementation to propagate error string from `parseFromString` to new error handler. * Update `MapMemRefStorageClassPass` to report error details using new API.
Diffstat (limited to 'mlir/lib/Pass/PassRegistry.cpp')
-rw-r--r--mlir/lib/Pass/PassRegistry.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/mlir/lib/Pass/PassRegistry.cpp b/mlir/lib/Pass/PassRegistry.cpp
index b0c3143..f814967 100644
--- a/mlir/lib/Pass/PassRegistry.cpp
+++ b/mlir/lib/Pass/PassRegistry.cpp
@@ -40,7 +40,7 @@ buildDefaultRegistryFn(const PassAllocatorFunction &allocator) {
return [=](OpPassManager &pm, StringRef options,
function_ref<LogicalResult(const Twine &)> errorHandler) {
std::unique_ptr<Pass> pass = allocator();
- LogicalResult result = pass->initializeOptions(options);
+ LogicalResult result = pass->initializeOptions(options, errorHandler);
std::optional<StringRef> pmOpName = pm.getOpName();
std::optional<StringRef> passOpName = pass->getOpName();
@@ -280,7 +280,8 @@ parseNextArg(StringRef options) {
llvm_unreachable("unexpected control flow in pass option parsing");
}
-LogicalResult detail::PassOptions::parseFromString(StringRef options) {
+LogicalResult detail::PassOptions::parseFromString(StringRef options,
+ raw_ostream &errorStream) {
// NOTE: `options` is modified in place to always refer to the unprocessed
// part of the string.
while (!options.empty()) {
@@ -291,7 +292,7 @@ LogicalResult detail::PassOptions::parseFromString(StringRef options) {
auto it = OptionsMap.find(key);
if (it == OptionsMap.end()) {
- llvm::errs() << "<Pass-Options-Parser>: no such option " << key << "\n";
+ errorStream << "<Pass-Options-Parser>: no such option " << key << "\n";
return failure();
}
if (llvm::cl::ProvidePositionalOption(it->second, value, 0))