Skip to content

[IR] SingleBlock::push_back operations to the back of the block #66655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023

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