[Mlir-commits] [mlir] [mlir][IR] Insert operations before `SingleBlock`'s terminator (PR #65959)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Sep 18 01:35:01 PDT 2023
================
@@ -932,6 +932,10 @@ 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());
----------------
victor-eds wrote:
So do you guys think we should just be consistent with `vector::push_back` semantics and just blame the API user if the code is broken? I'm fine with that, just wanted to keep former semantics.
https://github.com/llvm/llvm-project/pull/65959
More information about the Mlir-commits
mailing list