<div dir="ltr"><p>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 - </p>



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

<pre><code>auto x = new Alloca(...) vs. Alloca(...) x;
</code></pre>

<p>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;". </p>

<p>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?</p><p>It would be great if someone can explain the memory allocation schema used by these APIs.</p><p>Thanks!</p></div>