[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:58 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: woruyu (woruyu)
<details>
<summary>Changes</summary>
### Summary
This PR fix GPU_Launch op non-empty body region.
---
Full diff: https://github.com/llvm/llvm-project/pull/181318.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/GPU/IR/GPUDialect.cpp (+3-1)
- (modified) mlir/test/Dialect/GPU/invalid.mlir (+9)
``````````diff
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) ({
``````````
</details>
https://github.com/llvm/llvm-project/pull/181318
More information about the Mlir-commits
mailing list