This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Add a hook to PatternRewriter to allow for patterns to notify why a match failed.
ClosedPublic

Authored by rriddle on Mar 15 2020, 2:17 PM.

Details

Summary

This revision adds a new hook, notifyMatchFailure, that allows for notifying the rewriter that a match failure is coming with the provided reason. This hook takes as a parameter a callback that fills a Diagnostic instance with the reason why the match failed. This allows for the rewriter to decide how this information can be displayed to the end-user, and may completely ignore it if desired(opt mode). For now, DialectConversion is updated to include this information in the debug output.

Depends On D76202

Diff Detail

Event Timeline

rriddle created this revision.Mar 15 2020, 2:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2020, 2:17 PM
flaub added a subscriber: flaub.Mar 15 2020, 8:41 PM
jpienaar added inline comments.Mar 16 2020, 11:34 AM
mlir/lib/Transforms/DialectConversion.cpp
996

Is a match failing really an error?

rriddle updated this revision to Diff 250623.Mar 16 2020, 1:31 PM

Resolve comments

rriddle marked 2 inline comments as done.Mar 16 2020, 1:32 PM
rriddle added inline comments.
mlir/lib/Transforms/DialectConversion.cpp
996

Changed to Remark. Given that we don't include the severity in the message here, it doesn't matter what it gets set to.

jpienaar accepted this revision.Mar 17 2020, 7:42 AM

Looks good, then we can generate mismatch messages from DRR and resolve a long open FR :-)

This revision is now accepted and ready to land.Mar 17 2020, 7:42 AM
This revision was automatically updated to reflect the committed changes.
rriddle marked an inline comment as done.
mehdi_amini added inline comments.Mar 17 2020, 10:40 PM
mlir/lib/Transforms/DialectConversion.cpp
1001

If this was in a header, we could try to rely on inlining to make it purely zero cost in release mode at call-sites by eliminating all the debug strings. Right now they would still be in the binary I think (LTO may help). Have you looked into this possibility?

jbcoe added a reviewer: jbcoe.Dec 14 2021, 8:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 14 2021, 8:54 AM