[llvm-dev] alloca behavior in llvm IR
林政宗 via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 8 18:43:44 PST 2020
Hi, there,
I am not quite clear about the behavior of alloca instruction in llvm IR.
----------------------------------------------------------------------------------------------------
1273/// isStaticAlloca - Return true if this alloca is in the entry block of the
1274/// function and is a constant size. If so, the code generator will fold it
1275/// into the prolog/epilog code, so it is basically free.
1276bool AllocaInst::isStaticAlloca() const {
1277 // Must be constant size.
1278 if (!isa<ConstantInt>(getArraySize())) return false;
1279
1280 // Must be in the entry block.
1281 const BasicBlock *Parent = getParent();
1282 return Parent == &Parent->getParent()->front() && !isUsedWithInAlloca();
1283}
----------------------------------------------------------------------------------------------------
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?
Would it adjust the stack for the current function?
Thanks!
Best Regards,
Jerry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201209/0158467a/attachment.html>
More information about the llvm-dev
mailing list