diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -997,6 +997,8 @@ /// Verifies the body of the function. LogicalResult GPUFuncOp::verifyBody() { + if (empty()) + return emitOpError() << "expected body with at least one block"; unsigned numFuncArguments = getNumArguments(); unsigned numWorkgroupAttributions = getNumWorkgroupAttributions(); unsigned numBlockArguments = front().getNumArguments(); diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir --- a/mlir/test/Dialect/GPU/invalid.mlir +++ b/mlir/test/Dialect/GPU/invalid.mlir @@ -421,6 +421,15 @@ // ----- +module { + gpu.module @gpu_funcs { + // expected-error @+1 {{expected body with at least one block}} + "gpu.func"() ({}) {function_type = () -> (), gpu.kernel, sym_name = "kernel"} : () -> () + } +} + +// ----- + func.func @sync_wait_with_result() { // expected-error @+1 {{cannot name an operation with no results}} %t = gpu.wait