+2009-11-11 Jan Hubicka <jh@suse.cz>
+
+ * 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 <kai.tietz@onevision.com>
* config/i386/cygming.h (HANDLE_PRAGMA_PUSH_POP_MACRO):
$(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) \
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),
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);
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));
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). */
#include "output.h"
#include "pointer-set.h"
#include "lto-streamer.h"
+#include "gcov-io.h"
/* Create a new cgraph encoder. */
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. */
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);
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. */
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,
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
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
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);
}
}