[llvm-dev] alloca behavior in llvm IR
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Wed Dec 9 02:16:47 PST 2020
On Wed, 9 Dec 2020 at 02:43, 林政宗 via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I saw the code fragment as above. Is it possible that alloca is not static?
> And what is the behavior when alloca is not static?
> When alloca is not in the entry block, it is not static. How would it behave?
The compiler will modify sp in the middle of the function to allocate
more memory on the stack. If your alloca is in a loop it might even do
that repeatedly (@llvm.stacksave and @llvm.stackrestore can help
here).
> Would it adjust the stack for the current function?
The memory would become part of the current function's stack frame,
and still get freed when it returns.
Cheers.
Tim.
More information about the llvm-dev
mailing list