On 08/28/2014 01:34 PM, Aldy Hernandez wrote:
I wonder if instead of early dumping of all the DECLs, we could only
dump the toplevel scoped DECLs, and let inheritance set the proper
contexts.

Yes, I think this makes a lot more sense; do it at a well-defined point in compilation rather than as part of free_lang_data.

We could start with calling dwarf2out_early_decl() for each function
decl, and then for every global.  This is analogous to what we currently
do for late dwarf2out.

see final.c for the functions:
       if (!DECL_IGNORED_P (current_function_decl))
         debug_hooks->function_decl (current_function_decl);

see c/c-decl.c for the globals:
       FOR_EACH_VEC_ELT (*all_translation_units, i, t)
     c_write_global_declarations_2 (BLOCK_VARS (DECL_INITIAL (t)));
       c_write_global_declarations_2 (BLOCK_VARS (ext_block));

The problem being that to calculate `ext_block' above, we need intimate
knowledge of scopes and such, only available in the FE.  Is there a
generic way of determining if a DECL is in global scope?

Why not do it in the FE, i.e. *_write_global_declarations?

Jason

Reply via email to