[llvm-dev] Avoiding alloca elision

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 13 15:28:29 PDT 2019


On Sat, 13 Jul 2019 at 23:23, David Blaikie via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I think Sanjoy was maybe talking in terms of LLVM's alloca intrinsic, rather than the C API. But in any case, the C API seems quite implementable with dynamic memory allocation

Definitely. Historically armcc used malloc for alloca; while I was
there we got around to implementing "stack-based alloca" as a
bona-fide feature.

For Jorg:

> 1) If it gets demoted to a heap allocation, when does the memory ever get freed?  There is no "freea" call, after all.

The implementation would ensure free got called on every exit path
from the function. It's not a fundamentally different problem compared
to calling destructors in C++.

Cheers.

Tim.


More information about the llvm-dev mailing list