GCC Middle and Back End API Reference
ipa_icf::sem_function Class Reference

#include <ipa-icf.h>

Inheritance diagram for ipa_icf::sem_function:
Collaboration diagram for ipa_icf::sem_function:

Public Member Functions

 sem_function (bitmap_obstack *stack)
 
 sem_function (cgraph_node *_node, bitmap_obstack *stack)
 
 ~sem_function ()
 
void init (ipa_icf_gimple::func_checker *) final override
 
bool equals_wpa (sem_item *item, hash_map< symtab_node *, sem_item * > &ignored_nodes) final override
 
hashval_t get_hash (void) final override
 
bool equals (sem_item *item, hash_map< symtab_node *, sem_item * > &ignored_nodes) final override
 
bool merge (sem_item *alias_item) final override
 
void dump_to_file (FILE *file) final override
 
cgraph_nodeget_node (void)
 
void hash_stmt (gimple *stmt, inchash::hash &inchash)
 
bool compare_polymorphic_p (void)
 
bool compatible_parm_types_p (tree, tree)
 
bool param_used_p (unsigned int i)
 
DEBUG_FUNCTION void dump (void)
 
void add_reference (ref_map *map, sem_item *target)
 
void set_hash (hashval_t hash)
 
void update_hash_by_addr_refs (hash_map< symtab_node *, sem_item * > &m_symtab_node_map)
 
void update_hash_by_local_refs (hash_map< symtab_node *, sem_item * > &m_symtab_node_map)
 
bool target_supports_symbol_aliases_p (void)
 

Static Public Member Functions

static sem_functionparse (cgraph_node *node, bitmap_obstack *stack, ipa_icf_gimple::func_checker *checker)
 
static bool get_base_types (tree *t1, tree *t2)
 

Data Fields

eh_region region_tree
 
unsigned int arg_count
 
unsigned int edge_count
 
vec< unsigned int > bb_sizes
 
hashval_t cfg_checksum
 
hashval_t gcode_hash
 
auto_vec< treememory_access_types
 
unsigned ssa_names_size
 
vec< ipa_icf_gimple::sem_bb * > bb_sorted
 
hashval_t m_alias_sets_hash
 
sem_item_type type
 
symtab_nodenode
 
tree decl
 
unsigned reference_count
 
congruence_classcls
 
unsigned int index_in_class
 
bitmap usage_index_bitmap
 
vec< treetree_refs
 
hash_set< symtab_node * > refs_set
 
hashval_t global_hash
 
unsigned referenced_by_count
 

Protected Member Functions

void hash_referenced_symbol_properties (symtab_node *ref, inchash::hash &hstate, bool address)
 
bool compare_symbol_references (hash_map< symtab_node *, sem_item * > &ignored_nodes, symtab_node *n1, symtab_node *n2, bool address)
 

Static Protected Member Functions

static bool compare_referenced_symbol_properties (symtab_node *used_by, symtab_node *n1, symtab_node *n2, bool address)
 

Protected Attributes

hashval_t m_hash
 
bool m_hash_set
 

Private Member Functions

hashval_t get_bb_hash (const ipa_icf_gimple::sem_bb *basic_block)
 
bool compare_phi_node (basic_block bb1, basic_block bb2)
 
bool bb_dict_test (vec< int > *bb_dict, int source, int target)
 
bool compare_edge_flags (cgraph_edge *e1, cgraph_edge *e2)
 
bool equals_private (sem_item *item)
 
void setup (bitmap_obstack *stack)
 

Private Attributes

ipa_icf_gimple::func_checkerm_checker
 
sem_functionm_compared_func
 

Static Private Attributes

static hash_map< const_tree, hashval_t > m_type_hash_cache
 

Constructor & Destructor Documentation

◆ sem_function() [1/2]

ipa_icf::sem_function::sem_function ( bitmap_obstack * stack)
Semantic function constructor that uses STACK as bitmap memory stack.   

References bb_sizes, and bb_sorted.

Referenced by parse().

◆ sem_function() [2/2]

ipa_icf::sem_function::sem_function ( cgraph_node * _node,
bitmap_obstack * stack )

References bb_sizes, and bb_sorted.

◆ ~sem_function()

ipa_icf::sem_function::~sem_function ( )

References bb_sizes, bb_sorted, and i.

Member Function Documentation

◆ add_reference()

