[Mlir-commits] [mlir] [MLIR] Sprinkle extra asserts in OperationSupport.h (PR #90465)
Johannes de Fine Licht
llvmlistbot at llvm.org
Mon Apr 29 07:23:12 PDT 2024
https://github.com/definelicht updated https://github.com/llvm/llvm-project/pull/90465
>From 359e4af8c889d42c88d17513a14cf4275be8be21 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 | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index cdb75a3777ad80..6a7fda6bb4b8d0 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1037,8 +1037,11 @@ struct OperationState {
addAttribute(StringAttr::get(getContext(), name), attr);
}
- /// Add an attribute with the specified name.
+ /// Add an attribute with the specified name. 'name' and 'attr' must not be
+ /// null.
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 +1050,11 @@ struct OperationState {
attributes.append(newAttributes);
}
- void addSuccessors(Block *successor) { successors.push_back(successor); }
+ /// Adds a successor to the operation sate. 'successor' must not be null.
+ 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