GCC Middle and Back End API Reference
profile.c File Reference

Data Structures

struct  bb_info

Functions

static void find_spanning_tree (struct edge_list *)
static unsigned instrument_edges ()
static void instrument_values ()
void get_working_sets ()
gcov_working_set_tfind_working_set ()
static gcov_typeget_exec_counts ()
static bool is_edge_inconsistent ()
static void correct_negative_edge_counts ()
static bool is_inconsistent ()
static void set_bb_counts ()
static int read_profile_edge_counts ()
static int compute_frequency_overlap ()
static void compute_branch_probabilities ()
static void compute_value_histograms (histogram_values values, unsigned cfg_checksum, unsigned lineno_checksum)
static void output_location (char const *file_name, int line, gcov_position_t *offset, basic_block bb)
void branch_prob ()
static basic_block find_group ()
static void union_groups ()
static void find_spanning_tree ()
void init_branch_prob ()
void end_branch_prob ()

Variables

struct gcov_ctr_summaryprofile_info
static gcov_working_set_t gcov_working_sets [NUM_GCOV_WORKING_SETS]
static int total_num_blocks
static int total_num_edges
static int total_num_edges_ignored
static int total_num_edges_instrumented
static int total_num_blocks_created
static int total_num_passes
static int total_num_times_called
static int total_hist_br_prob [20]
static int total_num_branches

Function Documentation

void branch_prob ( void  )
Instrument and/or analyze program behavior based on program the CFG.

   This function creates a representation of the control flow graph (of
   the function being compiled) that is suitable for the instrumentation
   of edges and/or converting measured edge counts to counts on the
   complete CFG.

   When FLAG_PROFILE_ARCS is nonzero, this function instruments the edges in
   the flow graph that are needed to reconstruct the dynamic behavior of the
   flow graph.  This data is written to the gcno file for gcov.

   When FLAG_BRANCH_PROBABILITIES is nonzero, this function reads auxiliary
   information from the gcda file containing edge count information from
   previous executions of the function being compiled.  In this case, the
   control flow graph is annotated with actual execution counts by
   compute_branch_probabilities().

   Main entry point of this file.   

References add_noreturn_fake_exit_edges(), alloc_aux_for_edges(), BUILT_IN_NORMAL, compact_blocks(), compute_branch_probabilities(), compute_value_histograms(), edge_def::count, coverage_begin_function(), coverage_compute_cfg_checksum(), coverage_compute_lineno_checksum(), coverage_counter_alloc(), coverage_end_function(), create_edge_list(), curr_location, current_function_decl, edge_def::dest, dump_file, expand_location(), find_spanning_tree(), first, edge_def::flags, flow_call_edges_add(), free_aux_for_edges(), free_edge_list(), gcov_write_length(), gcov_write_string(), gcov_write_tag(), gcov_write_unsigned(), gimple_call_flags(), gimple_call_fndecl(), gimple_filename(), gimple_find_values_to_profile(), gimple_has_location(), gimple_init_edge_profiler(), gimple_lineno(), gimple_location(), edge_def::goto_locus, gsi_after_labels(), gsi_commit_edge_inserts(), gsi_end_p(), gsi_last_nondebug_bb(), gsi_next(), gsi_next_nondebug(), gsi_prev_nondebug(), gsi_start_bb(), gsi_stmt(), edge_info::ignore, basic_block_def::index, instrument_edges(), instrument_values(), is_gimple_call(), is_gimple_debug(), last, make_edge(), basic_block_def::next_bb, edge_list::num_edges, offset, edge_info::on_tree, output_location(), basic_block_def::preds, remove_fake_edges(), single_succ_edge(), single_succ_p(), split_block_after_labels(), split_edge(), edge_def::src, basic_block_def::succs, total_num_blocks, total_num_edges, total_num_edges_ignored, total_num_edges_instrumented, and total_num_times_called.

Referenced by tree_profiling().

static int compute_frequency_overlap ( )
static
Compare the static estimated profile to the actual profile, and
   return the "degree of overlap" measure between them.

   Degree of overlap is a number between 0 and OVERLAP_BASE. It is
   the sum of each basic block's minimum relative weights between
   two profiles. And overlap of OVERLAP_BASE means two profiles are
   identical.   

References basic_block_def::count, and basic_block_def::frequency.

Referenced by compute_branch_probabilities().

