I'm translating the source of stack-based virtual machine into LLVM IR and my plan is to implement  the stack in LLVM IR (using alloca/load/store) in order to emulate the VM's stack and then use the optimization phase "mem2reg". Therefore I'm going to have a stack pointer that points to the top of my stack. I'm curious whether I will have to implement that in a linked-list fashion, i.e. each stack node would contain the pointer to the previous node as well as the current value of the top of the stack or maybe alloca instruction works in a way that the subsequent calls to it allocates the contiguous memory area and I could get rid of the "pointer to previous thing" and only count the number of calls to alloca instruction.<div>

<br></div><div>Another thing is that there might be a better (less expensive or easier) way of doing the whole stack -> SSA transformation which I didn't came up with, but someone else did?</div><div><br></div><div>

Kind regards<br>-- <br>Piotr Kaleta<br>
</div>