◆ bb_dict_test()

bool ipa_icf::sem_function::bb_dict_test ( vec< int > * bb_dict,
int source,
int target )
private
Basic blocks dictionary BB_DICT returns true if SOURCE index BB
corresponds to TARGET.   

Referenced by equals_private().

◆ compare_edge_flags()

bool ipa_icf::sem_function::compare_edge_flags ( cgraph_edge * e1,
cgraph_edge * e2 )
private
If cgraph edges E1 and E2 are indirect calls, verify that
ECF flags are the same.   

References cgraph_indirect_call_info::ecf_flags, cgraph_edge::indirect_info, and return_false_with_msg.

Referenced by equals_wpa().

◆ compare_phi_node()

bool ipa_icf::sem_function::compare_phi_node ( basic_block bb1,
basic_block bb2 )
private

◆ compare_polymorphic_p()

bool ipa_icf::sem_function::compare_polymorphic_p ( void )
Return true if polymorphic comparison must be processed.   

References cgraph_edge::callee, symtab_node::decl, symtab_node::definition, get_node(), cgraph_edge::next_callee, NULL, and opt_for_fn.

Referenced by equals_wpa().

◆ compare_referenced_symbol_properties()

bool ipa_icf::sem_item::compare_referenced_symbol_properties ( symtab_node * used_by,
symtab_node * n1,
symtab_node * n2,
bool address )
staticprotectedinherited
Compare properties of symbols N1 and N2 that does not affect semantics of
symbol itself but affects semantics of its references from USED_BY (which
may be NULL if it is unknown).  If comparison is false, symbols
can still be merged but any symbols referring them can't.

If ADDRESS is true, do extra checking needed for IPA_REF_ADDR.

TODO: We can also split attributes to those that determine codegen of
a function body/variable constructor itself and those that are used when
referring to it.   

References attribute_list_equal(), AVAIL_INTERPOSABLE, comp_type_attributes(), symtab_node::decl, DECL_ALIGN, DECL_ATTRIBUTES, DECL_CONTEXT, DECL_DECLARED_INLINE_P, DECL_DISREGARD_INLINE_LIMITS, DECL_FINAL_P, DECL_IS_OPERATOR_NEW_P, DECL_IS_REPLACEABLE_OPERATOR, DECL_UNINLINABLE, DECL_VIRTUAL_P, symtab_node::get_availability(), is_a(), opt_for_fn, return_false_with_msg, TREE_TYPE, and types_must_be_same_for_odr().

Referenced by ipa_icf::sem_item::compare_symbol_references(), and merge().

◆ compare_symbol_references()

bool ipa_icf::sem_item::compare_symbol_references ( hash_map< symtab_node *, sem_item * > & ignored_nodes,
symtab_node * n1,
symtab_node * n2,
bool address )
protectedinherited
For a given symbol table nodes N1 and N2, we check that FUNCTION_DECLs
point to a same function. Comparison can be skipped if IGNORED_NODES
contains these nodes.  ADDRESS indicate if address is taken.   

References AVAIL_INTERPOSABLE, ipa_icf::sem_item::compare_referenced_symbol_properties(), symtab_node::equal_address_to(), hash_map< KeyId, Value, Traits >::get(), is_a(), ipa_icf::sem_item::node, return_false_with_msg, symtab_node::semantically_equivalent_p(), and symtab_node::ultimate_alias_target().

Referenced by equals_wpa(), and ipa_icf::sem_variable::equals_wpa().

◆ compatible_parm_types_p()

bool ipa_icf::sem_function::compatible_parm_types_p ( tree parm1,
tree parm2 )
Perform additional check needed to match types function parameters that are
used.  Unlike for normal decls it matters if type is TYPE_RESTRICT and we
make an assumption that REFERENCE_TYPE parameters are always non-NULL.   

References ipa_icf_gimple::func_checker::compatible_types_p(), opt_for_fn, POINTER_TYPE_P, return_false_with_msg, TREE_CODE, and TYPE_RESTRICT.

Referenced by equals_private(), and equals_wpa().

◆ dump()

DEBUG_FUNCTION void ipa_icf::sem_item::dump ( void )
inherited

◆ dump_to_file()

void ipa_icf::sem_function::dump_to_file ( FILE * file)
inlinefinaloverridevirtual

◆ equals()

