[Mlir-commits] [mlir] [IR] `SingleBlock::push_back` operations to the back of the block (PR #66655)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 18 07:58:16 PDT 2023


https://github.com/victor-eds created https://github.com/llvm/llvm-project/pull/66655

Instead of checking whether the last operation might be a terminator, always insert operations to the end of the block.

>From 0af88dd531bee6b1727dec88135aeab7d6c1f6ee Mon Sep 17 00:00:00 2001
From: Victor Perez <victor.perez at codeplay.com>
Date: Mon, 18 Sep 2023 14:32:14 +0100
Subject: [PATCH] [IR] `SingleBlock::push_back` operations to the back of the
 block

Instead of checking whether the last operation might be a terminator,
always insert operations to the end of the block.

Signed-off-by: Victor Perez <victor.perez at codeplay.com>
---
 mlir/include/mlir/IR/OpDefinition.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 306b3789a044f83..82d0e93a8ee2fa9 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -932,10 +932,6 @@ struct SingleBlock : public TraitBase<ConcreteType, SingleBlock> {
   }
   template <typename OpT = ConcreteType>
   enable_if_single_region<OpT> insert(Block::iterator insertPt, Operation *op) {
-    Block *body = getBody();
-    // Insert op before the block's terminator if it has one
-    if (insertPt == body->end() && body->hasTerminator())
-      insertPt = Block::iterator(body->getTerminator());
     getBody()->getOperations().insert(insertPt, op);
   }
 };



More information about the Mlir-commits mailing list