GCC Middle and Back End API Reference
|
Variables | |
static bool | error_found = false |
static pointer_map_t * | cgraph_node_map |
|
static |
The overall number of invocations of the counter should match execution count of basic block. Report it as error rather than internal error as it might mean that user has misused the profile somehow.
References current_function_decl, error_at(), gimple_location(), and inform().
Referenced by gimple_divmod_fixed_value_transform(), gimple_ic_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), and gimple_stringops_transform().
|
static |
Perform sanity check on the indirect call target. Due to race conditions, false function target may be attributed to an indirect call site. If the call expression type mismatches with the target function's type, expand_call may ICE. Here we only do very minimal sanity check just to make compiler happy. Returns true if TARGET is considered ok for call CALL_STMT.
References cgraph_node_name(), symtab_node_base::decl, gimple_check_call_matching_types(), gimple_location(), inform(), and cgraph_node::symbol.
Referenced by gimple_ic_transform().
void del_node_map | ( | void | ) |
Delete the CGRAPH_NODE_MAP.
References pointer_map_destroy().
Referenced by ipa_profile(), and tree_profiling().
|
static |
Dump information about HIST to DUMP_FILE.
References histogram_value_t::counters, histogram_value_t::hdata, HIST_TYPE_AVERAGE, HIST_TYPE_CONST_DELTA, HIST_TYPE_INDIR_CALL, HIST_TYPE_INTERVAL, HIST_TYPE_IOR, HIST_TYPE_MAX, HIST_TYPE_POW2, HIST_TYPE_SINGLE_VALUE, HOST_WIDEST_INT, HOST_WIDEST_INT_PRINT_DEC, histogram_value_t::hvalue, histogram_value_t::intvl, and histogram_value_t::type.
Referenced by dump_histograms_for_stmt(), gimple_find_values_to_profile(), verify_histograms(), and visit_hist().
void dump_histograms_for_stmt | ( | ) |
Dump all histograms attached to STMT to DUMP_FILE.
References dump_histogram_value(), gimple_histogram_value(), histogram_value_t::hvalue, and histogram_value_t::next.
Referenced by gimple_dump_bb_buff(), and gimple_value_profile_transformations().
|
read |
Return cgraph node for function with pid
References pointer_map_contains().
Referenced by gimple_ic_transform(), and ipa_profile().
|
static |
Helper function for verify_histograms. For each histogram reachable via htab walk verify that it was reached via statement walk.
References histogram_value_t::counters, free(), histogram_value_t::hvalue, and memset().
Referenced by free_histograms().
void free_histograms | ( | void | ) |
References cfun, and free_hist().
Referenced by gimple_expand_cfg(), and release_function_body().
void gimple_add_histogram_value | ( | struct function * | fun, |
gimple | stmt, | ||
histogram_value | hist | ||
) |
Add histogram for STMT.
References gimple_histogram_value(), histogram_value_t::hvalue, histogram_value_t::next, and set_histogram_value().
Referenced by compute_value_histograms(), gimple_duplicate_stmt_histograms(), and stream_in_histogram_value().
|
static |
Allocate histogram value.
References histogram_value_t::hvalue, histogram_value_t::stmt, histogram_value_t::type, type(), and histogram_value_t::value.
Referenced by gimple_divmod_values_to_profile(), gimple_duplicate_stmt_histograms(), gimple_indirect_call_to_profile(), gimple_stringops_values_to_profile(), and stream_in_histogram_value().
|
static |
@verbatim Transformations based on profile information for values.
Copyright (C) 2003-2013 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/.
In this file value profile based optimizations are placed. Currently the following optimizations are implemented (for more detailed descriptions see comments at value_profile_transformations): 1) Division/modulo specialization. Provided that we can determine that the operands of the division have some special properties, we may use it to produce more effective code. 2) Indirect/virtual call specialization. If we can determine most common function callee in indirect/virtual call. We can use this information to improve code effectiveness (especially info for the inliner). 3) Speculative prefetching. If we are able to determine that the difference between addresses accessed by a memory reference is usually constant, we may add the prefetch instructions. FIXME: This transformation was removed together with RTL based value profiling. Value profiling internals ========================== Every value profiling transformation starts with defining what values to profile. There are different histogram types (see HIST_TYPE_* in value-prof.h) and each transformation can request one or more histogram types per GIMPLE statement. The function gimple_find_values_to_profile() collects the values to profile in a vec, and adds the number of counters required for the different histogram types. For a -fprofile-generate run, the statements for which values should be recorded, are instrumented in instrument_values(). The instrumentation is done by helper functions that can be found in tree-profile.c, where new types of histograms can be added if necessary. After a -fprofile-use, the value profiling data is read back in by compute_value_histograms() that translates the collected data to histograms and attaches them to the profiled statements via gimple_add_histogram_value(). Histograms are stored in a hash table that is attached to every intrumented function, see VALUE_HISTOGRAMS in function.h. The value-profile transformations driver is the function gimple_value_profile_transformations(). It traverses all statements in the to-be-transformed function, and looks for statements with one or more histograms attached to it. If a statement has histograms, the transformation functions are called on the statement. Limitations / FIXME / TODO: * Only one histogram of each type can be associated with a statement. * Currently, HIST_TYPE_CONST_DELTA is not implemented. (This type of histogram was originally used to implement a form of stride profiling based speculative prefetching to improve SPEC2000 scores for memory-bound benchmarks, mcf and equake. However, this was an RTL value-profiling transformation, and those have all been removed.) * Some value profile transformations are done in builtins.c (?!) * Updating of histograms needs some TLC. * The value profiling code could be used to record analysis results from non-profiling (e.g. VRP). * Adding new profilers should be simplified, starting with a cleanup of what-happens-where andwith making gimple_find_values_to_profile and gimple_value_profile_transformations table-driven, perhaps...
Generate code for transformation 1 (with parent gimple assignment STMT and probability of taking the optimal path PROB, which is equivalent to COUNT/ALL within roundoff error). This generates the result into a temp and returns the temp; it does not replace or alter the original STMT.
References count, edge_def::count, basic_block_def::count, create_tmp_reg(), edge_def::dest, edge_def::flags, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), gimple_build_assign_with_ops(), gimple_build_cond(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, is_gimple_assign(), make_edge(), make_temp_ssa_name(), prob, edge_def::probability, remove_edge(), and split_block().
Referenced by gimple_divmod_fixed_value_transform().
|
static |
Referenced by gimple_value_profile_transformations().
|
static |
Do transform 1) on INSN if applicable.
References build_int_cst_wide(), cfun, check_counter(), count, histogram_value_t::counters, dump_file, get_gcov_type(), gimple_assign_lhs(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_rhs_from_tree(), gimple_divmod_fixed_value(), gimple_histogram_value_of_type(), gimple_remove_histogram_value(), gsi_stmt(), HIST_TYPE_SINGLE_VALUE, histogram, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, histogram_value_t::hvalue, optimize_bb_for_size_p(), print_generic_expr(), print_gimple_stmt(), prob, simple_cst_equal(), update_stmt(), and histogram_value_t::value.
|
static |
Find values inside STMT for that we want to measure histograms for division/modulo optimization.
References cfun, gimple_alloc_histogram_value(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), histogram_value_t::hdata, HIST_TYPE_INTERVAL, HIST_TYPE_POW2, HIST_TYPE_SINGLE_VALUE, histogram_value_t::intvl, and type().
Referenced by gimple_values_to_profile().
void gimple_duplicate_stmt_histograms | ( | struct function * | fun, |
gimple | stmt, | ||
struct function * | ofun, | ||
gimple | ostmt | ||
) |
Duplicate all histograms associates with OSTMT to STMT.
References histogram_value_t::counters, gimple_add_histogram_value(), gimple_alloc_histogram_value(), gimple_histogram_value(), histogram_value_t::hvalue, memcpy(), histogram_value_t::n_counters, histogram_value_t::next, histogram_value_t::stmt, and histogram_value_t::type.
Referenced by copy_bb(), gimple_duplicate_bb(), graphite_copy_stmts_from_block(), gsi_replace(), and move_block_to_fn().
void gimple_find_values_to_profile | ( | ) |
References dump_file, dump_histogram_value(), gimple_values_to_profile(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), histogram_value_t::hdata, HIST_TYPE_AVERAGE, HIST_TYPE_CONST_DELTA, HIST_TYPE_INDIR_CALL, HIST_TYPE_INTERVAL, HIST_TYPE_IOR, HIST_TYPE_POW2, HIST_TYPE_SINGLE_VALUE, histogram_value_t::hvalue, histogram_value_t::intvl, histogram_value_t::n_counters, print_gimple_stmt(), histogram_value_t::stmt, and histogram_value_t::type.
Referenced by branch_prob().
histogram_value gimple_histogram_value | ( | ) |
Get histogram list for STMT.
Referenced by dump_histograms_for_stmt(), gimple_add_histogram_value(), gimple_duplicate_stmt_histograms(), gimple_histogram_value_of_type(), gimple_move_stmt_histograms(), gimple_remove_histogram_value(), gimple_remove_stmt_histograms(), gimple_value_profile_transformations(), output_gimple_stmt(), and verify_histograms().
histogram_value gimple_histogram_value_of_type | ( | struct function * | fun, |
gimple | stmt, | ||
enum hist_type | type | ||
) |
Lookup histogram of type TYPE in the STMT.
References gimple_histogram_value(), histogram_value_t::hvalue, histogram_value_t::next, and histogram_value_t::type.
Referenced by gimple_divmod_fixed_value_transform(), gimple_ic_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_stringops_transform(), ipa_profile_generate_summary(), and stringop_block_profile().
gimple gimple_ic | ( | gimple | icall_stmt, |
struct cgraph_node * | direct_call, | ||
int | prob, | ||
gcov_type | count, | ||
gcov_type | all | ||
) |
Do transformation if (actual_callee_address == address_of_most_common_function/method) do direct call else old call
References add_phi_arg(), add_stmt_to_eh_lp(), build_addr(), build_pointer_type(), count, edge_def::count, basic_block_def::count, create_phi_node(), current_function_decl, symtab_node_base::decl, edge_def::dest, duplicate_ssa_name(), find_fallthru_edge(), edge_def::flags, flags_from_decl_or_type(), gimple_bb(), gimple_build_cond(), gimple_call_fn(), gimple_call_lhs(), gimple_call_set_fndecl(), gimple_call_set_lhs(), gimple_copy(), gimple_set_vdef(), gimple_set_vuse(), gsi_end_p(), gsi_for_stmt(), gsi_insert_before(), gsi_next(), GSI_SAME_STMT, gsi_start_phis(), gsi_stmt(), lookup_stmt_eh_lp(), make_edge(), make_temp_ssa_name(), prob, edge_def::probability, remove_edge(), single_pred_edge(), split_block(), split_edge(), stmt_could_throw_p(), stmt_ends_bb_p(), basic_block_def::succs, cgraph_node::symbol, unshare_expr(), and update_stmt().
Referenced by cgraph_redirect_edge_call_stmt_to_callee().
|
static |
Referenced by gimple_value_profile_transformations().
|
static |
References cfun, check_counter(), check_ic_target(), count, basic_block_def::count, histogram_value_t::counters, symtab_node_base::decl, dump_file, find_func_by_profile_id(), gimple_bb(), gimple_call_fn(), gimple_call_fndecl(), gimple_call_internal_p(), gimple_histogram_value_of_type(), gimple_remove_histogram_value(), gsi_stmt(), HIST_TYPE_INDIR_CALL, histogram, HOST_WIDEST_INT_PRINT_DEC, histogram_value_t::hvalue, print_generic_expr(), print_gimple_stmt(), and cgraph_node::symbol.
|
static |
Find calls inside STMT for that we want to measure histograms for indirect/virtual call optimization.
References cfun, gimple_alloc_histogram_value(), gimple_call_fn(), gimple_call_fndecl(), gimple_call_internal_p(), and HIST_TYPE_INDIR_CALL.
Referenced by gimple_values_to_profile().
Referenced by gimple_mod_pow2_value_transform().
|
static |
Generate code for transformation 2 (with parent gimple assign STMT and probability of taking the optimal path PROB, which is equivalent to COUNT/ALL within roundoff error). This generates the result into a temp and returns the temp; it does not replace or alter the original STMT.
References build_int_cst(), count, edge_def::count, basic_block_def::count, create_tmp_reg(), edge_def::dest, edge_def::flags, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), gimple_build_assign_with_ops(), gimple_build_cond(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, is_gimple_assign(), make_edge(), make_temp_ssa_name(), prob, edge_def::probability, remove_edge(), and split_block().
|
static |
Referenced by gimple_value_profile_transformations().
|
static |
Do transform 2) on INSN if applicable.
References cfun, check_counter(), count, histogram_value_t::counters, dump_file, gimple_assign_lhs(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_set_rhs_from_tree(), gimple_histogram_value_of_type(), gimple_mod_pow2(), gimple_remove_histogram_value(), gsi_stmt(), HIST_TYPE_POW2, histogram, histogram_value_t::hvalue, optimize_bb_for_size_p(), print_gimple_stmt(), prob, simple_cst_equal(), update_stmt(), and histogram_value_t::value.
|
static |
Generate code for transformations 3 and 4 (with parent gimple assign STMT, and NCOUNTS the number of cases to support. Currently only NCOUNTS==0 or 1 is supported and this is built into this interface. The probabilities of taking the optimal paths are PROB1 and PROB2, which are equivalent to COUNT1/ALL and COUNT2/ALL respectively within roundoff error). This generates the result into a temp and returns the temp; it does not replace or alter the original STMT.
FIXME: Generalize the interface to handle NCOUNTS > 1.
References edge_def::count, basic_block_def::count, create_tmp_reg(), edge_def::dest, edge_def::flags, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_bb(), gimple_build_assign_with_ops(), gimple_build_cond(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, is_gimple_assign(), make_edge(), make_temp_ssa_name(), edge_def::probability, and split_block().
Referenced by gimple_mod_subtract_transform().
|
static |
Referenced by gimple_value_profile_transformations().
|
static |
Do transforms 3) and 4) on the statement pointed-to by SI if applicable.
References cfun, check_counter(), count, histogram_value_t::counters, dump_file, gimple_assign_lhs(), gimple_assign_rhs_code(), gimple_assign_set_rhs_from_tree(), gimple_histogram_value_of_type(), gimple_mod_subtract(), gimple_remove_histogram_value(), gsi_stmt(), histogram_value_t::hdata, HIST_TYPE_INTERVAL, histogram, histogram_value_t::hvalue, histogram_value_t::intvl, optimize_bb_for_size_p(), print_gimple_stmt(), and update_stmt().
void gimple_move_stmt_histograms | ( | ) |
Move all histograms associated with OSTMT to STMT.
References gimple_histogram_value(), histogram_value_t::hvalue, histogram_value_t::next, set_histogram_value(), and histogram_value_t::stmt.
void gimple_remove_histogram_value | ( | struct function * | fun, |
gimple | stmt, | ||
histogram_value | hist | ||
) |
Remove histogram HIST from STMT's histogram list.
References histogram_value_t::counters, free(), gimple_histogram_value(), histogram_value_t::hvalue, memset(), histogram_value_t::next, and set_histogram_value().
Referenced by gimple_divmod_fixed_value_transform(), gimple_ic_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_remove_stmt_histograms(), gimple_stringops_transform(), ipa_profile_generate_summary(), and stringop_block_profile().
void gimple_remove_stmt_histograms | ( | ) |
Remove all histograms associated with STMT.
References gimple_histogram_value(), and gimple_remove_histogram_value().
Referenced by execute_fold_all_builtins(), gsi_remove(), gsi_replace(), and move_block_to_fn().
|
static |
Convert stringop (..., vcall_size) into if (vcall_size == icall_size) stringop (..., icall_size); else stringop (..., vcall_size); assuming we'll propagate a true constant into ICALL_SIZE later.
References add_phi_arg(), count, edge_def::count, basic_block_def::count, create_phi_node(), edge_def::dest, duplicate_ssa_name(), edge_def::flags, gimple_bb(), gimple_build_cond(), gimple_call_arg(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_set_arg(), gimple_call_set_lhs(), gimple_copy(), gimple_set_vdef(), gimple_set_vuse(), gsi_for_stmt(), gsi_insert_before(), GSI_SAME_STMT, interesting_stringop_to_profile_p(), make_edge(), make_temp_ssa_name(), prob, edge_def::probability, remove_edge(), split_block(), stmt_could_throw_p(), and update_stmt().
Referenced by gimple_stringops_transform().
|
static |
Referenced by gimple_value_profile_transformations().
|
static |
Find values inside STMT for that we want to measure histograms for division/modulo optimization.
References build_int_cst_wide(), builtin_memset_read_str(), can_move_by_pieces(), can_store_by_pieces(), cfun, check_counter(), count, histogram_value_t::counters, dump_file, get_gcov_type(), get_pointer_alignment(), gimple_call_arg(), gimple_call_fndecl(), gimple_histogram_value_of_type(), gimple_remove_histogram_value(), gimple_stringop_fixed_value(), gsi_stmt(), HIST_TYPE_SINGLE_VALUE, histogram, HOST_BITS_PER_WIDE_INT, HOST_WIDE_INT, histogram_value_t::hvalue, interesting_stringop_to_profile_p(), optimize_bb_for_size_p(), print_gimple_stmt(), and prob.
|
static |
Find values inside STMT for that we want to measure histograms for string operations.
References cfun, gimple_alloc_histogram_value(), gimple_call_arg(), gimple_call_fndecl(), HIST_TYPE_AVERAGE, HIST_TYPE_IOR, HIST_TYPE_SINGLE_VALUE, and interesting_stringop_to_profile_p().
Referenced by gimple_values_to_profile().
bool gimple_value_profile_transformations | ( | void | ) |
GIMPLE based transformations.
References cfun, changed, counts_to_freqs(), dump_file, dump_histograms_for_stmt(), gimple_bb(), gimple_divmod_fixed_value_transform(), gimple_histogram_value(), gimple_ic_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_stringops_transform(), gsi_end_p(), gsi_for_stmt(), gsi_next(), gsi_start_bb(), gsi_stmt(), and print_gimple_stmt().
Referenced by tree_profiling().
|
static |
Find values inside STMT for that we want to measure histograms and adds them to list VALUES.
References gimple_divmod_values_to_profile(), gimple_indirect_call_to_profile(), and gimple_stringops_values_to_profile().
Referenced by gimple_find_values_to_profile().
|
static |
Return nonzero if statement for histogram_value X is Y.
Referenced by set_histogram_value().
|
static |
Hash value for histogram.
void init_node_map | ( | ) |
Initialize map from PROFILE_ID to CGRAPH_NODE. When LOCAL is true, the PROFILE_IDs are computed. when it is false we assume that the PROFILE_IDs was already assigned.
References cgraph_function_with_gimple_body_p(), cgraph_node_name(), cgraph_only_called_directly_p(), coverage_compute_profile_id(), dump_file, symtab_node_base::order, pointer_map_contains(), pointer_map_create(), pointer_map_insert(), cgraph_node::profile_id, cgraph_node::symbol, and symtab_node_name().
|
static |
Return true if the stringop CALL with FNDECL shall be profiled. SIZE_ARG be set to the argument index for the size of the string operation.
References validate_gimple_arglist().
Referenced by gimple_stringop_fixed_value(), gimple_stringops_transform(), and gimple_stringops_values_to_profile().
|
static |
Set histogram for STMT.
References histogram_eq().
Referenced by gimple_add_histogram_value(), gimple_move_stmt_histograms(), and gimple_remove_histogram_value().
void stream_in_histogram_value | ( | ) |
Dump information about HIST to DUMP_FILE.
References bp_unpack_value(), cfun, histogram_value_t::counters, gimple_add_histogram_value(), gimple_alloc_histogram_value(), histogram_value_t::hdata, HIST_TYPE_AVERAGE, HIST_TYPE_CONST_DELTA, HIST_TYPE_INDIR_CALL, HIST_TYPE_INTERVAL, HIST_TYPE_IOR, HIST_TYPE_MAX, HIST_TYPE_POW2, HIST_TYPE_SINGLE_VALUE, histogram_value_t::hvalue, histogram_value_t::intvl, histogram_value_t::n_counters, histogram_value_t::next, streamer_read_bitpack(), streamer_read_gcov_count(), streamer_read_hwi(), streamer_read_uhwi(), and type().
Referenced by input_gimple_stmt().
void stream_out_histogram_value | ( | ) |
Dump information about HIST to DUMP_FILE.
References bitpack_create(), bp_pack_value(), histogram_value_t::counters, histogram_value_t::hdata, HIST_TYPE_INTERVAL, HIST_TYPE_MAX, histogram_value_t::hvalue, histogram_value_t::intvl, output_block::main_stream, histogram_value_t::n_counters, histogram_value_t::next, streamer_write_bitpack(), streamer_write_gcov_count(), streamer_write_hwi(), streamer_write_uhwi(), and histogram_value_t::type.
Referenced by output_gimple_stmt().
void stringop_block_profile | ( | gimple | stmt, |
unsigned int * | expected_align, | ||
HOST_WIDE_INT * | expected_size | ||
) |
References cfun, count, histogram_value_t::counters, gimple_histogram_value_of_type(), gimple_remove_histogram_value(), HIST_TYPE_AVERAGE, HIST_TYPE_IOR, histogram, and histogram_value_t::hvalue.
Referenced by expand_builtin_memcpy(), and expand_builtin_memset_args().
DEBUG_FUNCTION void verify_histograms | ( | void | ) |
Verify sanity of the histograms.
References cfun, debug_gimple_stmt(), dump_histogram_value(), error(), error_found, gimple_histogram_value(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), histogram_value_t::hvalue, internal_error(), histogram_value_t::next, pointer_set_create(), pointer_set_destroy(), pointer_set_insert(), histogram_value_t::stmt, and visit_hist().
Referenced by verify_gimple_in_cfg().
|
static |
Helper function for verify_histograms. For each histogram reachable via htab walk verify that it was reached via statement walk.
References debug_gimple_stmt(), dump_histogram_value(), error(), error_found, histogram_value_t::hvalue, pointer_set_contains(), histogram_value_t::stmt, and visited.
Referenced by verify_histograms().
|
static |
|
static |
Referenced by compile(), verify_cgraph_node(), verify_edge_count_and_frequency(), verify_histograms(), verify_symtab_base(), and visit_hist().