diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h index 4b50a0aec945c..3d00c405ead37 100644 --- a/mlir/include/mlir/IR/Block.h +++ b/mlir/include/mlir/IR/Block.h @@ -211,11 +211,11 @@ class Block : public IRObjectWithUseList, //===--------------------------------------------------------------------===// /// Get the terminator operation of this block. This function asserts that - /// the block has a valid terminator operation. + /// the block might have a valid terminator operation. Operation *getTerminator(); - /// Check whether this block has a terminator. - bool hasTerminator(); + /// Check whether this block might have a terminator. + bool mightHaveTerminator(); //===--------------------------------------------------------------------===// // Predecessors and successors. diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp index dc004cd14dc0f..23284e14461d8 100644 --- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp @@ -2188,7 +2188,7 @@ LogicalResult transform::SequenceOp::verify() { } } - if (!getBodyBlock()->hasTerminator()) + if (!getBodyBlock()->mightHaveTerminator()) return emitOpError() << "expects to have a terminator in the body"; if (getBodyBlock()->getTerminator()->getOperandTypes() != diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 029864d9ea47b..82ea303cf0171 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -234,14 +234,14 @@ void Block::eraseArguments(function_ref shouldEraseFn) { //===----------------------------------------------------------------------===// /// Get the terminator operation of this block. This function asserts that -/// the block has a valid terminator operation. +/// the block might have a valid terminator operation. Operation *Block::getTerminator() { - assert(hasTerminator()); + assert(mightHaveTerminator()); return &back(); } -/// Check whether this block has a terminator. -bool Block::hasTerminator() { +/// Check whether this block might have a terminator. +bool Block::mightHaveTerminator() { return !empty() && back().mightHaveTrait(); }