<div dir="ltr">I Lol'ed at your commit msg :)<div>We will start migrating to ORC for next release, but for now, this release invoke delete after remove right?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 5, 2016 at 12:20 AM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Koffie,<div><br></div><div>Kaleidoscope is no longer using MCJIT - it has been moved over to the ORC-based KaleidoscopeJIT class (see llvm/examples/Kaleidoscope/<wbr>include/KaleidoscopeJIT.h). The removeModule method there does not leak memory.</div><div><br></div><div>I've added documentation in r286026 to describe MCJIT removeModule's crazy ownership contract.</div><div><br></div><div>This will be fixed properly when we kill off ExecutionEngine. :)</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>- Lang.</div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 28, 2016 at 4:10 AM, koffie drinker <span dir="ltr"><<a href="mailto:gekkekoe@gmail.com" target="_blank">gekkekoe@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">http://llvm.org/relea<wbr>ses/3.8.1/docs/tutorial/LangIm<wbr>pl4.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="m_-932645826481048040m_1960620588512193887gmail-docutils m_-932645826481048040m_1960620588512193887gmail-literal"><span class="m_-932645826481048040m_1960620588512193887gmail-pre">addModule</span></tt> adds an LLVM IR module to the JIT, making its functions
available for execution; <tt class="m_-932645826481048040m_1960620588512193887gmail-docutils m_-932645826481048040m_1960620588512193887gmail-literal"><span class="m_-932645826481048040m_1960620588512193887gmail-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.releas<wbr>e());</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>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>