KhronosGroup / SPIRV-LLVM-Translator

A tool and a library for bi-directional translation between SPIR-V and LLVM IR
Other
468 stars 209 forks source link

Adjust OpVariable's users and Lifetime ptr operand storage classes #2650

Closed MrSidims closed 1 month ago

MrSidims commented 1 month ago

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.