* 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
+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.
$(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) \
$(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)
}
}
}
+
+/* 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;
+}
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. */
}
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);
+}
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 *,
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 *);
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'. */
#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. */
unsigned HOST_WIDE_INT num_ops;
size_t i;
struct bitpack_d bp;
+ bool has_hist;
code = lto_tag_to_gimple_code (tag);
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. */
/* 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;
}
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);
#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. */
enum gimple_code code;
enum LTO_tags tag;
struct bitpack_d bp;
+ histogram_value hist;
/* Emit identifying tag. */
code = gimple_code (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. */
default:
gcc_unreachable ();
}
+ if (hist)
+ stream_out_histogram_value (ob, hist);
}
: 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);
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)
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,
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);
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);
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);
{
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);
}
}
#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
}
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
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)
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);