From: hubicka Date: Wed, 11 Nov 2009 19:08:44 +0000 (+0000) Subject: * lto-cgraph.c: Include gcov-io.h X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=6c0782b190ae85409e2b509586553cd540e3cc02 * lto-cgraph.c: Include gcov-io.h (output_profile_summary): New function. (output_cgraph): Use it. (input_profile_summary): New function. (input_cgraph): Use it. * coverage.c (build_ctr_info_value): Use varpool; initalize DECL_ASSEMBLER_NAME. (create_coverage): Likewise. * tree-profile.c (tree_init_ic_make_global_vars): Likewise. (tree_init_edge_profiler): Likewise. * Makefile.in (lto-cgraph.o): Add dependency on gcov-io.h. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154100 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87e6fb41091..d3cf19511d2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2009-11-11 Jan Hubicka + + * lto-cgraph.c: Include gcov-io.h + (output_profile_summary): New function. + (output_cgraph): Use it. + (input_profile_summary): New function. + (input_cgraph): Use it. + * coverage.c (build_ctr_info_value): Use varpool; initalize + DECL_ASSEMBLER_NAME. + (create_coverage): Likewise. + * tree-profile.c (tree_init_ic_make_global_vars): Likewise. + (tree_init_edge_profiler): Likewise. + * Makefile.in (lto-cgraph.o): Add dependency on gcov-io.h. + 2009-11-11 Kai Tietz * config/i386/cygming.h (HANDLE_PRAGMA_PUSH_POP_MACRO): diff --git a/gcc/Makefile.in b/gcc/Makefile.in index f66f9ef0bf4..4e153092c06 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2199,7 +2199,7 @@ lto-cgraph.o: lto-cgraph.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TOPLEV_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) input.h \ $(VARRAY_H) $(HASHTAB_H) langhooks.h $(BASIC_BLOCK_H) \ $(TREE_FLOW_H) $(CGRAPH_H) $(FUNCTION_H) $(GGC_H) $(DIAGNOSTIC_H) \ - except.h $(TIMEVAR_H) output.h pointer-set.h $(LTO_STREAMER_H) + except.h $(TIMEVAR_H) output.h pointer-set.h $(LTO_STREAMER_H) $(GCOV_IO_H) lto-streamer-in.o: lto-streamer-in.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(TM_H) $(TOPLEV_H) $(EXPR_H) $(FLAGS_H) $(PARAMS_H) input.h $(VARRAY_H) \ $(HASHTAB_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) $(TREE_PASS_H) $(CGRAPH_H) \ diff --git a/gcc/coverage.c b/gcc/coverage.c index ebdc696218b..a223bc067e6 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -776,7 +776,7 @@ build_ctr_info_value (unsigned int counter, tree type) TREE_TYPE (tree_ctr_tables[counter]) = array_type; DECL_SIZE (tree_ctr_tables[counter]) = TYPE_SIZE (array_type); DECL_SIZE_UNIT (tree_ctr_tables[counter]) = TYPE_SIZE_UNIT (array_type); - assemble_variable (tree_ctr_tables[counter], 0, 0, 0); + varpool_finalize_decl (tree_ctr_tables[counter]); value = tree_cons (fields, build1 (ADDR_EXPR, TREE_TYPE (fields), @@ -795,6 +795,7 @@ build_ctr_info_value (unsigned int counter, tree type) TREE_PUBLIC (fn) = 1; DECL_ARTIFICIAL (fn) = 1; TREE_NOTHROW (fn) = 1; + DECL_ASSEMBLER_NAME (fn); /* Initialize assembler name so we can stream out. */ value = tree_cons (fields, build1 (ADDR_EXPR, TREE_TYPE (fields), fn), value); @@ -971,7 +972,7 @@ create_coverage (void) DECL_INITIAL (gcov_info) = t; /* Build structure. */ - assemble_variable (gcov_info, 0, 0, 0); + varpool_finalize_decl (gcov_info); /* Build a decl for __gcov_init. */ t = build_pointer_type (TREE_TYPE (gcov_info)); @@ -980,6 +981,7 @@ create_coverage (void) FUNCTION_DECL, get_identifier ("__gcov_init"), t); TREE_PUBLIC (t) = 1; DECL_EXTERNAL (t) = 1; + DECL_ASSEMBLER_NAME (t); /* Initialize assembler name so we can stream out. */ gcov_init = t; /* Generate a call to __gcov_init(&gcov_info). */ diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 6b340a37d58..38d02b83175 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see #include "output.h" #include "pointer-set.h" #include "lto-streamer.h" +#include "gcov-io.h" /* Create a new cgraph encoder. */ @@ -307,6 +308,24 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node, lto_output_uleb128_stream (ob->main_stream, node->global.inlined); } +/* Stream out profile_summary to OB. */ + +static void +output_profile_summary (struct lto_simple_output_block *ob) +{ + if (profile_info) + { + /* We do not output num, it is not terribly useful. */ + gcc_assert (profile_info->runs); + lto_output_uleb128_stream (ob->main_stream, profile_info->runs); + lto_output_sleb128_stream (ob->main_stream, profile_info->sum_all); + lto_output_sleb128_stream (ob->main_stream, profile_info->run_max); + lto_output_sleb128_stream (ob->main_stream, profile_info->sum_max); + } + else + lto_output_uleb128_stream (ob->main_stream, 0); +} + /* Output the part of the cgraph in SET. */ @@ -324,6 +343,8 @@ output_cgraph (cgraph_node_set set) ob = lto_create_simple_output_block (LTO_section_cgraph); + output_profile_summary (ob); + /* An encoder for cgraph nodes should have been created by ipa_write_summaries_1. */ gcc_assert (ob->decl_state->cgraph_node_encoder); @@ -642,6 +663,35 @@ input_cgraph_1 (struct lto_file_decl_data *file_data, VEC_free (cgraph_node_ptr, heap, nodes); } +static struct gcov_ctr_summary lto_gcov_summary; + +/* Input profile_info from IB. */ +static void +input_profile_summary (struct lto_input_block *ib) +{ + unsigned int runs = lto_input_uleb128 (ib); + if (runs) + { + if (!profile_info) + { + profile_info = <o_gcov_summary; + lto_gcov_summary.runs = runs; + lto_gcov_summary.sum_all = lto_input_sleb128 (ib); + lto_gcov_summary.run_max = lto_input_sleb128 (ib); + lto_gcov_summary.sum_max = lto_input_sleb128 (ib); + } + /* We can support this by scaling all counts to nearest common multiple + of all different runs, but it is perhaps not worth the effort. */ + else if (profile_info->runs != runs + || profile_info->sum_all != lto_input_sleb128 (ib) + || profile_info->run_max != lto_input_sleb128 (ib) + || profile_info->sum_max != lto_input_sleb128 (ib)) + sorry ("Combining units with different profiles is not supported."); + /* We allow some units to have profile and other to not have one. This will + just make unprofiled units to be size optimized that is sane. */ + } + +} /* Input and merge the cgraph from each of the .o files passed to lto1. */ @@ -662,6 +712,7 @@ input_cgraph (void) ib = lto_create_simple_input_block (file_data, LTO_section_cgraph, &data, &len); + input_profile_summary (ib); file_data->cgraph_node_encoder = lto_cgraph_encoder_new (); input_cgraph_1 (file_data, ib); lto_destroy_simple_input_block (file_data, LTO_section_cgraph, diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c index 95ab49a7543..2b75461b188 100644 --- a/gcc/tree-profile.c +++ b/gcc/tree-profile.c @@ -82,7 +82,7 @@ tree_init_ic_make_global_vars (void) TREE_PUBLIC (ic_void_ptr_var) = 0; DECL_ARTIFICIAL (ic_void_ptr_var) = 1; DECL_INITIAL (ic_void_ptr_var) = NULL; - assemble_variable (ic_void_ptr_var, 0, 0, 0); + varpool_finalize_decl (ic_void_ptr_var); gcov_type_ptr = build_pointer_type (get_gcov_type ()); ic_gcov_type_ptr_var @@ -93,7 +93,7 @@ tree_init_ic_make_global_vars (void) TREE_PUBLIC (ic_gcov_type_ptr_var) = 0; DECL_ARTIFICIAL (ic_gcov_type_ptr_var) = 1; DECL_INITIAL (ic_gcov_type_ptr_var) = NULL; - assemble_variable (ic_gcov_type_ptr_var, 0, 0, 0); + varpool_finalize_decl (ic_gcov_type_ptr_var); } static void @@ -159,6 +159,14 @@ tree_init_edge_profiler (void) tree_ior_profiler_fn = build_fn_decl ("__gcov_ior_profiler", average_profiler_fn_type); + /* LTO streamer needs assembler names. Because we create these decls + late, we need to initialize them by hand. */ + DECL_ASSEMBLER_NAME (tree_interval_profiler_fn); + DECL_ASSEMBLER_NAME (tree_pow2_profiler_fn); + DECL_ASSEMBLER_NAME (tree_one_value_profiler_fn); + DECL_ASSEMBLER_NAME (tree_indirect_call_profiler_fn); + DECL_ASSEMBLER_NAME (tree_average_profiler_fn); + DECL_ASSEMBLER_NAME (tree_ior_profiler_fn); } }