[LLVMdev] Leaking GlobalVariable from lowerInvoke pass
sabre at nondot.org
Fri Nov 12 15:02:33 PST 2004
On Thu, 11 Nov 2004, Morten Ofstad wrote:
> Although most of the leaks I detected in LLVM were from singleton
> objects, there also seem to be some real leaks. One such leak (which is
> creating problems for me when I try to get rid of the constant
> singletons) seems to be a GlobalVariable created on line 145 of
> Transforms/Scalar/lowerInvoke.cpp -- any suggestions how I can make sure
> this GlobalVariable gets deleted?
On line 145, a ConstantArray is created, which is very different than a
global variable. I think the thing that you are missing is that constants
are singleton objects as well. Some constants (like some types) actually
do get deleted, but they are they exception rather than the rule.
> Actually I'm a bit confused in general with how LLVM manages memory and
> I could not find anything in the documentation section -- from what I
> have seen in the source code it seems like bigger structures (Modules,
> BasicBlocks) take ownership of things you put into them (Functions,
> Instructions) and delete them when they are themselves deleted. Is this
> right? So why isn't the GlobalVariable getting deleted?
That is exactly right. Singleton objects like types and constants are the
exception, but otherwise, a module ends up owning everything.
FWIW, the LowerInvoke pass was doing some silly things w.r.t. the messages
it was generating. I've simplified it, so the symptom you were seeing may
More information about the llvm-dev