llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
25.95k stars 10.59k forks source link

[MLIR] Sprinkle extra asserts in OperationSupport.h #90465

Closed definelicht closed 2 weeks ago

definelicht commented 2 weeks ago

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

llvmbot commented 2 weeks ago

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Johannes de Fine Licht (definelicht)

Changes Should hopefully help shave some minutes off developer debugging time in the future. --- Full diff: https://github.com/llvm/llvm-project/pull/90465.diff 1 Files Affected: - (modified) mlir/include/mlir/IR/OperationSupport.h (+6-1) ``````````diff 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 ``````````