summaryrefslogtreecommitdiff
path: root/gcc/lto/lto.c
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2018-06-08 18:12:39 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2018-06-08 16:12:39 +0000
commit29a50dfb47ff12c7730a3d604642ce500a39c78f (patch)
treebc0b8a743872bd4b0673daa75981a8ee8dbce830 /gcc/lto/lto.c
parent850078b7387f7286aac70e1e594f39baf9f429af (diff)
dumpfile.c (FIRST_ME_AUTO_NUMBERED_DUMP): Bump to 4.
* dumpfile.c (FIRST_ME_AUTO_NUMBERED_DUMP): Bump to 4. * lto-lang.c (lto_link_dump_id, decl_merge_dump_id, partition_dump_id): New global vars. (lto_register_dumps): New hook. (LANG_HOOKS_REGISTER_DUMPS): New. * lto-partition.c: Dump into dump_file instead of symtab->dump_file. * lto-symtab.c: Include lto.h; dump into dump_file instead of symtab->dump_file. (lto_symtab_merge_decls): Initialize dump file. * lto.c (read_cgraph_and_symbols): Initialize dump file. (do_whole_program_analysis): Likewise. From-SVN: r261337
Diffstat (limited to 'gcc/lto/lto.c')
-rw-r--r--gcc/lto/lto.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 17634797c6e..3b57c12bc9f 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -2972,29 +2972,43 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
all_file_decl_data[i]->current_decl_state = NULL;
}
- /* Finally merge the cgraph according to the decl merging decisions. */
- timevar_push (TV_IPA_LTO_CGRAPH_MERGE);
- if (symtab->dump_file)
- {
- fprintf (symtab->dump_file, "Before merging:\n");
- symtab->dump (symtab->dump_file);
- }
if (!flag_ltrans)
{
+ /* Finally merge the cgraph according to the decl merging decisions. */
+ timevar_push (TV_IPA_LTO_CGRAPH_MERGE);
+
+ gcc_assert (!dump_file);
+ dump_file = dump_begin (lto_link_dump_id, NULL);
+
+ if (dump_file)
+ {
+ fprintf (dump_file, "Before merging:\n");
+ symtab->dump (dump_file);
+ }
lto_symtab_merge_symbols ();
/* Removal of unreachable symbols is needed to make verify_symtab to pass;
we are still having duplicated comdat groups containing local statics.
We could also just remove them while merging. */
symtab->remove_unreachable_nodes (dump_file);
+ ggc_collect ();
+
+ if (dump_file)
+ dump_end (lto_link_dump_id, dump_file);
+ dump_file = NULL;
+ timevar_pop (TV_IPA_LTO_CGRAPH_MERGE);
}
- ggc_collect ();
symtab->state = IPA_SSA;
- /* FIXME: Technically all node removals happening here are useless, because
- WPA should not stream them. */
+ /* All node removals happening here are useless, because
+ WPA should not stream them. Still always perform remove_unreachable_nodes
+ because we may reshape clone tree, get rid of dead masters of inline
+ clones and remove symbol entries for read-only variables we keep around
+ only to be able to constant fold them. */
if (flag_ltrans)
- symtab->remove_unreachable_nodes (dump_file);
-
- timevar_pop (TV_IPA_LTO_CGRAPH_MERGE);
+ {
+ if (symtab->dump_file)
+ symtab->dump (symtab->dump_file);
+ symtab->remove_unreachable_nodes (symtab->dump_file);
+ }
/* Indicate that the cgraph is built and ready. */
symtab->function_flags_ready = true;
@@ -3152,19 +3166,19 @@ do_whole_program_analysis (void)
if (seen_error ())
return;
- if (symtab->dump_file)
- {
- fprintf (symtab->dump_file, "Optimized ");
- symtab->dump (symtab->dump_file);
- }
-
- symtab_node::checking_verify_symtab_nodes ();
- bitmap_obstack_release (NULL);
-
/* We are about to launch the final LTRANS phase, stop the WPA timer. */
timevar_pop (TV_WHOPR_WPA);
timevar_push (TV_WHOPR_PARTITIONING);
+
+ gcc_assert (!dump_file);
+ dump_file = dump_begin (partition_dump_id, NULL);
+
+ if (dump_file)
+ symtab->dump (dump_file);
+
+ symtab_node::checking_verify_symtab_nodes ();
+ bitmap_obstack_release (NULL);
if (flag_lto_partition == LTO_PARTITION_1TO1)
lto_1_to_1_map ();
else if (flag_lto_partition == LTO_PARTITION_MAX)
@@ -3192,6 +3206,9 @@ do_whole_program_analysis (void)
to globals with hidden visibility because they are accessed from multiple
partitions. */
lto_promote_cross_file_statics ();
+ if (dump_file)
+ dump_end (partition_dump_id, dump_file);
+ dump_file = NULL;
timevar_pop (TV_WHOPR_PARTITIONING);
timevar_stop (TV_PHASE_OPT_GEN);