<div dir="ltr"><div>I'm on llvm 3.8.1 and was wondering if there's a memory leak in the removeModule impl of mcjit.</div><div>In the tutorial <a href="http://llvm.org/releases/3.8.1/docs/tutorial/LangImpl4.html">http://llvm.org/releases/3.8.1/docs/tutorial/LangImpl4.html</a> a module is removed from the Jit by invoking removeModule. </div><div><br></div><div>According to the tutorial:</div><div><br></div><div>"Its API is very simple::
<tt class="gmail-docutils gmail-literal"><span class="gmail-pre">addModule</span></tt> adds an LLVM IR module to the JIT, making its functions
available for execution; <tt class="gmail-docutils gmail-literal"><span class="gmail-pre">removeModule</span></tt> removes a module, freeing any
memory associated with the code in that module;"</div><div><br></div><div>But when I look into the implementation of remove module, it only erases the ptr from <span style="background-color:rgb(251,252,253);color:rgb(0,0,0);font-family:monospace,fixed;font-size:12px">AddedModules</span></div><div><span style="background-color:rgb(251,252,253);color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt">//</span><font color="#000000" face="monospace, fixed"><span style="font-size:12px">return AddedModules.erase(M) || LoadedModules.erase(M) || FinalizedModules.erase(M);</span></font></div><div><span style="background-color:rgb(251,252,253);color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt"><br></span></div><div>When you add a module, the unique ptr is stripped, and the raw ptr is stored. </div><div>//<span style="background-color:rgb(251,252,253);color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt">AddedModules.insert(M.release());</span></div><div><span style="background-color:rgb(251,252,253);color:rgb(0,0,0);font-family:monospace,fixed;font-size:9pt"><br></span></div><div>This should imply that the person who is invoking removeModule also should invoke a delete on the ptr?</div><div><br></div><div>Am I missing something here?</div><div></div></div>