[Mlir-commits] [mlir] [mlir][IR] Insert operations before `SingleBlock`'s terminator (PR #65959)
Mehdi Amini
llvmlistbot at llvm.org
Mon Sep 18 01:22:57 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());
----------------
joker-eph wrote:
It's not clear to me that it'll fix it: if you can't be sure if the last op is a terminator or not, I don't quite see how you can decide to insert before or after it?
https://github.com/llvm/llvm-project/pull/65959
More information about the Mlir-commits
mailing list