[LLVMdev] Making it possible to clear the LLVMContext
Reid Kleckner
rnk at google.com
Tue Jun 24 13:22:43 PDT 2014
On Tue, Jun 24, 2014 at 9:17 AM, Mathias Fröhlich <Mathias.Froehlich at gmx.net
> wrote:
>
> I can't comment on your solution.
> But again the open source OpenGL driver stack is suffering from problems
> connected to
> LLVMContext.
>
> So our observation is, if we use several LLVMContexts within the program
> execution
> lifetime, LLVM accumulates memory that is only freed on destruction of the
> managed singletons. It turns out that in SDNode::getValueTypeList(EVT) the
> non simple
> value types are cached and keyed by a llvm::Type value which in the end
> refers to a
> LLVMContext reference value. Which in turn leads to the llvm library
> hogging memory
> in this EVT std::set for each new LLVMContext.
> For the OpenGL drivers using the global LLVMContext singleton leads to
> serious
> threadsafeness problems. One driver is just non OpenGL conformant
> non thread safe because of that, some others just tolerate LLVM hogging
> memory because of that. Even worse for the ones just tolerating hogging
> memory, I could potentially think of possible ABA like problems with a
> new LLVMContext or llvm::Type being malloced at the same address than a
> previous already deleted
> one but not knowing about the cached EVT's which appear to belong to this
> context.
>
It looks like this bug is in SDNode::getValueTypeList(). This is a real
bug that should be filed and fixed.
That said I think you need to be careful since some of the llvm static
> caches refer to
> LLVMContext pointers and at least the one I mentioned above is not cleared
> if either
> a whole LLVMContext is cleared nor it is cleared by what you want to
> achieve.
>
> Also for my interest:
> Does anybody know of other statically cached object instances that are
> tied to an
> LLVMContext but not cleaned up when the referring LLVMContext is destroyed?
>
Not that I know of. Any global that points to a Type* is a potential bug
and should probably be removed.
> Greetings and thanks
>
> Mathias
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140624/f0ae4e62/attachment.html>
More information about the llvm-dev
mailing list