[Mlir-commits] [mlir] [MLIR] Sprinkle extra asserts in OperationSupport.h (PR #90465)

Johannes de Fine Licht llvmlistbot at llvm.org
Mon Apr 29 06:07:39 PDT 2024


https://github.com/definelicht created https://github.com/llvm/llvm-project/pull/90465

Should hopefully help shave some minutes off developer debugging time in the future.

>From 169f80705288ee61221af2cc07046ef75dc010fd Mon Sep 17 00:00:00 2001
From: Johannes de Fine Licht <johannes.definelicht at nextsilicon.com>
Date: Mon, 29 Apr 2024 13:01:19 +0000
Subject: [PATCH] [MLIR] Sprinkle extra asserts in OperationSupport.h.

Should hopefully help shave some minutes off developer debugging time in
the future.
---
 mlir/include/mlir/IR/OperationSupport.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index cdb75a3777ad80..b3c3401d51b506 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1039,6 +1039,8 @@ struct OperationState {
 
   /// Add an attribute with the specified name.
   void addAttribute(StringAttr name, Attribute attr) {
+    assert(name && "attribute name cannot be null");
+    assert(attr && "attribute cannot be null");
     attributes.append(name, attr);
   }
 
@@ -1047,7 +1049,10 @@ struct OperationState {
     attributes.append(newAttributes);
   }
 
-  void addSuccessors(Block *successor) { successors.push_back(successor); }
+  void addSuccessors(Block *successor) {
+    assert(successor && "successor cannot be null");
+    successors.push_back(successor);
+  }
   void addSuccessors(BlockRange newSuccessors);
 
   /// Create a region that should be attached to the operation.  These regions



More information about the Mlir-commits mailing list