[Mlir-commits] [mlir] [MLIR][IR] Drop `Block::hasTerminator()` (PR #66870)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Sep 20 01:12:47 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

<details>
<summary>Changes</summary>

This `Block` member function introduced in 87d77d3cfb5049b3b3714f95b2e48bbc78d8c5f9 may be misleading to users as the last operation in the block might have not been registered, so there would be no way to ensure that is a terminator. As this also adds little to no value, this commit removes that function.

---
Full diff: https://github.com/llvm/llvm-project/pull/66870.diff


2 Files Affected:

- (modified) mlir/include/mlir/IR/Block.h (-3) 
- (modified) mlir/lib/IR/Block.cpp (+1-6) 


``````````diff
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 4b50a0aec945c65..eb56290fbe77180 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -214,9 +214,6 @@ class Block : public IRObjectWithUseList<BlockOperand>,
   /// the block has a valid terminator operation.
   Operation *getTerminator();
 
-  /// Check whether this block has a terminator.
-  bool hasTerminator();
-
   //===--------------------------------------------------------------------===//
   // Predecessors and successors.
   //===--------------------------------------------------------------------===//
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index 029864d9ea47b98..fbbba96468a2a19 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -236,15 +236,10 @@ void Block::eraseArguments(function_ref<bool(BlockArgument)> shouldEraseFn) {
 /// Get the terminator operation of this block. This function asserts that
 /// the block has a valid terminator operation.
 Operation *Block::getTerminator() {
-  assert(hasTerminator());
+  assert(!empty() && back().mightHaveTrait<OpTrait::IsTerminator>());
   return &back();
 }
 
-/// Check whether this block has a terminator.
-bool Block::hasTerminator() {
-  return !empty() && back().mightHaveTrait<OpTrait::IsTerminator>();
-}
-
 // Indexed successor access.
 unsigned Block::getNumSuccessors() {
   return empty() ? 0 : back().getNumSuccessors();

``````````

</details>


https://github.com/llvm/llvm-project/pull/66870


More information about the Mlir-commits mailing list