Well, we'd also have to output globals, which we're currently not doing
in finalize_compilation_unit. But if you're ok with generating early
dwarf for functions as well as globals/statics from
finalize_compilation_unit() then we could get rid of virtually every
call to early_global_decl() from the front-ends.
So instead of FOR_EACH_*FUNCTION*, we could have:
+ symtab_node *node;
+ FOR_EACH_SYMBOL (node)
+ {
+ cgraph_node *cn = dyn_cast <cgraph_node *> (node);
+ /* Global symbols get early debug information regardless, but
+ functions need to be visible. */
+ if (!cn || cn->has_gimple_body_p ())
+ (*debug_hooks->early_global_decl) (node->decl);
+ }
Is this what you have in mind, or did you want to handle globals
separately?
Do keep in mind that the above snippet would have the side-effect of not
creating debug information for optimized away global statics. I assume
this is intended or acceptable?