GCC Middle and Back End API Reference
autofdo::function_instance Class Reference
Collaboration diagram for autofdo::function_instance:

Public Types

typedef auto_vec< function_instance * > function_instance_stack

Public Member Functions

 ~function_instance ()
int name () const
int set_name (int index)
gcov_type total_count () const
gcov_type head_count () const
function_instanceget_function_instance_by_decl (unsigned lineno, tree decl, location_t location) const
void merge (function_instance *other, vec< function_instance * > &new_functions)
void offline_if_not_realized (vec< function_instance * > &new_functions)
bool match (cgraph_node *node, vec< function_instance * > &new_functions, name_index_map &to_symbol_name)
void offline_if_in_set (name_index_set &seen, vec< function_instance * > &new_functions)
void remove_external_functions (name_index_set &seen, name_index_map &to_symbol_name, vec< function_instance * > &new_functions)
bool get_count_info (location_t loc, count_info *info) const
gcov_type find_icall_target_map (tree fn, gcall *stmt, icall_target_map *map) const
void remove_icall_target (tree fn, gcall *stmt)
void mark_annotated (location_t loc)
void dump (FILE *f, int indent=0, bool nested=false) const
void dump_inline_stack (FILE *f) const
DEBUG_FUNCTION void debug () const
void remove_icall_target ()
bool removed_icall_target ()
void set_inlined_to (function_instance *inlined_to)
function_instanceinlined_to () const
void set_realized ()
bool realized_p ()
void set_in_worklist ()
void clear_in_worklist ()
bool in_worklist_p ()
cgraph_nodeget_cgraph_node ()
void set_location (location_t l)
location_t get_location ()
void set_call_location (location_t l)
location_t get_call_location ()
count_infolookup_count (location_t loc, inline_stack &stack, cgraph_node *node)

Static Public Member Functions

static function_instanceread_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_infoposition_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_instanceinlined_to_
location_t location_
location_t call_location_

Detailed Description

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.

Member Typedef Documentation

◆ callsite

typedef std::pair<unsigned, unsigned> autofdo::function_instance::callsite
private

◆ callsite_map

◆ function_instance_stack

◆ position_count_map

typedef std::map<unsigned, count_info> autofdo::function_instance::position_count_map
private

Constructor & Destructor Documentation

◆ ~function_instance()

autofdo::function_instance::~function_instance ( )
Member functions for function_instance.

References callsites, gcc_assert, and in_worklist_p().

◆ function_instance()

Member Function Documentation

◆ clear_in_worklist()

◆ debug()

void autofdo::function_instance::debug ( ) const
Dump instance to stderr.

References dump().

◆ dump()

void autofdo::function_instance::dump ( FILE * f,
int indent = 0,
bool nested = false ) const

◆ dump_inline_stack()

◆ find_icall_target_map()

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.

◆ get_call_location()

location_t autofdo::function_instance::get_call_location ( )
inline

References call_location_.

Referenced by match().

◆ get_cgraph_node()

cgraph_node * autofdo::function_instance::get_cgraph_node ( )

◆ get_count_info()

bool autofdo::function_instance::get_count_info ( location_t loc,
count_info * info ) const
Return profile info for LOC in INFO.

References pos_counts.

◆ get_function_instance_by_decl()

function_instance * autofdo::function_instance::get_function_instance_by_decl ( unsigned lineno,
tree decl,
location_t location ) const

◆ get_location()

location_t autofdo::function_instance::get_location ( )
inline

◆ head_count()

gcov_type autofdo::function_instance::head_count ( ) const
inline

◆ in_worklist_p()

◆ inlined_to()

◆ lookup_count()

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().

◆ mark_annotated()

void autofdo::function_instance::mark_annotated ( location_t loc)

References DEBUG_FUNCTION.

◆ match()

bool autofdo::function_instance::match ( cgraph_node * node,
vec< function_instance * > & new_functions,
name_index_map & to_symbol_name )

◆ merge()

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_.

◆ name()

◆ offline()

bool autofdo::function_instance::offline ( function_instance * fn,
vec< function_instance * > & new_functions )
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().

◆ offline_if_in_set()

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().

◆ offline_if_not_realized()

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().

◆ read_function_instance()

function_instance * autofdo::function_instance::read_function_instance ( function_instance_stack * stack,
gcov_type head_count )
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().

◆ realized_p()

bool autofdo::function_instance::realized_p ( )
inline

◆ remove_external_functions()

void autofdo::function_instance::remove_external_functions ( name_index_set & seen,
name_index_map & to_symbol_name,
vec< function_instance * > & new_functions )

◆ remove_icall_target() [1/2]

void autofdo::function_instance::remove_icall_target ( )
inline

References removed_icall_target_.

◆ remove_icall_target() [2/2]

void autofdo::function_instance::remove_icall_target ( tree fn,
gcall * stmt )
Remove the inlined indirect call target profile for STMT.

References callsites, gcc_assert, and autofdo::get_relative_location_for_stmt().

◆ removed_icall_target()

bool autofdo::function_instance::removed_icall_target ( )
inline

References removed_icall_target_.

◆ set_call_location()

void autofdo::function_instance::set_call_location ( location_t l)
inline

References call_location_, gcc_checking_assert, and UNKNOWN_LOCATION.

Referenced by match().

◆ set_in_worklist()

void autofdo::function_instance::set_in_worklist ( )
inline

◆ set_inlined_to()

void autofdo::function_instance::set_inlined_to ( function_instance * inlined_to)
inline

◆ set_location()

void autofdo::function_instance::set_location ( location_t l)
inline

References gcc_checking_assert, location_, and UNKNOWN_LOCATION.

Referenced by match().

◆ set_name()

int autofdo::function_instance::set_name ( int index)
inline

◆ set_realized()

void autofdo::function_instance::set_realized ( )
inline

◆ total_count()

gcov_type autofdo::function_instance::total_count ( ) const
inline

References total_count_.

Referenced by dump(), merge(), and offline().

Field Documentation

◆ call_location_

location_t autofdo::function_instance::call_location_
private

◆ callsites

◆ head_count_

gcov_type autofdo::function_instance::head_count_
private

◆ in_worklist_

bool autofdo::function_instance::in_worklist_
private

◆ inlined_to_

function_instance* autofdo::function_instance::inlined_to_
private

◆ location_

location_t autofdo::function_instance::location_
private

◆ name_

unsigned autofdo::function_instance::name_
private

Referenced by function_instance(), name(), and set_name().

◆ pos_counts

position_count_map autofdo::function_instance::pos_counts
private

◆ realized_

bool autofdo::function_instance::realized_
private

◆ removed_icall_target_

bool autofdo::function_instance::removed_icall_target_
private

◆ total_count_

gcov_type autofdo::function_instance::total_count_
private

The documentation for this class was generated from the following file: