Result number not allowed in argument list

I got this error when I use an operand which is a result number. For example :

module attributes {gpu.container_module} {
    func.func private @myfunc() -> (memref<?xindex>, memref<?xindex>) 
    func.func @testfunc() {
        %c1 = arith.constant 1 : index
         %64 = arith.constant 64 : index
        %res:2 = @myfunc() : ()->(memref<?xindex>, memref<?xindex>) 
        gpu.launch_func  @heat3D_seidel_kernel::@heat3D_seidel_kernel blocks in (%c1, %c1, %c1) threads in (%c64, %c1, %c1) args( %res#1 : memref<?xindex>)


There is any reason why gpu.launch_func cannot accept result number as operands?

This restriction is coming from this line

the allowResultNumber variable is set to false !!! is it a bug?

@ftynse @albertcohen

I built out quite a bit of the code for argument shadowing years ago. My recollection is that I just didn’t allow this because there was no use-case at the time, so it was better to start conservatively. I am +1 for adding it, it keeps the stack more orthogonal.


It is indeed a bug, but in a different place. The parser of gpu.launch_func should not be using parseArgument, at least not in its current implementation. It was intended for defining entry block arguments, such as arguments of a function, and therefore doesn’t allow for result numbers, correctly. Otherwise we would be able to write func.func @foo(%arg0#0: i32). The correct fix is to change the parser of gpu.launch_func.

⚙ D141851 [mlir] accept values with result numbers in gpu.launch_func is the correct fix.