[llvm] [SPIRV] Emit intrinsics for globals only in function that references them (PR #178143)

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 27 06:44:04 PST 2026


jmmartinez wrote:

> I'm not sure I fully understand what the requirements here are. Is the problem here just that we need _some_ place to emit these instructions, and as the LLVM backend only has a notion of instructions inside functions, we solve this by emitting them in each function?
> 
> Would it be possible to instead create some dummy `__global_init` function that holds all the global declaration/initialization instructions? Or is the problem then that we can't properly reference the global from within functions?

I think that something along those lines would be possible. We could have all the globals constructors in a single `__global_init`. We would still need the global variable declarations on each function that references it.

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


More information about the llvm-commits mailing list