On Tue, May 30, 2017 at 5:47 PM, Pierre-Marie de Rodat <dero...@adacore.com> wrote: > Thank you for your review, Richard. > > On 05/30/2017 01:59 PM, Richard Biener wrote: >> >> I think the issue is unfortunate in the C frontend as well. So I believe >> we can >> go without a new langhook and instead make sure >> dwarf2out_early_global_decl >> is not called for uninteresting decls (which means eventually pushing the >> call(s) of that hook more towards the FEs). > > > It is called by rest_of_decl_compilation, which seems itself to be called a > lot on FUNCTION_DECL nodes. Before I dive into this consequent change: this > would lead for instance to add a parameter to rest_of_compilation to control > whether it must call the early_global_decl hook, and then to update all > callers accordingly. Is this what you actually have in mind?
Actually for the bigger picture I'd refactor rest_of_decl_compilation, not calling it from the frontends but rely on finalize_decl/function. The missing part would then be calling the dwarf hook which should eventually be done at some of the places the frontends now call rest_of_decl_compliation. > >> For C/C++ it would be reasonable to output debug info for external >> declarations >> that end up being used for example. > > > I guess that could be done indeed. :-) But for an easier way (you might still explore the above ;)) just remove the guards from dwarf2out.c and handle it more like types that we prune if they end up being unused (OTOH I guess we don't refer to the decl DIEs from "calls" because not all calls are refered to with standard DWARF -- the GNU callsite stuff refers them I think but those get generated too late). That said, when early_finish is called the cgraph and IPA references exists and thus you can sort-of see which functions are "used". Richard. > -- > Pierre-Marie de Rodat