[Mlir-commits] [mlir] [mlir][gpu] Reject gpu.launch_func ops with both async dependencies and explicit async object (PR #195436)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue May 5 00:57:04 PDT 2026


https://github.com/SabYic updated https://github.com/llvm/llvm-project/pull/195436

>From fd7dd48dbb3653987ce961063d8b073f07822f75 Mon Sep 17 00:00:00 2001
From: SabYic <sunwenjia04 at 163.com>
Date: Sat, 2 May 2026 16:21:01 +0800
Subject: [PATCH] When gpu.launch_func carried both async dependencies and an
 explicit async object, GPUToLLVMConversion reused the first dependency stream
 as the primary launch stream and ignored the explicit async object. Reject
 gpu.launch_func operations that specify both async dependencies and an
 explicit async object.

This combination is invalid and should be rejected by LaunchFuncOp::verify()
rather than handled during lowering.

Add an invalid IR test and remove the obsolete lowering test for this form.

 #Changes to be committed:

 #Changes to be committed:
---
 mlir/lib/Dialect/GPU/IR/GPUDialect.cpp |  4 ++++
 mlir/test/Dialect/GPU/invalid.mlir     | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index d3fb6df2010d2..f776129c77405 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -1341,6 +1341,10 @@ LogicalResult LaunchFuncOp::verify() {
              << "expects types of the cluster dimensions must be the same";
   }
 
+  if (!getAsyncDependencies().empty() && getAsyncObject())
+    return emitOpError(
+        "cannot have both async dependencies and an explicit async object");
+
   return success();
 }
 
diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir
index bf862b2c5ae3c..76c22431a2293 100644
--- a/mlir/test/Dialect/GPU/invalid.mlir
+++ b/mlir/test/Dialect/GPU/invalid.mlir
@@ -222,6 +222,24 @@ module attributes {gpu.container_module} {
 
 // -----
 
+module attributes {gpu.container_module} {
+  gpu.module @kernels {
+    gpu.func @kernel_1() kernel {
+      gpu.return
+    }
+  }
+
+  func.func @launch_func_async_deps_and_async_object(%sz : index, %stream : !llvm.ptr) {
+    %dep = gpu.wait async
+    // expected-error at +1 {{cannot have both async dependencies and an explicit async object}}
+    %t = gpu.launch_func async [%dep] <%stream : !llvm.ptr> @kernels::@kernel_1
+        blocks in (%sz, %sz, %sz) threads in (%sz, %sz, %sz)
+    return
+  }
+}
+
+// -----
+
 module attributes {gpu.container_module} {
   gpu.module @kernels {
     gpu.func @kernel_1(%arg1 : !llvm.ptr) {



More information about the Mlir-commits mailing list