GCC Middle and Back End API Reference
|
Public Types | |
typedef auto_vec< function_instance * > | function_instance_stack |
Static Public Member Functions | |
static function_instance * | read_function_instance (function_instance_stack *stack, gcov_type head_count) |
Private Types | |
typedef std::pair< unsigned, unsigned > | callsite |
typedef std::map< callsite, function_instance * > | callsite_map |
typedef std::map< unsigned, count_info > | position_count_map |
Private Member Functions | |
function_instance (unsigned name, gcov_type head_count) |
Static Private Member Functions | |
static bool | offline (function_instance *fn, vec< function_instance * > &new_functions) |
Private Attributes | |
unsigned | name_ |
gcov_type | total_count_ |
gcov_type | head_count_ |
callsite_map | callsites |
position_count_map | pos_counts |
bool | removed_icall_target_ |
bool | realized_ |
bool | in_worklist_ |
function_instance * | inlined_to_ |
location_t | location_ |
location_t | call_location_ |
Profile of a function instance: 1. total_count of the function. 2. head_count (entry basic block count) of the function (only valid when function is a top-level function_instance, i.e. it is the original copy instead of the inlined copy). 3. map from source location (decl_lineno) to profile (count_info). 4. map from callsite to callee function_instance.
|
private |
|
private |
|
private |
autofdo::function_instance::~function_instance | ( | ) |
Member functions for function_instance.
References callsites, gcc_assert, and in_worklist_p().
|
inlineprivate |
References call_location_, false, head_count(), head_count_, in_worklist_, inlined_to_, location_, name(), name_, NULL, realized_, removed_icall_target_, total_count_, and UNKNOWN_LOCATION.
Referenced by dump_inline_stack(), get_function_instance_by_decl(), match(), merge(), offline(), offline_if_in_set(), offline_if_not_realized(), read_function_instance(), remove_external_functions(), and set_inlined_to().
|
inline |
void autofdo::function_instance::debug | ( | ) | const |
Dump instance to stderr.
References dump().
Dump instance to F indented by INDENT.
References autofdo::afdo_string_table, callsites, autofdo::dump_afdo_loc(), gcc_checking_assert, head_count(), name(), pos_counts, PRId64, PRIu64, and total_count().
Referenced by debug().
void autofdo::function_instance::dump_inline_stack | ( | FILE * | f | ) | const |
Dump inline path.
References autofdo::afdo_string_table, autofdo::dump_afdo_loc(), function_instance(), gcc_checking_assert, inlined_to(), and name().
Referenced by match(), merge(), offline(), autofdo::autofdo_source_profile::offline_external_functions(), offline_if_in_set(), offline_if_not_realized(), autofdo::autofdo_source_profile::offline_unrealized_inlines(), and remove_external_functions().
gcov_type autofdo::function_instance::find_icall_target_map | ( | tree | fn, |
gcall * | stmt, | ||
icall_target_map * | map ) const |
Read the inlined indirect call target profile for STMT and store it in MAP, return the total count for all inlined indirect calls.
References autofdo::afdo_count_scale, autofdo::afdo_string_table, callsites, cgraph_node::get_for_asmname(), get_identifier(), autofdo::get_relative_location_for_stmt(), map, and NULL.
|
inline |
References call_location_.
Referenced by match().
cgraph_node * autofdo::function_instance::get_cgraph_node | ( | ) |
Return corresponding cgraph node, NULL if unavailable.
References autofdo::afdo_string_table, dyn_cast(), cgraph_node::get_for_asmname(), get_identifier(), name(), and NULL.
Referenced by autofdo::autofdo_source_profile::offline_external_functions(), and autofdo::autofdo_source_profile::offline_unrealized_inlines().
bool autofdo::function_instance::get_count_info | ( | location_t | loc, |
count_info * | info ) const |
Return profile info for LOC in INFO.
References pos_counts.
function_instance * autofdo::function_instance::get_function_instance_by_decl | ( | unsigned | lineno, |
tree | decl, | ||
location_t | location ) const |
Traverse callsites of the current function_instance to find one at the location of LINENO and callee name represented in DECL.
References autofdo::afdo_string_table, callsites, DECL_ABSTRACT_ORIGIN, DECL_ASSEMBLER_NAME, DECL_FROM_INLINE, dump_enabled_p(), dump_printf_loc(), dump_user_location_t::from_location_t(), function_instance(), get_function_instance_by_decl(), IDENTIFIER_POINTER, MSG_NOTE, MSG_PRIORITY_INTERNALS, and NULL.
Referenced by get_function_instance_by_decl().
|
inline |
References location_.
Referenced by match(), and autofdo::autofdo_source_profile::offline_external_functions().
|
inline |
References head_count_.
Referenced by dump(), function_instance(), merge(), and read_function_instance().
|
inline |
|
inline |
count_info * autofdo::function_instance::lookup_count | ( | location_t | loc, |
inline_stack & | stack, | ||
cgraph_node * | node ) |
Lookup count and warn about duplicates.
References symtab_node::decl, gcc_checking_assert, NULL, pos_counts, and warning_at().
Referenced by autofdo::mark_expr_locations(), and match().
void autofdo::function_instance::mark_annotated | ( | location_t | loc | ) |
References DEBUG_FUNCTION.
bool autofdo::function_instance::match | ( | cgraph_node * | node, |
vec< function_instance * > & | new_functions, | ||
name_index_map & | to_symbol_name ) |
Match function instance with gimple body. Report mismatches, attempt to fix them if possible and remove data we will not use. Set location and call_location so we can output diagnostics and know what functions was already matched.
References hash_set< KeyId, Lazy, Traits >::add(), autofdo::afdo_string_table, callsites, hash_set< KeyId, Lazy, Traits >::contains(), symtab_node::decl, DECL_ARGUMENTS, DECL_CHAIN, DECL_SOURCE_LOCATION, DECL_STRUCT_FUNCTION, autofdo::dump_afdo_loc(), dump_file, dump_inline_stack(), symtab_node::dump_name(), autofdo::dump_stmt(), dyn_cast(), FOR_EACH_BB_FN, function_instance(), functions, gcc_checking_assert, cgraph_node::get(), hash_map< KeyId, Value, Traits >::get(), get_call_location(), autofdo::get_combined_location(), autofdo::get_inline_stack_in_node(), get_location(), gimple_call_fndecl(), gimple_location(), gimple_num_ops(), gimple_op(), gimple_phi_arg_def_from_edge(), gimple_phi_arg_location_from_edge(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, inform(), lookup_count(), autofdo::mark_expr_locations(), autofdo::match_with_target(), name(), NULL, offline(), pos_counts, print_generic_expr(), PRIu64, r, set_call_location(), set_location(), set_name(), basic_block_def::succs, autofdo::count_info::targets, cgraph_node::ultimate_alias_target(), UNKNOWN_LOCATION, and warning_at().
Referenced by autofdo::autofdo_source_profile::offline_external_functions().
void autofdo::function_instance::merge | ( | function_instance * | other, |
vec< function_instance * > & | new_functions ) |
Merge profile of OTHER to THIS. Note that cloning hasnt been performed when we annotate the CFG (at this stage).
References callsites, changed, dump_file, dump_inline_stack(), function_instance(), gcc_checking_assert, head_count(), head_count_, name(), offline(), pos_counts, PRIu64, total_count(), and total_count_.
|
inline |
References name_.
Referenced by autofdo::autofdo_source_profile::add_function_instance(), dump(), dump_inline_stack(), function_instance(), get_cgraph_node(), match(), autofdo::match_with_target(), merge(), offline(), autofdo::autofdo_source_profile::offline_external_functions(), autofdo::autofdo_source_profile::offline_unrealized_inlines(), and read_function_instance().
|
staticprivate |
Make inline function FN offline. If tolevel function of same name already exists, then merge profiles. Otherwise turn FN toplevel. Return true if new toplevel function was introduced. If new toplevel functions are created and NEW_FUNCTIONS != NULL, add them to NEW_FUNCTIONS. TODO: When offlining indirect call we lose information about the call target. It should be possible to add it into targets histogram.
References autofdo::afdo_source_profile, dump_file, dump_inline_stack(), function_instance(), gcc_checking_assert, head_count_, in_worklist_p(), inlined_to(), name(), NULL, set_in_worklist(), set_inlined_to(), and total_count().
Referenced by match(), merge(), offline_if_in_set(), and offline_if_not_realized().
void autofdo::function_instance::offline_if_in_set | ( | name_index_set & | seen, |
vec< function_instance * > & | new_functions ) |
Offline all inlined functions with name in SEEN. If new toplevel functions are created, add them to NEW_FUNCTIONS.
References callsites, hash_set< KeyId, Lazy, Traits >::contains(), dump_file, dump_inline_stack(), function_instance(), and offline().
Referenced by autofdo::autofdo_source_profile::offline_external_functions(), and remove_external_functions().
void autofdo::function_instance::offline_if_not_realized | ( | vec< function_instance * > & | new_functions | ) |
Look for inline instances that was not realized and remove them while possibly merging them to offline variants.
References callsites, dump_file, dump_inline_stack(), function_instance(), and offline().
Referenced by autofdo::autofdo_source_profile::offline_unrealized_inlines().
|
static |
Read the profile and create a function_instance with head count as HEAD_COUNT. Recursively read callsites to create nested function_instances too. STACK is used to track the recursive creation process.
function instance profile format: ENTRY_COUNT: 8 bytes NAME_INDEX: 4 bytes NUM_POS_COUNTS: 4 bytes NUM_CALLSITES: 4 byte POS_COUNT_1: POS_1_OFFSET: 4 bytes NUM_TARGETS: 4 bytes COUNT: 8 bytes TARGET_1: VALUE_PROFILE_TYPE: 4 bytes TARGET_IDX: 8 bytes COUNT: 8 bytes TARGET_2 ... TARGET_n POS_COUNT_2 ... POS_COUNT_N CALLSITE_1: CALLSITE_1_OFFSET: 4 bytes FUNCTION_INSTANCE_PROFILE (nested) CALLSITE_2 ... CALLSITE_n.
References autofdo::afdo_profile_info, count, function_instance(), gcov_read_counter(), gcov_read_unsigned(), head_count(), i, name(), and read_function_instance().
Referenced by autofdo::autofdo_source_profile::read(), and read_function_instance().
|
inline |
References realized_.
Referenced by autofdo::autofdo_source_profile::offline_unrealized_inlines().
void autofdo::function_instance::remove_external_functions | ( | name_index_set & | seen, |
name_index_map & | to_symbol_name, | ||
vec< function_instance * > & | new_functions ) |
Walk inlined functions and if their name is not in SEEN remove it. Also rename function names as given by to_symbol_name map.
References callsites, hash_set< KeyId, Lazy, Traits >::contains(), dump_file, dump_inline_stack(), function_instance(), gcc_checking_assert, hash_map< KeyId, Value, Traits >::get(), i, NULL, offline_if_in_set(), pos_counts, set_inlined_to(), and UNKNOWN_LOCATION.
Referenced by autofdo::autofdo_source_profile::offline_external_functions().
|
inline |
References removed_icall_target_.
Remove the inlined indirect call target profile for STMT.
References callsites, gcc_assert, and autofdo::get_relative_location_for_stmt().
|
inline |
References removed_icall_target_.
|
inline |
References call_location_, gcc_checking_assert, and UNKNOWN_LOCATION.
Referenced by match().
|
inline |
References gcc_checking_assert, in_worklist_, in_worklist_p(), and inlined_to_.
Referenced by offline().
|
inline |
References function_instance(), gcc_checking_assert, inlined_to(), and inlined_to_.
Referenced by offline(), and remove_external_functions().
|
inline |
References gcc_checking_assert, location_, and UNKNOWN_LOCATION.
Referenced by match().
|
inline |
References name_.
Referenced by match(), autofdo::match_with_target(), and autofdo::autofdo_source_profile::offline_external_functions().
|
inline |
References realized_.
Referenced by autofdo::autofdo_source_profile::offline_unrealized_inlines().
|
inline |
References total_count_.
|
private |
Referenced by function_instance(), get_call_location(), and set_call_location().
|
private |
|
private |
Referenced by function_instance(), head_count(), merge(), and offline().
|
private |
Referenced by clear_in_worklist(), function_instance(), in_worklist_p(), and set_in_worklist().
|
private |
Referenced by clear_in_worklist(), function_instance(), inlined_to(), set_in_worklist(), and set_inlined_to().
|
private |
Referenced by function_instance(), get_location(), and set_location().
|
private |
Referenced by function_instance(), name(), and set_name().
|
private |
Referenced by dump(), get_count_info(), lookup_count(), match(), merge(), and remove_external_functions().
|
private |
Referenced by function_instance(), realized_p(), and set_realized().
|
private |
Referenced by function_instance(), remove_icall_target(), and removed_icall_target().
|
private |
Referenced by function_instance(), merge(), and total_count().