[Mlir-commits] [mlir] [mlir][GPU] Fix GPU_Launch op non-empty body region (PR #181318)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Feb 12 22:53:20 PST 2026
https://github.com/woruyu created https://github.com/llvm/llvm-project/pull/181318
### Summary
This PR fix GPU_Launch op non-empty body region.
>From da78003795c874611e2e7dff5964b185b1a043d6 Mon Sep 17 00:00:00 2001
From: woruyu <1214539920 at qq.com>
Date: Fri, 13 Feb 2026 14:52:04 +0800
Subject: [PATCH] [mlir][GPU] Fix GPU_Launch op non-empty body region
---
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 4 +++-
mlir/test/Dialect/GPU/invalid.mlir | 9 +++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index 5953553ae0df0..4d6a6e7acf408 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -892,7 +892,9 @@ LogicalResult LaunchOp::verifyRegions() {
// Kernel launch takes kNumConfigOperands leading operands for grid/block
// sizes and transforms them into kNumConfigRegionAttributes region arguments
// for block/thread identifiers and grid/block sizes.
- if (!getBody().empty()) {
+ if (getBody().empty()) {
+ return emitOpError("expected a non-empty body region");
+ } else {
if (getBody().getNumArguments() <
kNumConfigRegionAttributes + getNumWorkgroupAttributions())
return emitOpError("unexpected number of region arguments");
diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir
index 7c678e4f34d3d..6797988e2e678 100644
--- a/mlir/test/Dialect/GPU/invalid.mlir
+++ b/mlir/test/Dialect/GPU/invalid.mlir
@@ -10,6 +10,15 @@ func.func @not_enough_sizes(%sz : index) {
// -----
+func.func @not_empty_body(%sz : index) {
+ // expected-error at +1 {{expected a non-empty body region}}
+ "gpu.launch"(%sz, %sz, %sz, %sz, %sz, %sz) ({
+ }) {operandSegmentSizes = array<i32: 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0>}: (index, index, index, index, index, index) -> ()
+ return
+}
+
+// -----
+
func.func @no_region_attrs(%sz : index) {
// expected-error at +1 {{unexpected number of region arguments}}
"gpu.launch"(%sz, %sz, %sz, %sz, %sz, %sz) ({
More information about the Mlir-commits
mailing list