[Mlir-commits] [mlir] MLIR Rewriters: add new listener to emit match failures to user, enhance docs (PR #94130)
Matthias Springer
llvmlistbot at llvm.org
Tue Jun 4 00:44:06 PDT 2024
================
@@ -1620,6 +1620,8 @@ void ConversionPatternRewriterImpl::notifyMatchFailure(
if (config.notifyCallback)
config.notifyCallback(diag);
});
+ if (config.listener)
+ config.listener->notifyMatchFailure(loc, reasonCallback);
----------------
matthias-springer wrote:
> This is already done in greedy rewriter, as added by @matthias-springer (who seems to agree with me on the goals of this PR):
I have to admit I didn't think much about `notifyMatchFailure` when I added listener support to the greedy pattern rewrite driver. I just forwarded all notifications to the listener.
> I disagree that match failure should be eliminated from a release build. For example, in my use case, we use notifyMatchFailure on patterns that we must run to support conversions that lower from higher-level to lower-level dialects. I consider a failure to match a required lowering pattern as something more helpful to the user than just emitting "failure to legalize operation explicitly marked illegal".
So the use case here is to produce better error messages. What happens after a "required pattern" reports a match failure? Sending the error message via the listener seems a bit convoluted. Could you directly `op->emitError()` and `return failure()` in the pattern?
https://github.com/llvm/llvm-project/pull/94130
More information about the Mlir-commits
mailing list