<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 24, 2014 at 2:22 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.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 class="gmail_extra"><div class="gmail_quote"><div class="">On Tue, Jun 24, 2014 at 9:17 AM, Mathias Fröhlich <span dir="ltr"><<a href="mailto:Mathias.Froehlich@gmx.net" target="_blank">Mathias.Froehlich@gmx.net</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I can't comment on your solution.<br>
But again the open source OpenGL driver stack is suffering from problems connected to<br>
LLVMContext.<br>
<br>
So our observation is, if we use several LLVMContexts within the program execution<br>
lifetime, LLVM accumulates memory that is only freed on destruction of the<br>
managed singletons. It turns out that in SDNode::getValueTypeList(EVT) the non simple<br>
value types are cached and keyed by a llvm::Type value which in the end refers to a<br>
LLVMContext reference value. Which in turn leads to the llvm library hogging memory<br>
in this EVT std::set for each new LLVMContext.<br>
For the OpenGL drivers using the global LLVMContext singleton leads to serious<br>
threadsafeness problems. One driver is just non OpenGL conformant<br>
non thread safe because of that, some others just tolerate LLVM hogging<br>
memory because of that. Even worse for the ones just tolerating hogging<br>
memory, I could potentially think of possible ABA like problems with a<br>
new LLVMContext or llvm::Type being malloced at the same address than a previous already deleted<br>
one but not knowing about the cached EVT's which appear to belong to this context.<br></blockquote><div><br></div></div><div>It looks like this bug is in SDNode::getValueTypeList(). This is a real bug that should be filed and fixed.<br>
</div></div></div></div></blockquote><div><br></div><div>Doing some archaeology, it seems like the blame on that cache points at r78610. The commit message is "Rename MVT to EVT, [...]", so it seems like it goes back even further. Probably just a remnant of something ancient. Anyone that was around back then have any insight into this?</div>
<div><br></div><div>-- Sean Silva</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>
</div><div class=""><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
That said I think you need to be careful since some of the llvm static caches refer to<br>
LLVMContext pointers and at least the one I mentioned above is not cleared if either<br>
a whole LLVMContext is cleared nor it is cleared by what you want to achieve.<br>
<br>
Also for my interest:<br>
Does anybody know of other statically cached object instances that are tied to an<br>
LLVMContext but not cleaned up when the referring LLVMContext is destroyed?<br></blockquote><div><br></div></div><div>Not that I know of. Any global that points to a Type* is a potential bug and should probably be removed.</div>
<div class="">
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Greetings and thanks<br>
<span><font color="#888888"><br>
Mathias<br>
</font></span><div><div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div></div><br></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div></div>