alloca function in llvm

​Hi all,

I know that we use alloca method in llvm (llvmlite) to statically allocate a stack slot for size values of type typ. However, if I want to deallocate and free the memory from the allocated stack, there is no free method. Does any one know how can I simply deallocate the allocated stack in llvm or llvmlite?

Thank you in advance

I have no idea about llvmlite and any questions related to it are better addressed to the llvmlite mailing list.

In LLVM, the alloca instruction allocates space in the current stack frame. This space is (as you would expect in any language with normal stack discipline) freed automatically when the function returns. If you have dynamic allocas that are reached more than once in a function (for example, in a loop), then you can use the stacksave and stackrestore intrinsics. The stackrestore intrinsic will reset the stack to a value from a corresponding stacksave, effectively freeing all allocas that occur in the middle. You cannot free individual allocas in any other order (it would not make sense to do so, because they are stack allocations).