While clang is generating alloca in private address space for OpenCL following target's datalayout, some of the passes might generate it in generic AS and for this cases we have to create OpVariable in function storage class and create a cast to generic. Additionally if such alloca was an operand of lifetime instruction - then SPIR-V without storage class adjustment validation for lifetime instruction will be violated (pointer operand must be with Function storage class).
This became exposed after https://github.com/llvm/llvm-project/pull/97306 which was fixing handling of byval pointer parameter of a function during inlining, byval pointer for OpenCL will be generated in default (under an option - generic) address space making the alloca to store value of the function's operand also be generic.
While clang is generating alloca in private address space for OpenCL following target's datalayout, some of the passes might generate it in generic AS and for this cases we have to create OpVariable in function storage class and create a cast to generic. Additionally if such alloca was an operand of lifetime instruction - then SPIR-V without storage class adjustment validation for lifetime instruction will be violated (pointer operand must be with Function storage class).
This became exposed after https://github.com/llvm/llvm-project/pull/97306 which was fixing handling of byval pointer parameter of a function during inlining, byval pointer for OpenCL will be generated in default (under an option - generic) address space making the alloca to store value of the function's operand also be generic.