/* Calculate branch probabilities, and basic block execution counts.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+ 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by James E. Wilson, UC Berkeley/Cygnus Support;
based on some ideas from Dain Samples of UC Berkeley.
#include "regs.h"
#include "expr.h"
#include "function.h"
-#include "toplev.h"
+#include "basic-block.h"
+#include "diagnostic-core.h"
#include "coverage.h"
#include "value-prof.h"
#include "tree.h"
#include "profile.h"
-/* Hooks for profiling. */
-static struct profile_hooks* profile_hooks;
-
struct bb_info {
unsigned int count_valid : 1;
fprintf (dump_file, "Edge %d to %d instrumented%s\n",
e->src->index, e->dest->index,
EDGE_CRITICAL_P (e) ? " (and split)" : "");
- (profile_hooks->gen_edge_profiler) (num_instr_edges++, e);
+ gimple_gen_edge_profiler (num_instr_edges++, e);
}
}
}
switch (hist->type)
{
case HIST_TYPE_INTERVAL:
- (profile_hooks->gen_interval_profiler) (hist, t, 0);
+ gimple_gen_interval_profiler (hist, t, 0);
break;
case HIST_TYPE_POW2:
- (profile_hooks->gen_pow2_profiler) (hist, t, 0);
+ gimple_gen_pow2_profiler (hist, t, 0);
break;
case HIST_TYPE_SINGLE_VALUE:
- (profile_hooks->gen_one_value_profiler) (hist, t, 0);
+ gimple_gen_one_value_profiler (hist, t, 0);
break;
case HIST_TYPE_CONST_DELTA:
- (profile_hooks->gen_const_delta_profiler) (hist, t, 0);
+ gimple_gen_const_delta_profiler (hist, t, 0);
break;
case HIST_TYPE_INDIR_CALL:
- (profile_hooks->gen_ic_profiler) (hist, t, 0);
+ gimple_gen_ic_profiler (hist, t, 0);
break;
case HIST_TYPE_AVERAGE:
- (profile_hooks->gen_average_profiler) (hist, t, 0);
+ gimple_gen_average_profiler (hist, t, 0);
break;
case HIST_TYPE_IOR:
- (profile_hooks->gen_ior_profiler) (hist, t, 0);
+ gimple_gen_ior_profiler (hist, t, 0);
break;
default:
{
if (dump_file)
{
- fprintf (dump_file, "BB %i count does not match sum of incomming edges "
+ fprintf (dump_file, "BB %i count does not match sum of incoming edges "
HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
bb->index,
bb->count,
e->count = exec_counts[exec_counts_pos++];
if (e->count > profile_info->sum_max)
{
- error ("corrupted profile info: edge from %i to %i exceeds maximal count",
- bb->index, e->dest->index);
+ if (flag_profile_correction)
+ {
+ static bool informed = 0;
+ if (!informed)
+ inform (input_location,
+ "corrupted profile info: edge count exceeds maximal count");
+ informed = 1;
+ }
+ else
+ error ("corrupted profile info: edge from %i to %i exceeds maximal count",
+ bb->index, e->dest->index);
}
}
else
return;
}
- name_differs = !prev_file_name || strcmp (file_name, prev_file_name);
+ name_differs = !prev_file_name || filename_cmp (file_name, prev_file_name);
line_differs = prev_line != line;
if (name_differs || line_differs)
/* It may happen that there are compiler generated statements
without a locus at all. Go through the basic block from the
last to the first statement looking for a locus. */
- for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
+ for (gsi = gsi_last_nondebug_bb (bb);
+ !gsi_end_p (gsi);
+ gsi_prev_nondebug (&gsi))
{
last = gsi_stmt (gsi);
if (gimple_has_location (last))
/* Line numbers. */
if (coverage_begin_output ())
{
- gcov_position_t offset;
-
/* Initialize the output. */
output_location (NULL, 0, NULL, NULL);
FOR_EACH_BB (bb)
{
gimple_stmt_iterator gsi;
-
- offset = 0;
+ gcov_position_t offset = 0;
if (bb == ENTRY_BLOCK_PTR->next_bb)
{
&offset, bb);
}
- /* Notice GOTO expressions we eliminated while constructing the
- CFG. */
+ /* Notice GOTO expressions eliminated while constructing the CFG. */
if (single_succ_p (bb)
&& single_succ_edge (bb)->goto_locus != UNKNOWN_LOCATION)
{
- location_t curr_location = single_succ_edge (bb)->goto_locus;
- /* ??? The FILE/LINE API is inconsistent for these cases. */
- output_location (LOCATION_FILE (curr_location),
- LOCATION_LINE (curr_location), &offset, bb);
+ expanded_location curr_location
+ = expand_location (single_succ_edge (bb)->goto_locus);
+ output_location (curr_location.file, curr_location.line,
+ &offset, bb);
}
if (offset)
#undef BB_TO_GCOV_INDEX
if (flag_profile_values)
- find_values_to_profile (&values);
+ gimple_find_values_to_profile (&values);
if (flag_branch_probabilities)
{
{
unsigned n_instrumented;
- profile_hooks->init_edge_profiler ();
+ gimple_init_edge_profiler ();
n_instrumented = instrument_edges (el);
}
}
-/* Set up hooks to enable tree-based profiling. */
-
-void
-tree_register_profile_hooks (void)
-{
- gcc_assert (current_ir_type () == IR_GIMPLE);
- profile_hooks = &tree_profile_hooks;
-}