This merges moving filename and related CU annotation from late finish to early finish. With this all changes to cgraphunit.c have been merged.
[LTO] Bootstrap and test running on x86_64-unknown-linux-gnu. Richard. 2016-09-19 Richard Biener <rguent...@suse.de> * debug.h (gcc_debug_hooks): Add filename parameter to early_finish hook. * debug.c (do_nothing_debug_hooks): Adjust. * dbxout.c (dbx_debug_hooks): Likewise. * sdbout.c (sdb_debug_hooks): Likewise. * dwarf2out.c (dwarf2_lineno_debug_hooks): Likewise. (dwarf2out_finish): Move producer, filename and path annotation ... (dwarf2out_early_finish): ... here. Remove in_lto_p special-casing. * cgraphunit.c (symbol_table::finalize_compilation_unit): Adjust. lto/ * lto.c (lto_main): Call early_finish with "<artificial>" as filename. Index: gcc/debug.h =================================================================== --- gcc/debug.h (revision 240228) +++ gcc/debug.h (working copy) @@ -31,7 +31,7 @@ struct gcc_debug_hooks void (* finish) (const char *main_filename); /* Run cleanups necessary after early debug generation. */ - void (* early_finish) (void); + void (* early_finish) (const char *main_filename); /* Called from cgraph_optimize before starting to assemble functions/variables/toplevel asms. */ Index: gcc/debug.c =================================================================== --- gcc/debug.c (revision 240228) +++ gcc/debug.c (working copy) @@ -26,7 +26,7 @@ const struct gcc_debug_hooks do_nothing_ { debug_nothing_charstar, debug_nothing_charstar, - debug_nothing_void, /* early_finish */ + debug_nothing_charstar, /* early_finish */ debug_nothing_void, debug_nothing_int_charstar, debug_nothing_int_charstar, Index: gcc/dbxout.c =================================================================== --- gcc/dbxout.c (revision 240228) +++ gcc/dbxout.c (working copy) @@ -344,7 +344,7 @@ const struct gcc_debug_hooks dbx_debug_h { dbxout_init, dbxout_finish, - debug_nothing_void, + debug_nothing_charstar, debug_nothing_void, debug_nothing_int_charstar, debug_nothing_int_charstar, Index: gcc/sdbout.c =================================================================== --- gcc/sdbout.c (revision 240228) +++ gcc/sdbout.c (working copy) @@ -277,7 +277,7 @@ const struct gcc_debug_hooks sdb_debug_h { sdbout_init, /* init */ sdbout_finish, /* finish */ - debug_nothing_void, /* early_finish */ + debug_nothing_charstar, /* early_finish */ debug_nothing_void, /* assembly_start */ debug_nothing_int_charstar, /* define */ debug_nothing_int_charstar, /* undef */ Index: gcc/cgraphunit.c =================================================================== --- gcc/cgraphunit.c (revision 240228) +++ gcc/cgraphunit.c (working copy) @@ -2561,7 +2564,7 @@ symbol_table::finalize_compilation_unit /* Clean up anything that needs cleaning up after initial debug generation. */ - (*debug_hooks->early_finish) (); + (*debug_hooks->early_finish) (main_input_filename); } /* Finally drive the pass manager. */ Index: gcc/lto/lto.c =================================================================== --- gcc/lto/lto.c (revision 240228) +++ gcc/lto/lto.c (working copy) @@ -3316,7 +3316,7 @@ lto_main (void) lto_promote_statics_nonwpa (); /* Annotate the CU DIE and mark the early debug phase as finished. */ - debug_hooks->early_finish (); + debug_hooks->early_finish ("<artificial>"); /* Let the middle end know that we have read and merged all of the input files. */ Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 240228) +++ gcc/dwarf2out.c (working copy) @@ -2480,7 +2480,7 @@ build_cfa_aligned_loc (dw_cfa_location * static void dwarf2out_init (const char *); static void dwarf2out_finish (const char *); -static void dwarf2out_early_finish (void); +static void dwarf2out_early_finish (const char *); static void dwarf2out_assembly_start (void); static void dwarf2out_define (unsigned int, const char *); static void dwarf2out_undef (unsigned int, const char *); @@ -2556,7 +2556,7 @@ const struct gcc_debug_hooks dwarf2_line { dwarf2out_init, debug_nothing_charstar, - debug_nothing_void, + debug_nothing_charstar, debug_nothing_void, debug_nothing_int_charstar, debug_nothing_int_charstar, @@ -27804,7 +27804,7 @@ flush_limbo_die_list (void) and generate the DWARF-2 debugging info. */ static void -dwarf2out_finish (const char *filename) +dwarf2out_finish (const char *) { comdat_type_node *ctnode; dw_die_ref main_comp_unit_die; @@ -27816,34 +27816,8 @@ dwarf2out_finish (const char *filename) DIEs generated after early finish. */ gcc_assert (deferred_asm_name == NULL); - /* PCH might result in DW_AT_producer string being restored from the - header compilation, so always fill it with empty string initially - and overwrite only here. */ - dw_attr_node *producer = get_AT (comp_unit_die (), DW_AT_producer); - producer_string = gen_producer_string (); - producer->dw_attr_val.v.val_str->refcount--; - producer->dw_attr_val.v.val_str = find_AT_string (producer_string); - gen_remaining_tmpl_value_param_die_attribute (); - /* Add the name for the main input file now. We delayed this from - dwarf2out_init to avoid complications with PCH. - For LTO produced units use a fixed artificial name to avoid - leaking tempfile names into the dwarf. */ - if (!in_lto_p) - add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); - else - add_name_attribute (comp_unit_die (), "<artificial>"); - if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir) - add_comp_dir_attribute (comp_unit_die ()); - else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL) - { - bool p = false; - file_table->traverse<bool *, file_table_relative_p> (&p); - if (p) - add_comp_dir_attribute (comp_unit_die ()); - } - #if ENABLE_ASSERT_CHECKING { dw_die_ref die = comp_unit_die (), c; @@ -28151,10 +28125,31 @@ dwarf2out_finish (const char *filename) has run. */ static void -dwarf2out_early_finish (void) +dwarf2out_early_finish (const char *filename) { set_early_dwarf s; + /* PCH might result in DW_AT_producer string being restored from the + header compilation, so always fill it with empty string initially + and overwrite only here. */ + dw_attr_node *producer = get_AT (comp_unit_die (), DW_AT_producer); + producer_string = gen_producer_string (); + producer->dw_attr_val.v.val_str->refcount--; + producer->dw_attr_val.v.val_str = find_AT_string (producer_string); + + /* Add the name for the main input file now. We delayed this from + dwarf2out_init to avoid complications with PCH. */ + add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); + if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir) + add_comp_dir_attribute (comp_unit_die ()); + else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL) + { + bool p = false; + file_table->traverse<bool *, file_table_relative_p> (&p); + if (p) + add_comp_dir_attribute (comp_unit_die ()); + } + /* With LTO early dwarf was really finished at compile-time, so make sure to adjust the phase after annotating the LTRANS CU DIE. */ if (in_lto_p)