[Mlir-commits] [mlir] [mlir][GPUToNVVM] Fix memref function args/results (PR #96392)

Guray Ozen llvmlistbot at llvm.org
Sat Jun 22 08:04:48 PDT 2024


================
@@ -679,6 +680,28 @@ gpu.module @gpumodule {
 }
 
 
+gpu.module @test_module_34 {
+  // CHECK-LABEL: llvm.func @memref_signature(
+  //  CHECK-SAME:     %{{.*}}: !llvm.ptr, %{{.*}}: !llvm.ptr, %{{.*}}: i64, %{{.*}}: i64, %{{.*}}: i64, %{{.*}}: f32) -> !llvm.struct<(struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>, f32)>
+  //       CHECK:   llvm.mlir.undef
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.mlir.undef
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.insertvalue
+  //       CHECK:   llvm.return
+
+  // CHECK-BARE-LABEL: llvm.func @memref_signature(
+  //  CHECK-BARE-SAME:     %{{.*}}: !llvm.ptr, %{{.*}}: f32) -> !llvm.struct<(ptr, f32)>
+  gpu.func @memref_signature(%m: memref<2xf32>, %f: f32) -> (memref<2xf32>, f32) {
+    gpu.return %m, %f : memref<2xf32>, f32
----------------
grypp wrote:

This example is nice. I think here gpu.func is a regular device function, so it can return. However, a GPU kernel cannot return anything. For nvidia, we differentiate kernel when nvvm.kernel attribute is present. I'm not sure how does it work for other models. 
Does it make sense to add a verifier for that? What do you think?

https://github.com/llvm/llvm-project/pull/96392


More information about the Mlir-commits mailing list