bool ipa_icf::sem_function::equals ( sem_item * item,
hash_map< symtab_node *, sem_item * > & ignored_nodes )
finaloverridevirtual

◆ equals_private()

◆ equals_wpa()

◆ get_base_types()

static bool ipa_icf::sem_item::get_base_types ( tree * t1,
tree * t2 )
staticinherited

◆ get_bb_hash()

hashval_t ipa_icf::sem_function::get_bb_hash ( const ipa_icf_gimple::sem_bb * basic_block)
private
Calculates hash value based on a BASIC_BLOCK.   

References inchash::hash::add_int(), and inchash::hash::end().

Referenced by get_hash().

◆ get_hash()

◆ get_node()

cgraph_node * ipa_icf::sem_function::get_node ( void )
inline

◆ hash_referenced_symbol_properties()

void ipa_icf::sem_item::hash_referenced_symbol_properties ( symtab_node * ref,
inchash::hash & hstate,
bool address )
protectedinherited

◆ hash_stmt()

◆ init()

◆ merge()

bool ipa_icf::sem_function::merge ( sem_item * alias_item)
finaloverridevirtual
Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can
be applied.   

Implements ipa_icf::sem_item.

References symtab_node::address_matters_p(), symtab_node::address_taken, AUTO_DUMP_SCOPE, AVAIL_INTERPOSABLE, symtab_node::body_removed, symbol_table::call_cgraph_insertion_hooks(), symbol_table::call_cgraph_removal_hooks(), cgraph_node::call_for_symbol_and_aliases(), cgraph_node::call_for_symbol_thunks_and_aliases(), symtab_node::can_be_discarded_p(), cgraph_node::can_remove_if_no_direct_calls_p(), ipa_icf::clear_decl_rtl(), symtab_node::comdat_local_p(), ipa_icf::sem_item::compare_referenced_symbol_properties(), cgraph_node::create_alias(), cgraph_node::create_wrapper(), ipa_icf::sem_item::decl, symtab_node::decl, DECL_ATTRIBUTES, decl_binds_to_current_def_p(), DECL_COMDAT_GROUP, DECL_EXTERNAL, DECL_NO_INLINE_WARNING_P, DECL_SECTION_NAME, DECL_STATIC_CHAIN, DECL_VIRTUAL_P, dump_enabled_p(), dump_printf(), dyn_cast(), dump_user_location_t::from_function_decl(), ipa_icf::FUNC, gcc_assert, cgraph_node::get_availability(), symtab_node::get_comdat_group(), get_node(), symtab_node::has_aliases_p(), cgraph_node::has_thunk_p(), cgraph_node::icf_merged, symtab_node::implicit_section, symtab_node::in_same_comdat_group_p(), ipa_fn_summaries, ipa_merge_profiles(), ipa_size_summaries, cgraph_node::local_p(), lookup_attribute(), cgraph_node::merged_comdat, MSG_MISSED_OPTIMIZATION, MSG_NOTE, MSG_OPTIMIZED_LOCATIONS, ipa_icf::sem_item::node, symtab_node::noninterposable_alias(), NULL, ipa_icf::redirect_all_callers(), cgraph_node::release_body(), symtab_node::reset(), symtab_node::resolution, symtab_node::resolve_alias(), ipa_icf::set_local(), stdarg_p(), symtab, ipa_icf::sem_item::target_supports_symbol_aliases_p(), TREE_TYPE, and ipa_icf::sem_item::type.

◆ param_used_p()

bool ipa_icf::sem_function::param_used_p ( unsigned int i)
Return true if parameter I may be used.   

References ipa_node_params::descriptors, get_node(), i, ipa_is_param_used(), ipa_node_params_sum, NULL, and vec_safe_length().

Referenced by equals_private(), and equals_wpa().

◆ parse()

sem_function * ipa_icf::sem_function::parse ( cgraph_node * node,
bitmap_obstack * stack,
ipa_icf_gimple::func_checker * checker )
static

◆ set_hash()

◆ setup()

void ipa_icf::sem_item::setup ( bitmap_obstack * stack)
privateinherited
Initialize internal data structures. Bitmap STACK is used for
bitmap memory allocation process.   

References BITMAP_ALLOC, gcc_checking_assert, ipa_icf::sem_item::node, ipa_icf::sem_item::reference_count, ipa_icf::sem_item::tree_refs, and ipa_icf::sem_item::usage_index_bitmap.

