GCC Middle and Back End API Reference
value-prof.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  histogram_value_t
 

Macros

#define COUNTER_FOR_HIST_TYPE(TYPE)   ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)
 
#define HIST_TYPE_FOR_COUNTER(COUNTER)    ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))
 

Typedefs

typedef struct histogram_value_thistogram_value
 
typedef const struct histogram_value_tconst_histogram_value
 
typedef vec< histogram_valuehistogram_values
 

Enumerations

enum  hist_type {
  HIST_TYPE_INTERVAL , HIST_TYPE_POW2 , HIST_TYPE_TOPN_VALUES , HIST_TYPE_INDIR_CALL ,
  HIST_TYPE_AVERAGE , HIST_TYPE_IOR , HIST_TYPE_TIME_PROFILE , HIST_TYPE_MAX
}
 

Functions

void gimple_find_values_to_profile (histogram_values *)
 
bool gimple_value_profile_transformations (void)
 
histogram_value gimple_alloc_histogram_value (struct function *, enum hist_type, gimple *stmt=NULL, tree value=NULL_TREE)
 
histogram_value gimple_histogram_value (struct function *, gimple *)
 
histogram_value gimple_histogram_value_of_type (struct function *, gimple *, enum hist_type)
 
void gimple_add_histogram_value (struct function *, gimple *, histogram_value)
 
void dump_histograms_for_stmt (struct function *, FILE *, gimple *)
 
void gimple_remove_histogram_value (struct function *, gimple *, histogram_value)
 
void gimple_remove_stmt_histograms (struct function *, gimple *)
 
void gimple_duplicate_stmt_histograms (struct function *, gimple *, struct function *, gimple *)
 
void gimple_move_stmt_histograms (struct function *, gimple *, gimple *)
 
void verify_histograms (void)
 
void free_histograms (function *)
 
void stringop_block_profile (gimple *, unsigned int *, HOST_WIDE_INT *)
 
gcallgimple_ic (gcall *, struct cgraph_node *, profile_probability)
 
bool get_nth_most_common_value (gimple *stmt, const char *counter_type, histogram_value hist, gcov_type *value, gcov_type *count, gcov_type *all, unsigned n=0)
 
void gimple_init_gcov_profiler (void)
 
void gimple_gen_edge_profiler (int, edge)
 
void gimple_gen_interval_profiler (histogram_value, unsigned)
 
void gimple_gen_pow2_profiler (histogram_value, unsigned)
 
void gimple_gen_topn_values_profiler (histogram_value, unsigned)
 
void gimple_gen_ic_profiler (histogram_value, unsigned)
 
void gimple_gen_ic_func_profiler (void)
 
void gimple_gen_time_profiler (unsigned)
 
void gimple_gen_average_profiler (histogram_value, unsigned)
 
void gimple_gen_ior_profiler (histogram_value, unsigned)
 
void stream_out_histogram_value (struct output_block *, histogram_value)
 
void stream_in_histogram_value (class lto_input_block *, gimple *)
 
struct cgraph_nodefind_func_by_profile_id (int func_id)
 
void init_branch_prob (void)
 
void branch_prob (bool)
 
void read_thunk_profile (struct cgraph_node *)
 
void end_branch_prob (void)
 

Macro Definition Documentation

◆ COUNTER_FOR_HIST_TYPE

#define COUNTER_FOR_HIST_TYPE ( TYPE)    ((int) (TYPE) + GCOV_FIRST_VALUE_COUNTER)

◆ HIST_TYPE_FOR_COUNTER

#define HIST_TYPE_FOR_COUNTER ( COUNTER)     ((enum hist_type) ((COUNTER) - GCOV_FIRST_VALUE_COUNTER))

Typedef Documentation

◆ const_histogram_value

◆ histogram_value

◆ histogram_values

Enumeration Type Documentation

◆ hist_type

Definitions for transformations based on profile information for values.
   Copyright (C) 2003-2024 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.   
Supported histogram types.   
Enumerator
HIST_TYPE_INTERVAL 
HIST_TYPE_POW2 
HIST_TYPE_TOPN_VALUES 
HIST_TYPE_INDIR_CALL 
HIST_TYPE_AVERAGE 
HIST_TYPE_IOR 
HIST_TYPE_TIME_PROFILE 
HIST_TYPE_MAX 

Function Documentation

◆ branch_prob()

