[Mlir-commits] [mlir] 64a5e57 - [mlir] Disable notifyMatchFailure in NDEBUG

River Riddle llvmlistbot at llvm.org
Wed Mar 18 13:27:14 PDT 2020


Author: River Riddle
Date: 2020-03-18T13:27:04-07:00
New Revision: 64a5e57a61bb6f6080236bd1e21afdf044ae810a

URL: https://github.com/llvm/llvm-project/commit/64a5e57a61bb6f6080236bd1e21afdf044ae810a
DIFF: https://github.com/llvm/llvm-project/commit/64a5e57a61bb6f6080236bd1e21afdf044ae810a.diff

LOG: [mlir] Disable notifyMatchFailure in NDEBUG

Summary: 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.

Differential Revision: https://reviews.llvm.org/D76372

Added: 
    

Modified: 
    mlir/include/mlir/IR/PatternMatch.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 9882ce933834..bab479bfbb61 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -322,10 +322,15 @@ class PatternRewriter : public OpBuilder {
   /// 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 @@ class PatternRewriter : public OpBuilder {
   /// 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.


        


More information about the Mlir-commits mailing list