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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Jul 1 05:08:48 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

<details>
<summary>Changes</summary>

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.)

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


1 Files Affected:

- (modified) mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp (+1-1) 


``````````diff
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();
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/146516


More information about the Mlir-commits mailing list