[flang-commits] [flang] [flang][cuda] Fix fir.cuda_kernel_launch assembly with no args (PR #85987)

via flang-commits flang-commits at lists.llvm.org
Wed Mar 20 11:57:01 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Valentin Clement (バレンタイン クレメン) (clementval)

<details>
<summary>Changes</summary>

When the kernel launch has no arguments, the generated parser was expecting at least a type to be present. Make the last part of the assemble format optional.
Add a run line to round-trip the output through fir-opt so we make sure the IR can be parsed and printed correctly. 

---
Full diff: https://github.com/llvm/llvm-project/pull/85987.diff


2 Files Affected:

- (modified) flang/include/flang/Optimizer/Dialect/FIROps.td (+1-1) 
- (modified) flang/test/Lower/CUDA/cuda-kernel-calls.cuf (+1) 


``````````diff
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 8a7e36e42457f5..b991ec76fdd956 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2466,7 +2466,7 @@ def fir_CUDAKernelLaunch : fir_Op<"cuda_kernel_launch", [CallOpInterface,
   let assemblyFormat = [{
     $callee `<` `<` `<` $grid_x `,` $grid_y `,` $grid_z `,`$block_x `,`
         $block_y `,` $block_z ( `,` $bytes^ ( `,` $stream^ )? )? `>` `>` `>`
-        `` `(` $args `)` `:` `(` type($args) `)` attr-dict
+        `` `(` $args `)` ( `:` `(` type($args)^ `)` )? attr-dict
   }];
 
   let extraClassDeclaration = [{
diff --git a/flang/test/Lower/CUDA/cuda-kernel-calls.cuf b/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
index f4327b3261751f..7e28fbb2231a2d 100644
--- a/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
+++ b/flang/test/Lower/CUDA/cuda-kernel-calls.cuf
@@ -1,4 +1,5 @@
 ! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir -fcuda %s -o - | fir-opt | FileCheck %s
 
 ! Test lowering of CUDA procedure calls.
 

``````````

</details>


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


More information about the flang-commits mailing list