void branch_prob ( bool thunk)
extern
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_PROFILE_CONDITIONS is nonzero, this functions instruments the
edges in the control flow graph to track what conditions are evaluated to in
order to determine what conditions are covered and have an independent
effect on the outcome (modified condition/decision coverage).  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(), loop::any_estimate, cfun, compact_blocks(), compare_freqs(), compute_branch_probabilities(), compute_function_frequency(), compute_value_histograms(), basic_block_def::count, cov_blocks(), cov_free(), cov_length(), cov_maps(), cov_masks(), 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, DECL_SOURCE_LOCATION, dump_file, dump_flags, dump_function_to_file(), ECF_RETURNS_TWICE, EDGE_INFO, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK_PTR_FOR_FN, expand_location(), expected_loop_iterations_by_profile(), find_conditions(), find_spanning_tree(), flow_call_edges_add(), FOR_BB_BETWEEN, FOR_EACH_BB_FN, FOR_EACH_EDGE, free_aux_for_edges(), free_edge_list(), gcc_assert, gcc_checking_assert, GCOV_ARC_FAKE, GCOV_ARC_FALLTHROUGH, GCOV_ARC_ON_TREE, GCOV_TAG_ARCS, GCOV_TAG_BLOCKS, GCOV_TAG_CONDS, gcov_write_length(), gcov_write_string(), gcov_write_tag(), gcov_write_unsigned(), ggc_alloc(), gimple_call_builtin_p(), gimple_call_flags(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_filename(), gimple_find_values_to_profile(), gimple_has_location(), gimple_init_gcov_profiler(), gimple_lineno(), gimple_location(), gsi_commit_edge_inserts(), gsi_end_p(), gsi_last_nondebug_bb(), gsi_next(), gsi_prev_nondebug(), gsi_start_bb(), gsi_start_nondebug_after_labels_bb(), gsi_stmt(), loop::header, i, basic_block_def::index, INDEX_EDGE, instrument_decisions(), instrument_edges(), instrument_values(), profile_count::ipa(), is_gimple_call(), array_slice< T >::is_valid(), last, LOCATION_FILE, LOCATION_LINE, make_edge(), MAX, n_basic_blocks_for_fn, profile_count::nonzero_p(), NULL, NUM_EDGES, edge_list::num_edges, offset, output_location(), basic_block_def::preds, PROFILE_READ, profile_status_for_fn, qsort, record_niter_bound(), remove_fake_edges(), report_predictor_hitrates(), RESERVED_LOCATION_P, single_succ_edge(), single_succ_p(), split_block_after_labels(), split_edge(), basic_block_def::succs, TDF_DETAILS, total_num_blocks, total_num_conds, total_num_edges, total_num_edges_ignored, total_num_edges_instrumented, and total_num_times_called.

Referenced by tree_profiling().

◆ dump_histograms_for_stmt()

void dump_histograms_for_stmt ( struct function * fun,
FILE * dump_file,
gimple * stmt )
Dump all histograms attached to STMT to DUMP_FILE.   

References dump_file, dump_histogram_value(), ggc_alloc(), and gimple_histogram_value().

Referenced by gimple_dump_bb_buff(), and gimple_value_profile_transformations().

◆ end_branch_prob()

◆ find_func_by_profile_id()

struct cgraph_node * find_func_by_profile_id ( int profile_id)
extern
Return cgraph node for function with pid  

References cgraph_node_map, cgraph_node::get(), NULL, and cgraph_node::profile_id.

Referenced by speculative_call_summary::dump(), dump_ic_profile(), and ipa_profile().

◆ free_histograms()

void free_histograms ( function * fn)

◆ get_nth_most_common_value()

bool get_nth_most_common_value ( gimple * stmt,
const char * counter_type,
histogram_value hist,
gcov_type * value,
gcov_type * count,
gcov_type * all,
unsigned n )
Return the n-th value count of TOPN_VALUE histogram.  If
there's a value, return true and set VALUE and COUNT
arguments.

Counters have the following meaning.

abs (counters[0]) is the number of executions
for i in 0 ... TOPN-1
  counters[2 * i + 2] is target
  counters[2 * i + 3] is corresponding hitrate counter.

Value of counters[0] negative when counter became
full during merging and some values are lost.   

References abs_hwi(), check_counter(), count, dump_file, ggc_alloc(), gimple_bb(), i, PROFILE_REPRODUCIBILITY_MULTITHREADED, and PROFILE_REPRODUCIBILITY_PARALLEL_RUNS.

Referenced by dump_ic_profile(), gimple_divmod_fixed_value_transform(), gimple_stringops_transform(), and ipa_profile_generate_summary().

◆ gimple_add_histogram_value()

◆ gimple_alloc_histogram_value()

◆ gimple_duplicate_stmt_histograms()

◆ gimple_find_values_to_profile()

◆ gimple_gen_average_profiler()

void gimple_gen_average_profiler ( histogram_value value,
unsigned tag )
extern
Output instructions as GIMPLE trees to increment the average histogram
counter.  VALUE is the expression whose value is profiled.  TAG is the
tag of the section for counters, BASE is offset of the counter position.   

References force_gimple_operand_gsi(), ggc_alloc(), gimple_build_call(), gsi_for_stmt(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, histogram_value_t::hvalue, NULL_TREE, prepare_instrumented_value(), histogram_value_t::stmt, tree_average_profiler_fn, and tree_coverage_counter_addr().

Referenced by instrument_values().

◆ gimple_gen_edge_profiler()

void gimple_gen_edge_profiler ( int edgeno,
edge e )
extern
Output instructions as GIMPLE trees to increment the edge
execution count, and insert them on E.   

References gen_counter_update(), ggc_alloc(), gsi_last(), NULL_TREE, PENDING_STMT, and tree_coverage_counter_ref().

Referenced by instrument_edges().

◆ gimple_gen_ic_func_profiler()

◆ gimple_gen_ic_profiler()

void gimple_gen_ic_profiler ( histogram_value value,
unsigned tag )
extern
Output instructions as GIMPLE trees for code to find the most
common called function in indirect call.
VALUE is the call expression whose indirect callee is profiled.
TAG is the tag of the section for counters.   

References build3(), build_pointer_type(), force_gimple_operand_gsi(), get_gcov_type(), ggc_alloc(), gimple_build_assign(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, histogram_value_t::hvalue, ic_tuple_callee_field, ic_tuple_counters_field, ic_tuple_var, make_temp_ssa_name(), NULL, NULL_TREE, ptr_type_node, histogram_value_t::stmt, tree_coverage_counter_addr(), unshare_expr(), and histogram_value_t::value.

Referenced by instrument_values().

◆ gimple_gen_interval_profiler()

void gimple_gen_interval_profiler ( histogram_value value,
unsigned tag )
extern

◆ gimple_gen_ior_profiler()

void gimple_gen_ior_profiler ( histogram_value value,
unsigned tag )
extern
Output instructions as GIMPLE trees to increment the ior histogram
counter.  VALUE is the expression whose value is profiled.  TAG is the
tag of the section for counters, BASE is offset of the counter position.   

References force_gimple_operand_gsi(), ggc_alloc(), gimple_build_call(), gsi_for_stmt(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, histogram_value_t::hvalue, NULL_TREE, prepare_instrumented_value(), histogram_value_t::stmt, tree_coverage_counter_addr(), and tree_ior_profiler_fn.

Referenced by instrument_values().

◆ gimple_gen_pow2_profiler()

void gimple_gen_pow2_profiler ( histogram_value value,
unsigned tag )
extern
Output instructions as GIMPLE trees to increment the power of two histogram
counter.  VALUE is the expression whose value is profiled.  TAG is the tag
of the section for counters.   

References force_gimple_operand_gsi(), ggc_alloc(), gimple_build_call(), gsi_for_stmt(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, histogram_value_t::hvalue, NULL_TREE, prepare_instrumented_value(), histogram_value_t::stmt, tree_coverage_counter_addr(), and tree_pow2_profiler_fn.

Referenced by instrument_values().

◆ gimple_gen_time_profiler()

void gimple_gen_time_profiler ( unsigned tag)
extern
Output instructions as GIMPLE tree at the beginning for each function.
TAG is the tag of the section for counters, BASE is offset of the
counter position and GSI is the iterator we place the counter.   

References build_int_cst(), cfun, ENTRY_BLOCK_PTR_FOR_FN, force_gimple_operand_gsi(), gen_counter_update(), get_gcov_type(), ggc_alloc(), gimple_build_cond(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, gsi_start_bb(), make_edge(), NULL, NULL_TREE, single_succ_edge(), split_edge(), tree_coverage_counter_ref(), tree_time_profiler_counter, and profile_probability::unlikely().

Referenced by instrument_values().

◆ gimple_gen_topn_values_profiler()

void gimple_gen_topn_values_profiler ( histogram_value value,
unsigned tag )
extern
Output instructions as GIMPLE trees for code to find the most N common
values.  VALUE is the expression whose value is profiled.  TAG is the tag
of the section for counters.   

References force_gimple_operand_gsi(), ggc_alloc(), gimple_build_call(), gsi_for_stmt(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, histogram_value_t::hvalue, NULL_TREE, prepare_instrumented_value(), histogram_value_t::stmt, tree_coverage_counter_addr(), and tree_topn_values_profiler_fn.

Referenced by instrument_values().

◆ gimple_histogram_value()

◆ gimple_histogram_value_of_type()

◆ gimple_ic()

◆ gimple_init_gcov_profiler()

◆ gimple_move_stmt_histograms()

void gimple_move_stmt_histograms ( struct function * fun,
gimple * stmt,
gimple * ostmt )

◆ gimple_remove_histogram_value()

◆ gimple_remove_stmt_histograms()

void gimple_remove_stmt_histograms ( struct function * fun,
gimple * stmt )
Remove all histograms associated with STMT.   

References gimple_histogram_value(), gimple_remove_histogram_value(), and NULL.

Referenced by gsi_remove(), gsi_replace(), and move_block_to_fn().

◆ gimple_value_profile_transformations()

◆ init_branch_prob()

void init_branch_prob ( void )
extern

◆ read_thunk_profile()

◆ stream_in_histogram_value()

◆ stream_out_histogram_value()

◆ stringop_block_profile()

◆ verify_histograms()