[Mlir-commits] [mlir] [mlir][async] Erase op later to preserve insertion point (PR #146516)

Matthias Springer llvmlistbot at llvm.org
Tue Jul 1 05:08:19 PDT 2025


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/146516

Delay the erasure of an op, so that the insertion point of the rewriter remains valid.

This commit is in preparation of the One-Shot Dialect Conversion refactoring. (The current implementation works with the current dialect conversion driver because op erasure is delayed.)

>From 329a00b13e1a2aa762ae36b52f7ed1a67bdd85c3 Mon Sep 17 00:00:00 2001
From: Matthias Springer <me at m-sp.org>
Date: Tue, 1 Jul 2025 12:05:58 +0000
Subject: [PATCH] [mlir][async] Erase op later to preserve insertion point

Delay the erasure of an op, so that the insertion point of the rewriter remains valid.

This commit is in preparation of the One-Shot Dialect Conversion refactoring.
---
 mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
index c289faaf9983c..8601bb5aaada9 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
@@ -723,8 +723,8 @@ class YieldOpLowering : public OpConversionPattern<async::YieldOp> {
       // Switch the coroutine completion token to available state.
       rewriter.create<RuntimeSetAvailableOp>(loc, *coro.asyncToken);
 
-    rewriter.eraseOp(op);
     rewriter.create<cf::BranchOp>(loc, coro.cleanup);
+    rewriter.eraseOp(op);
 
     return success();
   }



More information about the Mlir-commits mailing list