[LLVMdev] LLVM C++ API memory management

Gregory Petrosyan gregory.petrosyan at gmail.com
Tue Nov 11 01:08:05 PST 2008


2008/11/11 Chris Lattner <clattner at apple.com>:

> The ownership model is very simple.  We have a simple structured
> system (e.g. module is a list of functions, function is a list of
> blocks, blocks are a list of instructions).  When a node is inserted
> into a parent container (e.g. an instruction in a basic block) then
> the parent owns the node.
>
> This means that if you create an instruction and insert it into a
> block, you're fine.  If you remove an instruction from a block, you
> have to either reinsert it or delete it.  The "remove" methods remove
> a node from its parent and returns it, the "erase" methods do a remove
> +delete.

Thanks once again.

> Unfortunately this is not really documented anywhere.  It would be
> really really good to add a section about this in the Programmer's
> Manual.  Can you write up a patch?

I'll try.

-- 
Regards, Gregory.



More information about the llvm-dev mailing list