[LLVMdev] Beginner LLVM Questions

ajay gopalakrishnan ajgopala at gmail.com
Wed Mar 25 16:25:41 PDT 2015


I've recently started using LLVM IR generation APIs for my project. The
documentation and LLC tool are pretty helpful, but I haven't been able to
find answer to the following -

All code that creates LLVM IR instructions using their APIs seems to "new"
instructions instead of creating them as stack variables.

auto x = new Alloca(...) vs. Alloca(...) x;

I am wondering what the ownership semantics are for the pointers that are
created? Do I have to call delete on these instruction objects. All code
that I've seen calls "delete engine;".

I am guessing that all this memory is owned by this Module object and when
the module is destroyed, all the memory occupied by these instructions are
also destroyed. By looking at some of the code, it seems that all these
instruction objects are created by using "placement new" ... Is this
understanding correct?

It would be great if someone can explain the memory allocation schema used
by these APIs.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150325/8b873353/attachment.html>


More information about the llvm-dev mailing list