<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58058>58058</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            MemRefToSPIRV allocation broken for opencl-spirv
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nirvedhmeshram
      </td>
    </tr>
</table>

<pre>
    Instead of allocating a global variable like
```
spirv.GlobalVariable @__workgroup_mem__0 : !spirv.ptr<!spirv.struct<(!spirv.array<20 x f32>)>, Workgroup>
```
if you change environment from shader to kernel you get a dynamic kind of allocation like this
```
spirv.GlobalVariable @__workgroup_mem__0 : !spirv.ptr<f32, Workgroup>
```
This does not play nice with backends as it becomes a scalar allocation rather than an array
To reproduce change Shader to Kernel in any tests in https://github.com/llvm/llvm-project/blob/main/mlir/test/Conversion/MemRefToSPIRV/alloc.mlir 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1Uk1v2zAM_TX2hWjgyHYWH3zo0nUohgFDW3THgLJpW4ssGZKcLP9-tNpmLbDDdhhAiHoSv96TpG3P9Z3xgbAF2wFqbRsMyvSA0GsrUcMRnUKpCbQ6UJLdJNl1ssleLEI_KXdcfY7hT6_RSZHt9yfrDr2z87QfadzvM0jya0jE-jljCi7Jdxfog5ubEE-2l0N0Ds98JjL4CV0ukvxTIqq47uD7a_kF_2ky1cHZztAMaHoCMkflrBnJBOicHcEP2JKDYOFAzpCOwT0FJt-eDY6qgYMy75SxJuoAYVD-P4ixMPwbYo_cHlpLHowNMGk8g1ENwUmFASQ2BzKtB_SgAkhq7MiRCL5Bje4tF4dhWBRggWCxqPZzBwuOJmfbmcu-CPhw0evLs15qyTpDIB_8AoYQJs-0EnHL1vMws1xxdwZaH1_dFZf9QfzU4layTuxGVGZxWjl2Szl2O2uO5DyPyeArjffUPdqHb3f3T4wjh9WSACnV682mKDYbUVVpW-dtlVeYBhU01e_y3jKXzrJI0FkHdiLT6Kv4DunsdP3PNJT3M3nelNus3KZDvW7yrNt-yEqJssSiK2ldYNWJrcxJtqJINUrSvk7Kj4kQhk4QS_A-KW9SVYtMiKwS1bosirJabdpWdGVeZqXoaL0V_J-INdOrZY6VdX3q6jiSnHvPl1rxg_y-RO9Vb4hiO66Pcxisqw3zpXbgvzE4HNM4QR0Z_AKF6VdW">