[PATCH] D76372: [mlir] Disable notifyMatchFailure in NDEBUG
River Riddle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 18 10:20:24 PDT 2020
rriddle created this revision.
rriddle added a reviewer: mehdi_amini.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar.
Herald added a project: LLVM.
The usage story in for NDEBUG isn't fleshed out yet, so this revision ensures that none of the diagnostic code exists in the binary.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76372
Files:
mlir/include/mlir/IR/PatternMatch.h
Index: mlir/include/mlir/IR/PatternMatch.h
===================================================================
--- mlir/include/mlir/IR/PatternMatch.h
+++ mlir/include/mlir/IR/PatternMatch.h
@@ -322,10 +322,15 @@
/// why the failure occurred. This method allows for derived rewriters to
/// optionally hook into the reason why a pattern failed, and display it to
/// users.
- virtual LogicalResult
- notifyMatchFailure(Operation *op,
- function_ref<void(Diagnostic &)> reasonCallback) {
+ template <typename CallbackT>
+ std::enable_if_t<!std::is_convertible<CallbackT, Twine>::value, LogicalResult>
+ notifyMatchFailure(Operation *op, CallbackT &&reasonCallback) {
+#ifndef NDEBUG
+ return notifyMatchFailure(op,
+ function_ref<void(Diagnostic &)>(reasonCallback));
+#else
return failure();
+#endif
}
LogicalResult notifyMatchFailure(Operation *op, const Twine &msg) {
return notifyMatchFailure(op, [&](Diagnostic &diag) { diag << msg; });
@@ -351,6 +356,17 @@
/// uses.
virtual void notifyOperationRemoved(Operation *op) {}
+ /// Notify the pattern rewriter that the pattern is failing to match the given
+ /// operation, and provide a callback to populate a diagnostic with the reason
+ /// why the failure occurred. This method allows for derived rewriters to
+ /// optionally hook into the reason why a pattern failed, and display it to
+ /// users.
+ virtual LogicalResult
+ notifyMatchFailure(Operation *op,
+ function_ref<void(Diagnostic &)> reasonCallback) {
+ return failure();
+ }
+
private:
/// 'op' and 'newOp' are known to have the same number of results, replace the
/// uses of op with uses of newOp.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76372.251127.patch
Type: text/x-patch
Size: 1745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200318/e12915f3/attachment.bin>
More information about the llvm-commits
mailing list