alloca in function or private address space can be lowered to VariableOp. This allow values in memory if needed.
You may have to check if the parent op has the AutomaticAllocationScope trait. When is the stack space for VariableOps reclaimed when they aren't immediately not surrounded by SPIRV functions? (or are they always are?)
Is it possible to have std.alloca outside of builtin func? So I think we only have Function storage class case here?
SPIR-V variable ops outside spv.func (that is, with Private storage class) have the lifetime as the SPIR-V module. But is it possible to have std.alloca outside of builtin func? std.alloca's semantics seem to allow that; I'm wondering whether we will see such cases in reality though.
I am not really sure we want to support AllocaOps. The lifetime of the buffers cannot be enforced. So we are potentially breaking that semantics (I dont see a way of deallocating the OpVariable. Maybe some use case info might help