Referenced by ipa_icf::sem_item::sem_item(), and ipa_icf::sem_item::sem_item().

◆ target_supports_symbol_aliases_p()

bool ipa_icf::sem_item::target_supports_symbol_aliases_p ( void )
inherited
Return true if target supports alias symbols.   

References gcc_checking_assert, and TARGET_SUPPORTS_ALIASES.

Referenced by merge(), and ipa_icf::sem_variable::merge().

◆ update_hash_by_addr_refs()

void ipa_icf::sem_item::update_hash_by_addr_refs ( hash_map< symtab_node *, sem_item * > & m_symtab_node_map)
inherited
Update hash by address sensitive references. We iterate over all
sensitive references (address_matters_p) and we hash ultimate alias
target of these nodes, which can improve a semantic item hash.

Also hash in referenced symbols properties.  This can be done at any time
(as the properties should not change), but it is convenient to do it here
while we walk the references anyway.   

References inchash::hash::add_int(), ipa_ref::address_matters_p(), dyn_cast(), inchash::hash::end(), ipa_icf::sem_item::get_hash(), ipa_icf::sem_item::hash_referenced_symbol_properties(), i, IPA_REF_ADDR, is_a(), symtab_node::iterate_reference(), ipa_icf::sem_item::node, symtab_node::order, ipa_ref::referred, ipa_icf::sem_item::set_hash(), symtab_node::ultimate_alias_target(), and ipa_ref::use.

◆ update_hash_by_local_refs()

void ipa_icf::sem_item::update_hash_by_local_refs ( hash_map< symtab_node *, sem_item * > & m_symtab_node_map)
inherited
Update hash by computed local hash values taken from different
semantic items.
TODO: stronger SCC based hashing would be desirable here.   

References dyn_cast(), ipa_icf::FUNC, ipa_icf::sem_item::get_hash(), ipa_icf::sem_item::global_hash, symtab_node::iterate_reference(), ipa_icf::sem_item::node, and ipa_ref::referring.

Field Documentation

◆ arg_count

unsigned int ipa_icf::sem_function::arg_count

Referenced by get_hash(), and init().

◆ bb_sizes

vec<unsigned int> ipa_icf::sem_function::bb_sizes

◆ bb_sorted

vec<ipa_icf_gimple::sem_bb *> ipa_icf::sem_function::bb_sorted

◆ cfg_checksum

hashval_t ipa_icf::sem_function::cfg_checksum

Referenced by equals_private(), get_hash(), and init().

◆ cls

◆ decl

◆ edge_count

unsigned int ipa_icf::sem_function::edge_count

Referenced by equals_private(), and init().

◆ gcode_hash

hashval_t ipa_icf::sem_function::gcode_hash

Referenced by get_hash(), and init().

◆ global_hash

hashval_t ipa_icf::sem_item::global_hash
inherited

◆ index_in_class

unsigned int ipa_icf::sem_item::index_in_class
inherited

◆ m_alias_sets_hash

hashval_t ipa_icf::sem_function::m_alias_sets_hash

◆ m_checker

ipa_icf_gimple::func_checker* ipa_icf::sem_function::m_checker
private

◆ m_compared_func

sem_function* ipa_icf::sem_function::m_compared_func
private

Referenced by equals_private(), and equals_wpa().

◆ m_hash

hashval_t ipa_icf::sem_item::m_hash
protectedinherited

◆ m_hash_set

bool ipa_icf::sem_item::m_hash_set
protectedinherited

◆ m_type_hash_cache

hash_map< const_tree, hashval_t > ipa_icf::sem_item::m_type_hash_cache
staticprivateinherited

◆ memory_access_types

◆ node

◆ reference_count

unsigned ipa_icf::sem_item::reference_count
inherited

◆ referenced_by_count

unsigned ipa_icf::sem_item::referenced_by_count
inherited

◆ refs_set

hash_set<symtab_node *> ipa_icf::sem_item::refs_set
inherited

◆ region_tree

eh_region ipa_icf::sem_function::region_tree

Referenced by init().

◆ ssa_names_size

unsigned ipa_icf::sem_function::ssa_names_size

Referenced by init().

◆ tree_refs

vec<tree> ipa_icf::sem_item::tree_refs
inherited

◆ type

◆ usage_index_bitmap

bitmap ipa_icf::sem_item::usage_index_bitmap
inherited

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