I'm implementing a lazy functional language and 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? -- Piotr Kaleta -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110719/48593ed6/attachment.html>
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
On 07/19/2011 12:02 PM, Piotr Kaleta wrote:> I'm implementing a lazy functional language and 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?Hi, you could call to libc malloc function to allocate heap memory. There may also be more efficient, but more complex methods. Cheers Tobi