[LLVMdev] Heap memory allocation

Ondřej Hošek ondra.hosek at gmail.com
Tue Jul 19 03:33:00 PDT 2011


On Tue, Jul 19, 2011 at 12:02, Piotr Kaleta <piotrek.kaleta at gmail.com> wrote:
> I need to allocate nodes on
> the heap. From what I've read LLVM supports only the 'alloca' instruction
> which allows to allocate memory on the stack. Is this true and and if so,
> what is the preferred way to solve my problem?

Yup, that's true; the 'malloc' instruction has been removed a while
ago. If I recall correctly, the preferred way is to declare and call
the C function "malloc" instead. Of course, the size of its argument
may change from system to system (e.g. i32 on 32-bit systems and i64
on 64-bit ones).

Cheers,
~~ Ondra



More information about the llvm-dev mailing list