[LLVMdev] Proposal: release MDNodes for source modules (LTO+debug info)

Chris Lattner clattner at apple.com
Tue Nov 12 18:02:56 PST 2013


On Nov 12, 2013, at 4:59 PM, Chandler Carruth <chandlerc at google.com> wrote:
> Other options are:
> 1> Using a different LLVMContext for the destination module, but it didn’t work out since Linker was not designed to work with different LLVMContexts for source vs destination.
> 2> removeUnusedMDNodes checks if a MDNode is used in a different way  (i.e use_empty() && !hasValueHandler()), but it does not remove MDNodes that form cycles.
> 
> 3) Make the MDNode be owned by the module that uses it?
>  
> MDNode is shared among modules so multiple modules can use it, if we specify an owner for a MDNode, that will prevent sharing.
> 
> From your stats (40% stuck in the old module) it doesn't sound like this is buying us anything...
>  

If the old module is deleted, then these MDNodes can be reclaimed.

I think this proposal amounts to a “garbage collector” that clears out now-dead IR objects that are uniqued in the LLVM Context.  While MDNodes are your focus, the same thing would apply equally well to ConstantInt and other things that may become unreachable.

Details matter on this (for it to be efficient), but I think that it would be very useful for LLVMContext to have a method that goes through and releases IR objects that aren’t used.  This could be used by the LTO driver, and if it actually reduces memory by 40%, that would be huge.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131112/734dfb66/attachment.html>


More information about the llvm-dev mailing list