[LLVMdev] How to strip all unused debugging metadata?

Matt Pharr matt.pharr at gmail.com
Tue Apr 24 08:43:46 PDT 2012


On Apr 24, 2012, at 5:36 AM, Renato Golin wrote:

> On 24 April 2012 16:04, Matt Pharr <matt.pharr at gmail.com> wrote:
>> When I generate debug information for a source file that has a number of static functions that are unused, all of the debugging metadata that I generated for them during initial compilation remains even after the source function definitions have been stripped out of the IR.  (e.g. in the MD for DW_TAG_compile_unit's list of subprograms, each of those functions' info is still in the list, and so forth).  How can I remove that unused stuff?  (It continues on to generated object files, which is extra undesirable when there is a lot of this.)
> 
> In theory, every metadata that is not attached to a real value (or a
> named metadata) is stripped out. I think even if they're not in gv/sp
> arrays, but I'm not sure.
> 
> Are you sure there isn't any path to a real value from the dangling
> metadata? Do you create named metadata?

I think that the root problem is that there is a path to the metadata (from llvm.dbg.cu to the metadata for the DW_TAG_compile_unit to the list of subprograms to the individual DW_TAG_subprogram metadata), but that in turn there's no longer any need for the DW_TAG_subprogram metadata for all of the functions that were stripped out.

Perhaps the answer is that I just need to write the code that traverses the metadata and removes the subprogram metadata from the list of subprograms, if the corresponding function definition has been stripped from the module.  I'd have guessed that the DIBuilder infrastructure would have ended up doing that automagically for me, but maybe that was an incorrect assumption?

Thanks,
-matt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120424/5f0409f6/attachment.html>


More information about the llvm-dev mailing list