Skip to content

[mlir][async] Erase op later to preserve insertion point #146516

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
Jul 1, 2025

Conversation

matthias-springer
Copy link
Member

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

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.
@llvmbot
Copy link
Member

llvmbot commented Jul 1, 2025

@llvm/pr-subscribers-mlir-async

@llvm/pr-subscribers-mlir

Author: Matthias Springer (matthias-springer)

Changes

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

@matthias-springer matthias-springer merged commit 569ca0f into main Jul 1, 2025
10 checks passed
@matthias-springer matthias-springer deleted the users/matthias-springer/ip_async branch July 1, 2025 15:25
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
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.)
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
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.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants