Skip to content

Conversation

victor-eds
Copy link
Contributor

Instead of checking whether the last operation might be a terminator, always insert operations to the end 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 <[email protected]>
@victor-eds victor-eds self-assigned this Sep 18, 2023
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Sep 18, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Changes

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


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

1 Files Affected:

  • (modified) mlir/include/mlir/IR/OpDefinition.h (-4)
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);
   }
 };

@victor-eds
Copy link
Contributor Author

Renaming hasTerminator will be part of a follow-up patch to separate concerns here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants