On Wed, Mar 18, 2015 at 10:28 PM, Jason Merrill <ja...@redhat.com> wrote: > If you move the call to rest_of_decl_compilation we could go through and > prune the debug info for unused decls at dwarf2out_finish time, the way we > do with unused types.
True. Note that the varpool nodes eventually get created once the first use is seen. So I wonder how much garbage we create by unconditionally creating the node in rest_of_decl_compilation (yeah, header files, of course - probably a similar issue for unused function declarations?). I'd prefer to do early_global_decl from rest_of_decl_compilation (and shun the symtab/varpool walk - but that would require the FEs would hand off each global that possibly needs debug info through rest_of_decl_compilation). To prune globals during early(!) dwarf2out_finish you should be able to use the symbol table (not sure if we prune all unused symbols, but surely the list of references should be empty). Richard. > Jason