summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-28 15:29:40 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2013-03-28 15:29:40 +0000
commitfc44a215aec90430e9d4b4c066c6b93f7ebc915d (patch)
tree35ba8ad462caf0907fefeff0406e6ef831248073
parenta706be2ea60dedff74ab4a1589b6e7acad2a34c7 (diff)
downloadppe42-gcc-fc44a215aec90430e9d4b4c066c6b93f7ebc915d.tar.gz
ppe42-gcc-fc44a215aec90430e9d4b4c066c6b93f7ebc915d.zip
* data-streamer-in.c (streamer_read_gcov_count): New function.
* gimple-streamer-out.c: Include value-prof.h. (output_gimple_stmt): Output histogram. (output_bb): Use streamer_write_gcov_count. * value-prof.c: Include data-streamer.h (dump_histogram_value): Add HIST_TYPE_MAX. (stream_out_histogram_value): New function. (stream_in_histogram_value): New function. * value-prof.h (enum hist_type): Add HIST_TYPE_MAX. (stream_out_histogram_value, stream_in_histogram_value): Declare. * data-streamer-out.c (streamer_write_gcov_count): New function. (streamer_write_gcov_count_stream): New function. * lto-cgraph.c (lto_output_edge): Update counter streaming. (lto_output_node): Likewise. (input_node, input_edge): Likewise. * lto-streamer-out.c (output_cfg): Update streaming. * lto-streamer-in.c (input_cfg): Likewise. * data-streamer.h (streamer_write_gcov_count, streamer_write_gcov_count_stream, streamer_read_gcov_count): Declare. * gimple-streamer-in.c: Include value-prof.h (input_gimple_stmt): Input histograms. (input_bb): Update profile streaming. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197205 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog26
-rw-r--r--gcc/Makefile.in6
-rw-r--r--gcc/data-streamer-in.c10
-rw-r--r--gcc/data-streamer-out.c17
-rw-r--r--gcc/data-streamer.h3
-rw-r--r--gcc/gimple-streamer-in.c7
-rw-r--r--gcc/gimple-streamer-out.c8
-rw-r--r--gcc/lto-cgraph.c8
-rw-r--r--gcc/lto-streamer-in.c2
-rw-r--r--gcc/lto-streamer-out.c2
-rw-r--r--gcc/value-prof.c90
-rw-r--r--gcc/value-prof.h5
12 files changed, 172 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 84245d54a57..36ba256ea7b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,9 +1,35 @@
+2013-03-28 Jan Hubicka <jh@suse.cz>
+
+ * data-streamer-in.c (streamer_read_gcov_count): New function.
+ * gimple-streamer-out.c: Include value-prof.h.
+ (output_gimple_stmt): Output histogram.
+ (output_bb): Use streamer_write_gcov_count.
+ * value-prof.c: Include data-streamer.h
+ (dump_histogram_value): Add HIST_TYPE_MAX.
+ (stream_out_histogram_value): New function.
+ (stream_in_histogram_value): New function.
+ * value-prof.h (enum hist_type): Add HIST_TYPE_MAX.
+ (stream_out_histogram_value, stream_in_histogram_value): Declare.
+ * data-streamer-out.c (streamer_write_gcov_count): New function.
+ (streamer_write_gcov_count_stream): New function.
+ * lto-cgraph.c (lto_output_edge): Update counter streaming.
+ (lto_output_node): Likewise.
+ (input_node, input_edge): Likewise.
+ * lto-streamer-out.c (output_cfg): Update streaming.
+ * lto-streamer-in.c (input_cfg): Likewise.
+ * data-streamer.h (streamer_write_gcov_count,
+ streamer_write_gcov_count_stream, streamer_read_gcov_count): Declare.
+ * gimple-streamer-in.c: Include value-prof.h
+ (input_gimple_stmt): Input histograms.
+ (input_bb): Update profile streaming.
+
2013-03-28 Kenneth Zadeck <zadeck@naturalbridge.com>
* genmodes.c (emit_max_int): New function.
(emit_insn_modes_h): Added call to emit_max_function.
* doc/rtl.texi (MAX_BITSIZE_MODE_ANY_INT, MAX_BITSIZE_MODE_ANY_MODE): Added doc.
* machmode.def: Fixed comment.
+
2013-03-28 Kenneth Zadeck <zadeck@naturalbridge.com>
* combine.c (try_combine): Removed useless assert.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index b60e1f84fec..54ec7e1260e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2137,9 +2137,9 @@ lto-compress.o: lto-compress.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TREE_H) langhooks.h $(LTO_STREAMER_H) $(LTO_SECTION_H) \
lto-compress.h $(DIAGNOSTIC_CORE_H) $(DIAGNOSTIC_CORE_H)
data-streamer-in.o: data-streamer-in.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
- $(DATA_STREAMER_H) $(DIAGNOSTIC_H)
+ $(DATA_STREAMER_H) $(DIAGNOSTIC_H) value-prof.h
data-streamer-out.o: data-streamer-out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
- $(DATA_STREAMER_H)
+ $(DATA_STREAMER_H) value-prof.h
data-streamer.o: data-streamer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(DATA_STREAMER_H)
gimple-streamer-in.o: gimple-streamer-in.c $(CONFIG_H) $(SYSTEM_H) \
@@ -3088,7 +3088,7 @@ value-prof.o : value-prof.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_
$(RECOG_H) insn-config.h $(OPTABS_H) $(REGS_H) $(GGC_H) $(DIAGNOSTIC_H) \
$(TREE_H) $(COVERAGE_H) $(RTL_H) $(GCOV_IO_H) $(TREE_FLOW_H) \
tree-flow-inline.h $(TIMEVAR_H) $(DIAGNOSTIC_CORE_H) pointer-set.h \
- $(GIMPLE_PRETTY_PRINT_H)
+ $(GIMPLE_PRETTY_PRINT_H) $(DATA_STREAMER_H)
loop-doloop.o : loop-doloop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h dumpfile.h $(TM_H) \
$(RTL_H) $(FLAGS_H) $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) $(TM_P_H) \
$(DIAGNOSTIC_CORE_H) $(CFGLOOP_H) $(PARAMS_H) $(TARGET_H)
diff --git a/gcc/data-streamer-in.c b/gcc/data-streamer-in.c
index 0f83aa69808..e9ceb29312a 100644
--- a/gcc/data-streamer-in.c
+++ b/gcc/data-streamer-in.c
@@ -158,3 +158,13 @@ streamer_read_hwi (struct lto_input_block *ib)
}
}
}
+
+/* Read gcov_type value from IB. */
+
+gcov_type
+streamer_read_gcov_count (struct lto_input_block *ib)
+{
+ gcov_type ret = streamer_read_hwi (ib);
+ gcc_assert (ret >= 0);
+ return ret;
+}
diff --git a/gcc/data-streamer-out.c b/gcc/data-streamer-out.c
index ad50263fc96..72f4f72e1bb 100644
--- a/gcc/data-streamer-out.c
+++ b/gcc/data-streamer-out.c
@@ -174,6 +174,13 @@ streamer_write_hwi (struct output_block *ob, HOST_WIDE_INT work)
streamer_write_hwi_stream (ob->main_stream, work);
}
+/* Write a gcov counter value WORK to OB->main_stream. */
+
+void
+streamer_write_gcov_count (struct output_block *ob, gcov_type work)
+{
+ streamer_write_gcov_count_stream (ob->main_stream, work);
+}
/* Write an unsigned HOST_WIDE_INT value WORK to OBS. */
@@ -216,3 +223,13 @@ streamer_write_hwi_stream (struct lto_output_stream *obs, HOST_WIDE_INT work)
}
while (more);
}
+
+/* Write a GCOV counter value WORK to OBS. */
+
+void
+streamer_write_gcov_count_stream (struct lto_output_stream *obs, gcov_type work)
+{
+ gcc_assert (work >= 0);
+ gcc_assert ((HOST_WIDE_INT) work == work);
+ streamer_write_hwi_stream (obs, work);
+}
diff --git a/gcc/data-streamer.h b/gcc/data-streamer.h
index 288da283d8f..e2ab7adfad6 100644
--- a/gcc/data-streamer.h
+++ b/gcc/data-streamer.h
@@ -63,6 +63,7 @@ HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
void streamer_write_zero (struct output_block *);
void streamer_write_uhwi (struct output_block *, unsigned HOST_WIDE_INT);
void streamer_write_hwi (struct output_block *, HOST_WIDE_INT);
+void streamer_write_gcov_count (struct output_block *, gcov_type);
void streamer_write_string (struct output_block *, struct lto_output_stream *,
const char *, bool);
unsigned streamer_string_index (struct output_block *, const char *,
@@ -77,6 +78,7 @@ void bp_pack_string (struct output_block *, struct bitpack_d *,
void streamer_write_uhwi_stream (struct lto_output_stream *,
unsigned HOST_WIDE_INT);
void streamer_write_hwi_stream (struct lto_output_stream *, HOST_WIDE_INT);
+void streamer_write_gcov_count_stream (struct lto_output_stream *, gcov_type);
/* In data-streamer-in.c */
const char *string_for_index (struct data_in *, unsigned int, unsigned int *);
@@ -89,6 +91,7 @@ const char *bp_unpack_indexed_string (struct data_in *, struct bitpack_d *,
const char *bp_unpack_string (struct data_in *, struct bitpack_d *);
unsigned HOST_WIDE_INT streamer_read_uhwi (struct lto_input_block *);
HOST_WIDE_INT streamer_read_hwi (struct lto_input_block *);
+gcov_type streamer_read_gcov_count (struct lto_input_block *);
/* Returns a hash code for P. Adapted from libiberty's htab_hash_string
to support strings that may not end in '\0'. */
diff --git a/gcc/gimple-streamer-in.c b/gcc/gimple-streamer-in.c
index aff589a4c8f..cedacb6642c 100644
--- a/gcc/gimple-streamer-in.c
+++ b/gcc/gimple-streamer-in.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "data-streamer.h"
#include "tree-streamer.h"
#include "gimple-streamer.h"
+#include "value-prof.h"
/* Read a PHI function for basic block BB in function FN. DATA_IN is
the file being read. IB is the input block to use for reading. */
@@ -86,6 +87,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
unsigned HOST_WIDE_INT num_ops;
size_t i;
struct bitpack_d bp;
+ bool has_hist;
code = lto_tag_to_gimple_code (tag);
@@ -97,6 +99,7 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
if (is_gimple_assign (stmt))
stmt->gsbase.nontemporal_move = bp_unpack_value (&bp, 1);
stmt->gsbase.has_volatile_ops = bp_unpack_value (&bp, 1);
+ has_hist = bp_unpack_value (&bp, 1);
stmt->gsbase.subcode = bp_unpack_var_len_unsigned (&bp);
/* Read location information. */
@@ -300,6 +303,8 @@ input_gimple_stmt (struct lto_input_block *ib, struct data_in *data_in,
/* Mark the statement modified so its operand vectors can be filled in. */
gimple_set_modified (stmt, true);
+ if (has_hist)
+ stream_in_histogram_value (ib, stmt);
return stmt;
}
@@ -324,7 +329,7 @@ input_bb (struct lto_input_block *ib, enum LTO_tags tag,
index = streamer_read_uhwi (ib);
bb = BASIC_BLOCK_FOR_FUNCTION (fn, index);
- bb->count = (streamer_read_hwi (ib) * count_materialization_scale
+ bb->count = (streamer_read_gcov_count (ib) * count_materialization_scale
+ REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
bb->frequency = streamer_read_hwi (ib);
bb->flags = streamer_read_hwi (ib);
diff --git a/gcc/gimple-streamer-out.c b/gcc/gimple-streamer-out.c
index adf230ed93a..0b8d8c1d251 100644
--- a/gcc/gimple-streamer-out.c
+++ b/gcc/gimple-streamer-out.c
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-streamer.h"
#include "lto-streamer.h"
#include "tree-streamer.h"
+#include "value-prof.h"
/* Output PHI function PHI to the main stream in OB. */
@@ -59,6 +60,7 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
enum gimple_code code;
enum LTO_tags tag;
struct bitpack_d bp;
+ histogram_value hist;
/* Emit identifying tag. */
code = gimple_code (stmt);
@@ -72,6 +74,8 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
if (is_gimple_assign (stmt))
bp_pack_value (&bp, gimple_assign_nontemporal_move_p (stmt), 1);
bp_pack_value (&bp, gimple_has_volatile_ops (stmt), 1);
+ hist = gimple_histogram_value (cfun, stmt);
+ bp_pack_value (&bp, hist != NULL, 1);
bp_pack_var_len_unsigned (&bp, stmt->gsbase.subcode);
/* Emit location information for the statement. */
@@ -167,6 +171,8 @@ output_gimple_stmt (struct output_block *ob, gimple stmt)
default:
gcc_unreachable ();
}
+ if (hist)
+ stream_out_histogram_value (ob, hist);
}
@@ -183,7 +189,7 @@ output_bb (struct output_block *ob, basic_block bb, struct function *fn)
: LTO_bb0);
streamer_write_uhwi (ob, bb->index);
- streamer_write_hwi (ob, bb->count);
+ streamer_write_gcov_count (ob, bb->count);
streamer_write_hwi (ob, bb->frequency);
streamer_write_hwi (ob, bb->flags);
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 8cf57c6f937..d9d798a2ade 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -267,7 +267,7 @@ lto_output_edge (struct lto_simple_output_block *ob, struct cgraph_edge *edge,
streamer_write_hwi_stream (ob->main_stream, ref);
}
- streamer_write_hwi_stream (ob->main_stream, edge->count);
+ streamer_write_gcov_count_stream (ob->main_stream, edge->count);
bp = bitpack_create (ob->main_stream);
uid = (!gimple_has_body_p (edge->caller->symbol.decl)
@@ -429,7 +429,7 @@ lto_output_node (struct lto_simple_output_block *ob, struct cgraph_node *node,
lto_output_fn_decl_index (ob->decl_state, ob->main_stream, node->symbol.decl);
- streamer_write_hwi_stream (ob->main_stream, node->count);
+ streamer_write_gcov_count_stream (ob->main_stream, node->count);
streamer_write_hwi_stream (ob->main_stream, node->count_materialization_scale);
streamer_write_hwi_stream (ob->main_stream,
@@ -948,7 +948,7 @@ input_node (struct lto_file_decl_data *file_data,
if (order >= symtab_order)
symtab_order = order + 1;
- node->count = streamer_read_hwi (ib);
+ node->count = streamer_read_gcov_count (ib);
node->count_materialization_scale = streamer_read_hwi (ib);
count = streamer_read_hwi (ib);
@@ -1109,7 +1109,7 @@ input_edge (struct lto_input_block *ib, vec<symtab_node> nodes,
else
callee = NULL;
- count = (gcov_type) streamer_read_hwi (ib);
+ count = streamer_read_gcov_count (ib);
bp = streamer_read_bitpack (ib);
inline_failed = bp_unpack_enum (&bp, cgraph_inline_failed_enum, CIF_N_REASONS);
diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index f3a08884b53..0e128fddd78 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -622,7 +622,7 @@ input_cfg (struct lto_input_block *ib, struct function *fn,
dest_index = streamer_read_uhwi (ib);
probability = (int) streamer_read_hwi (ib);
- count = ((gcov_type) streamer_read_hwi (ib) * count_materialization_scale
+ count = ((gcov_type) streamer_read_gcov_count (ib) * count_materialization_scale
+ REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
edge_flags = streamer_read_uhwi (ib);
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index b205092f597..f9184c3c16f 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -644,7 +644,7 @@ output_cfg (struct output_block *ob, struct function *fn)
{
streamer_write_uhwi (ob, e->dest->index);
streamer_write_hwi (ob, e->probability);
- streamer_write_hwi (ob, e->count);
+ streamer_write_gcov_count (ob, e->count);
streamer_write_uhwi (ob, e->flags);
}
}
diff --git a/gcc/value-prof.c b/gcc/value-prof.c
index c120c82ad05..39bbdbf02e7 100644
--- a/gcc/value-prof.c
+++ b/gcc/value-prof.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see
#include "dumpfile.h"
#include "pointer-set.h"
#include "profile.h"
+#include "data-streamer.h"
/* In this file value profile based optimizations are placed. Currently the
following optimizations are implemented (for more detailed descriptions
@@ -333,9 +334,98 @@ dump_histogram_value (FILE *dump_file, histogram_value hist)
}
fprintf (dump_file, ".\n");
break;
+ case HIST_TYPE_MAX:
+ gcc_unreachable ();
}
}
+/* Dump information about HIST to DUMP_FILE. */
+
+void
+stream_out_histogram_value (struct output_block *ob, histogram_value hist)
+{
+ struct bitpack_d bp;
+ unsigned int i;
+
+ bp = bitpack_create (ob->main_stream);
+ bp_pack_enum (&bp, hist_type, HIST_TYPE_MAX, hist->type);
+ bp_pack_value (&bp, hist->hvalue.next != NULL, 1);
+ streamer_write_bitpack (&bp);
+ switch (hist->type)
+ {
+ case HIST_TYPE_INTERVAL:
+ streamer_write_hwi (ob, hist->hdata.intvl.int_start);
+ streamer_write_uhwi (ob, hist->hdata.intvl.steps);
+ break;
+ default:
+ break;
+ }
+ for (i = 0; i < hist->n_counters; i++)
+ streamer_write_gcov_count (ob, hist->hvalue.counters[i]);
+ if (hist->hvalue.next)
+ stream_out_histogram_value (ob, hist->hvalue.next);
+}
+/* Dump information about HIST to DUMP_FILE. */
+
+void
+stream_in_histogram_value (struct lto_input_block *ib, gimple stmt)
+{
+ enum hist_type type;
+ unsigned int ncounters = 0;
+ struct bitpack_d bp;
+ unsigned int i;
+ histogram_value new_val;
+ bool next;
+ histogram_value *next_p = NULL;
+
+ do
+ {
+ bp = streamer_read_bitpack (ib);
+ type = bp_unpack_enum (&bp, hist_type, HIST_TYPE_MAX);
+ next = bp_unpack_value (&bp, 1);
+ new_val = gimple_alloc_histogram_value (cfun, type, stmt, NULL);
+ switch (type)
+ {
+ case HIST_TYPE_INTERVAL:
+ new_val->hdata.intvl.int_start = streamer_read_hwi (ib);
+ new_val->hdata.intvl.steps = streamer_read_uhwi (ib);
+ ncounters = new_val->hdata.intvl.steps + 2;
+ break;
+
+ case HIST_TYPE_POW2:
+ case HIST_TYPE_AVERAGE:
+ ncounters = 2;
+ break;
+
+ case HIST_TYPE_SINGLE_VALUE:
+ case HIST_TYPE_INDIR_CALL:
+ ncounters = 3;
+ break;
+
+ case HIST_TYPE_CONST_DELTA:
+ ncounters = 4;
+ break;
+
+ case HIST_TYPE_IOR:
+ ncounters = 1;
+ break;
+ case HIST_TYPE_MAX:
+ gcc_unreachable ();
+ }
+ new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * ncounters);
+ new_val->n_counters = ncounters;
+ for (i = 0; i < ncounters; i++)
+ new_val->hvalue.counters[i] = streamer_read_gcov_count (ib);
+ debug_gimple_stmt (stmt);
+ if (!next_p)
+ gimple_add_histogram_value (cfun, stmt, new_val);
+ else
+ *next_p = new_val;
+ next_p = &new_val->hvalue.next;
+ }
+ while (next);
+}
+
/* Dump all histograms attached to STMT to DUMP_FILE. */
void
diff --git a/gcc/value-prof.h b/gcc/value-prof.h
index b6c77b6d65f..7030d90e988 100644
--- a/gcc/value-prof.h
+++ b/gcc/value-prof.h
@@ -33,7 +33,8 @@ enum hist_type
HIST_TYPE_INDIR_CALL, /* Tries to identify the function that is (almost)
called in indirect call */
HIST_TYPE_AVERAGE, /* Compute average value (sum of all values). */
- HIST_TYPE_IOR /* Used to compute expected alignment. */
+ HIST_TYPE_IOR, /* Used to compute expected alignment. */
+ HIST_TYPE_MAX
};
#define COUNTER_FOR_HIST_TYPE(TYPE) ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)
@@ -98,6 +99,8 @@ extern void gimple_gen_const_delta_profiler (histogram_value,
unsigned, unsigned);
extern void gimple_gen_average_profiler (histogram_value, unsigned, unsigned);
extern void gimple_gen_ior_profiler (histogram_value, unsigned, unsigned);
+extern void stream_out_histogram_value (struct output_block *, histogram_value);
+extern void stream_in_histogram_value (struct lto_input_block *, gimple);
/* In profile.c. */
extern void init_branch_prob (void);
OpenPOWER on IntegriCloud