static void compute_value_histograms ( histogram_values  values,
unsigned  cfg_checksum,
unsigned  lineno_checksum 
)
static
Load value histograms values whose description is stored in VALUES array
   from .gcda file.  

   CFG_CHECKSUM is the precomputed checksum for the CFG.   

References cfun, histogram_value_t::counters, free(), get_coverage_counts(), gimple_add_histogram_value(), histogram_value_t::hvalue, histogram_value_t::n_counters, histogram_value_t::stmt, and histogram_value_t::type.

Referenced by branch_prob().

static void correct_negative_edge_counts ( )
static
static basic_block find_group ( )
static
Union find algorithm implementation for the basic blocks using
   aux fields.   

References basic_block_def::aux.

Referenced by find_spanning_tree(), and union_groups().

static void find_spanning_tree ( struct edge_list )
static
Forward declarations.   

Referenced by branch_prob().

static void find_spanning_tree ( )
static
This function searches all of the edges in the program flow graph, and puts
   as many bad edges as possible onto the spanning tree.  Bad edges include
   abnormals edges, which can't be instrumented at the moment.  Since it is
   possible for fake edges to form a cycle, we will have to develop some
   better way in the future.  Also put critical edges to the tree, since they
   are more expensive to instrument.   

References basic_block_def::aux, clear_aux_for_blocks(), edge_def::dest, dump_file, find_group(), edge_def::flags, edge_info::ignore, basic_block_def::index, edge_def::src, and union_groups().

gcov_working_set_t* find_working_set ( )
Given a the desired percentage of the full profile (sum_all from the
   summary), multiplied by 10 to avoid float in PCT_TIMES_10, returns
   the corresponding working set information. If an exact match for
   the percentage isn't found, the closest value is used.   
static gcov_type* get_exec_counts ( )
static
Computes hybrid profile for all matching entries in da_file.  
   
   CFG_CHECKSUM is the precomputed checksum for the CFG.   

References dump_file, get_coverage_counts(), get_working_sets(), edge_info::ignore, edge_info::on_tree, gcov_ctr_summary::runs, basic_block_def::succs, and gcov_ctr_summary::sum_max.

Referenced by compute_branch_probabilities().

void get_working_sets ( void  )
Fill the working set information into the profile_info structure.   

References compute_working_sets(), dump_file, HOST_WIDEST_INT, HOST_WIDEST_INT_PRINT_DEC, gcov_working_set_info::min_counter, and gcov_working_set_info::num_counters.

Referenced by get_exec_counts(), and input_symtab().

void init_branch_prob ( void  )
static unsigned instrument_edges ( )
static
Add edge instrumentation code to the entire insn chain.

   F is the first insn of the chain.
   NUM_BLOCKS is the number of basic blocks found in F.   

References edge_def::dest, dump_file, edge_def::flags, gimple_gen_edge_profiler(), edge_info::ignore, basic_block_def::index, edge_info::on_tree, edge_def::src, basic_block_def::succs, and total_num_blocks_created.

Referenced by branch_prob().

static void output_location ( char const *  file_name,
int  line,
gcov_position_t offset,
basic_block  bb 
)
static
When passed NULL as file_name, initialize.
   When passed something else, output the necessary commands to change
   line to LINE and offset to FILE_NAME.   

References gcov_write_string(), gcov_write_tag(), gcov_write_unsigned(), and basic_block_def::index.

Referenced by branch_prob().

static int read_profile_edge_counts ( )
static
static void set_bb_counts ( )
static
Set each basic block count to the sum of its outgoing edge counts  

References basic_block_def::count, basic_block_def::succs, and sum_edge_counts().

Referenced by compute_branch_probabilities().

static void union_groups ( )
static

References basic_block_def::aux, and find_group().

Referenced by find_spanning_tree().


Variable Documentation

gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS]
static
Counter working set information computed from the current counter
   summary. Not initialized unless profile_info summary is non-NULL.   

Referenced by dump_working_sets().

int total_hist_br_prob[20]
static
int total_num_blocks
static
Collect statistics on the performance of this pass for the entire source
   file.   

Referenced by branch_prob(), end_branch_prob(), and init_branch_prob().

int total_num_blocks_created
static
int total_num_branches
static
int total_num_edges
static
int total_num_edges_ignored
static
int total_num_edges_instrumented
static
int total_num_passes
static
int total_num_times_called
static