GCC Middle and Back End API Reference
|
#include <ipa-icf.h>
Public Member Functions | |
sem_item_optimizer () | |
~sem_item_optimizer () | |
void | parse_funcs_and_vars (void) |
bool | execute (void) |
void | dump (void) |
void | checking_verify_classes (void) |
void | verify_classes (void) |
void | write_summary (void) |
void | read_summary (void) |
void | remove_item (sem_item *item) |
void | remove_symtab_node (symtab_node *node) |
void | register_hooks (void) |
void | unregister_hooks (void) |
void | add_class (congruence_class *cls) |
congruence_class_group * | get_group_by_hash (hashval_t hash, sem_item_type type) |
Static Public Member Functions | |
static void | cgraph_removal_hook (cgraph_node *node, void *data) |
static void | varpool_removal_hook (varpool_node *node, void *data) |
Data Fields | |
fibonacci_heap< unsigned, congruence_class > | worklist |
Private Member Functions | |
void | update_hash_by_addr_refs () |
void | update_hash_by_memory_access_type () |
void | build_hash_based_classes (void) |
unsigned int | parse_nonsingleton_classes (void) |
void | subdivide_classes_by_equality (bool in_wpa=false) |
unsigned | subdivide_classes_by_sensitive_refs () |
void | dump_cong_classes (void) |
void | build_graph (void) |
void | process_cong_reduction (void) |
bool | merge_classes (unsigned int prev_class_count, unsigned int loaded_symbols) |
void | fixup_points_to_sets (void) |
void | fixup_pt_set (struct pt_solution *pt) |
void | worklist_push (congruence_class *cls) |
congruence_class * | worklist_pop () |
void | do_congruence_step (congruence_class *cls) |
bool | do_congruence_step_for_index (congruence_class *cls, unsigned int index) |
void | read_section (lto_file_decl_data *file_data, const char *data, size_t len) |
void | filter_removed_items (void) |
Static Private Member Functions | |
static void | add_item_to_class (congruence_class *cls, sem_item *item) |
static bool | release_split_map (congruence_class *const &cls, bitmap const &b, traverse_split_pair *pair) |
static bool | traverse_congruence_split (congruence_class *const &cls, bitmap const &b, traverse_split_pair *pair) |
static int | sort_congruence_split (const void *, const void *) |
Private Attributes | |
vec< sem_item * > | m_items |
hash_set< symtab_node * > | m_removed_items_set |
hash_table< congruence_class_hash > | m_classes |
unsigned int | m_classes_count |
hash_map< symtab_node *, sem_item * > | m_symtab_node_map |
bool | splitter_class_removed |
cgraph_node_hook_list * | m_cgraph_node_hooks |
varpool_node_hook_list * | m_varpool_node_hooks |
bitmap_obstack | m_bmstack |
vec< symtab_pair > | m_merged_variables |
ref_map | m_references |
Static Private Attributes | |
static unsigned int | class_id = 0 |
Semantic item optimizer includes all top-level logic related to semantic equality comparison.
ipa_icf::sem_item_optimizer::sem_item_optimizer | ( | ) |
References bitmap_obstack_initialize(), m_bmstack, and m_items.
ipa_icf::sem_item_optimizer::~sem_item_optimizer | ( | ) |
References bitmap_obstack_release(), free(), i, m_bmstack, m_classes, m_items, and m_merged_variables.
void ipa_icf::sem_item_optimizer::add_class | ( | congruence_class * | cls | ) |
Adds a CLS to hashtable associated by hash value.
References ipa_icf::congruence_class_group::classes, gcc_assert, get_group_by_hash(), and ipa_icf::congruence_class::members.
Referenced by traverse_congruence_split().
|
staticprivate |
Makes pairing between a congruence class CLS and semantic ITEM.
References ipa_icf::sem_item::cls, ipa_icf::sem_item::index_in_class, ipa_icf::congruence_class::members, ipa_icf::congruence_class::referenced_by_count, and ipa_icf::sem_item::referenced_by_count.
Referenced by build_hash_based_classes(), subdivide_classes_by_equality(), subdivide_classes_by_sensitive_refs(), and traverse_congruence_split().
|
private |
Build references according to call graph.
References ipa_icf::sem_item::add_reference(), cgraph_edge::callee, cgraph_node::callees, dyn_cast(), ipa_icf::FUNC, ipa_icf::sem_item::get_hash(), i, symtab_node::iterate_reference(), m_items, m_references, m_symtab_node_map, cgraph_edge::next_callee, ipa_icf::sem_item::node, NULL, ipa_ref::referred, ipa_icf::sem_item::type, cgraph_node::ultimate_alias_target(), and symtab_node::ultimate_alias_target().
Referenced by execute().
|
private |
Congruence classes are built by hash value.
References add_item_to_class(), class_id, ipa_icf::congruence_class_group::classes, get_group_by_hash(), ipa_icf::sem_item::get_hash(), i, m_classes_count, m_items, and ipa_icf::sem_item::type.
Referenced by execute().
|
static |
Callgraph removal hook called for a NODE with a custom DATA.
References ipa_icf::optimizer, and remove_symtab_node().
Referenced by register_hooks().
void ipa_icf::sem_item_optimizer::checking_verify_classes | ( | void | ) |
Verify congruence classes, if checking is enabled.
References verify_classes().
Referenced by execute(), and subdivide_classes_by_equality().
|
private |
Every usage of a congruence class CLS is a candidate that can split the collection of classes. Bitmap stack BMSTACK is used for bitmap allocation.
References BITMAP_ALLOC, BITMAP_FREE, bitmap_ior_into(), do_congruence_step_for_index(), dump_file, dump_flags, EXECUTE_IF_SET_IN_BITMAP, i, ipa_icf::congruence_class::id, m_bmstack, ipa_icf::congruence_class::members, ipa_icf::congruence_class::referenced_by_count, splitter_class_removed, TDF_DETAILS, and usage().
Referenced by process_cong_reduction().
|
private |
Tests if a class CLS used as INDEXth splits any congruence classes. Bitmap stack BMSTACK is used for bitmap allocation.
References b, hash_map< KeyId, Value, Traits >::begin(), BITMAP_ALLOC, bitmap_set_bit, ipa_icf::sem_item::cls, hash_map< KeyId, Value, Traits >::elements(), hash_map< KeyId, Value, Traits >::end(), gcc_checking_assert, hash_map< KeyId, Value, Traits >::get(), i, ipa_icf::sem_item::index_in_class, m_bmstack, m_references, ipa_icf::congruence_class::members, NULL, hash_map< KeyId, Value, Traits >::put(), r, release_split_map(), sort_congruence_split(), splitter_class_removed, hash_map< KeyId, Value, Traits >::traverse(), and traverse_congruence_split().
Referenced by do_congruence_step().
void ipa_icf::sem_item_optimizer::dump | ( | void | ) |
Referenced by traverse_congruence_split().
|
private |
Debug function prints all informations about congruence classes.
References dump_file, dump_flags, fmt_size_t, free(), histogram, HOST_SIZE_T_PRINT_UNSIGNED, i, m_classes, m_items, and TDF_DETAILS.
Referenced by execute().
bool ipa_icf::sem_item_optimizer::execute | ( | void | ) |
Optimizer entry point which returns true in case it processes a merge operation. True is returned if there's a merge operation processed.
References build_graph(), build_hash_based_classes(), checking_verify_classes(), symbol_table::dump(), dump_cong_classes(), dump_file, dump_flags, filter_removed_items(), m_classes_count, merge_classes(), parse_nonsingleton_classes(), process_cong_reduction(), subdivide_classes_by_equality(), symtab, TDF_DETAILS, unregister_hooks(), update_hash_by_addr_refs(), and update_hash_by_memory_access_type().
Referenced by ipa_icf::ipa_icf_driver().
|
private |
Removes all callgraph and varpool nodes that are marked by symtab as deleted.
References symtab_node::alias, symtab_node::body_removed, hash_set< KeyId, Lazy, Traits >::contains(), ipa_icf::sem_item::decl, ipa_icf::FUNC, i, m_items, m_removed_items_set, ipa_icf::sem_item::node, remove_item(), TREE_READONLY, and ipa_icf::sem_item::type.
Referenced by execute().
|
private |
Fixup points to analysis info.
References symtab_node::decl, DECL_STRUCT_FUNCTION, DECL_UID, dyn_cast(), gimple_df::escaped, gimple_df::escaped_return, fixup_pt_set(), FOR_EACH_BB_FN, FOR_EACH_DEFINED_FUNCTION, FOR_EACH_SSA_NAME, FOR_EACH_VEC_ELT, gimple_call_clobber_set(), gimple_call_use_set(), function::gimple_df, gimple_in_ssa_p(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), i, m_merged_variables, POINTER_TYPE_P, ipa_icf::set_alias_uids(), SSA_NAME_PTR_INFO, and TREE_TYPE.
Referenced by merge_classes().
|
private |
Fixup points to set PT.
References bitmap_bit_p, bitmap_set_bit, DECL_UID, FOR_EACH_VEC_ELT, i, m_merged_variables, NULL, and pt_solution::vars.
Referenced by fixup_points_to_sets().
congruence_class_group * ipa_icf::sem_item_optimizer::get_group_by_hash | ( | hashval_t | hash, |
sem_item_type | type ) |
Gets a congruence class group based on given HASH value and TYPE.
References ipa_icf::congruence_class_group::classes, free(), ipa_icf::congruence_class_group::hash, m_classes, ipa_icf::congruence_class_group::type, and type().
Referenced by add_class(), and build_hash_based_classes().
|
private |
After reduction is done, we can declare all items in a group to be equal. PREV_CLASS_COUNT is start number of classes before reduction. True is returned if there's a merge operation processed. LOADED_SYMBOLS is number of symbols that were loaded in WPA.
References dbg_cnt(), ipa_icf::sem_item::decl, DECL_ATTRIBUTES, DECL_NAME, DECL_STRUCT_FUNCTION, DECL_UID, symtab_node::dump_asm_name(), dump_enabled_p(), dump_file, dump_flags, symtab_node::dump_name(), dump_printf_loc(), ipa_icf::sem_item::dump_to_file(), fixup_points_to_sets(), FOR_EACH_SSA_NAME, FOR_EACH_VEC_ELT, dump_user_location_t::from_function_decl(), ipa_icf::FUNC, gcc_checking_assert, i, lookup_attribute(), m_classes, m_classes_count, m_items, m_merged_variables, MAIN_NAME_P, ipa_icf::congruence_class::members, ipa_icf::sem_item::merge(), MSG_OPTIMIZED_LOCATIONS, ipa_icf::sem_item::node, NULL, POINTER_TYPE_P, ipa_icf::sort_congruence_class_groups_by_decl_uid(), ipa_icf::sort_congruence_classes_by_decl_uid(), ipa_icf::sort_sem_items_by_decl_uid(), SSA_NAME_PTR_INFO, SSA_NAME_RANGE_INFO, TDF_DETAILS, TREE_TYPE, ipa_icf::sem_item::type, and ipa_icf::VAR.
Referenced by execute().
void ipa_icf::sem_item_optimizer::parse_funcs_and_vars | ( | void | ) |
Function responsible for visiting all potential functions and read-only variables that can be merged.
References FOR_EACH_DEFINED_FUNCTION, FOR_EACH_DEFINED_VARIABLE, m_bmstack, m_items, m_symtab_node_map, ipa_icf::sem_function::parse(), and ipa_icf::sem_variable::parse().
Referenced by ipa_icf::ipa_icf_generate_summary().
|
private |
|
private |
Iterative congruence reduction function.
References do_congruence_step(), dump_file, dump_flags, fmt_size_t, HOST_SIZE_T_PRINT_UNSIGNED, i, m_classes, NULL, subdivide_classes_by_sensitive_refs(), TDF_DETAILS, worklist, worklist_pop(), and worklist_push().
Referenced by execute().
|
private |
Reads a section from LTO stream file FILE_DATA. Input block for DATA contains LEN bytes.
References inchash::hash::add_int(), lto_function_header::cfg_size, count, symtab_node::definition, dyn_cast(), inchash::hash::end(), gcc_assert, get_deref_alias_set(), i, INCREMENTAL_LINK_LTO, is_a(), lto_data_in_create(), lto_data_in_delete(), lto_free_section_data(), LTO_section_ipa_icf, lto_symtab_encoder_deref(), ipa_icf::sem_function::m_alias_sets_hash, m_bmstack, m_items, lto_simple_header::main_size, ipa_icf::sem_function::memory_access_types, NULL, ipa_icf::sem_item::set_hash(), stream_read_tree, streamer_read_uhwi(), lto_simple_header_with_strings::string_size, lto_file_decl_data::symtab_node_encoder, and vNULL.
Referenced by read_summary().
void ipa_icf::sem_item_optimizer::read_summary | ( | void | ) |
Read IPA ICF summary for symbols.
References lto_get_file_decl_data(), lto_get_summary_section_data(), LTO_section_ipa_icf, and read_section().
Referenced by ipa_icf::ipa_icf_read_summary().
void ipa_icf::sem_item_optimizer::register_hooks | ( | void | ) |
Register callgraph and varpool hooks.
References symbol_table::add_cgraph_removal_hook(), symbol_table::add_varpool_removal_hook(), cgraph_removal_hook(), m_cgraph_node_hooks, m_varpool_node_hooks, symtab, and varpool_removal_hook().
Referenced by ipa_icf::ipa_icf_generate_summary(), and ipa_icf::ipa_icf_read_summary().
|
staticprivate |
Disposes split map traverse function. CLS_PTR is pointer to congruence class, BSLOT is bitmap slot we want to release. DATA is mandatory, but unused argument.
References b, and BITMAP_FREE.
Referenced by do_congruence_step_for_index().
void ipa_icf::sem_item_optimizer::remove_item | ( | sem_item * | item | ) |
References m_symtab_node_map, and ipa_icf::sem_item::node.
Referenced by filter_removed_items().
void ipa_icf::sem_item_optimizer::remove_symtab_node | ( | symtab_node * | node | ) |
Remove symtab NODE triggered by symtab removal hooks.
References hash_set< KeyId, Lazy, Traits >::add(), gcc_assert, m_classes, and m_removed_items_set.
Referenced by cgraph_removal_hook(), and varpool_removal_hook().
|
staticprivate |
Compare function for sorting pairs in do_congruence_step_f.
Referenced by do_congruence_step_for_index().
Equality function for semantic items is used to subdivide existing classes. If IN_WPA, fast equality function is invoked.
References add_item_to_class(), checking_verify_classes(), class_id, ipa_icf::sem_item::equals(), ipa_icf::sem_item::equals_wpa(), i, m_classes, m_classes_count, m_symtab_node_map, and ipa_icf::congruence_class::members.
Referenced by execute().
|
private |
Subdivide classes by address references that members of the class reference. Example can be a pair of functions that have an address taken from a function. If these addresses are different the class is split.
References add_item_to_class(), class_id, gcc_checking_assert, i, m_classes, m_classes_count, ipa_icf::congruence_class::members, ipa_icf::sem_item::node, and worklist_push().
Referenced by process_cong_reduction().
|
staticprivate |
Process split operation for a class given as pointer CLS_PTR, where bitmap B splits congruence class members. DATA is used as argument of split pair.
References add_class(), add_item_to_class(), b, bitmap_bit_p, bitmap_count_bits(), class_id, ipa_icf::congruence_class::dump(), dump(), dump_file, dump_flags, g, gcc_assert, i, ipa_icf::congruence_class::in_worklist, m_classes, m_classes_count, ipa_icf::congruence_class::members, ipa_icf::optimizer, splitter_class_removed, TDF_DETAILS, and worklist_push().
Referenced by do_congruence_step_for_index().
void ipa_icf::sem_item_optimizer::unregister_hooks | ( | void | ) |
Unregister callgraph and varpool hooks.
References m_cgraph_node_hooks, m_varpool_node_hooks, symbol_table::remove_cgraph_removal_hook(), symbol_table::remove_varpool_removal_hook(), and symtab.
Referenced by execute().
|
private |
For each semantic item, append hash values of references.
References inchash::hash::add_hwi(), contains_polymorphic_type_p(), DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, DECL_CXX_CONSTRUCTOR_P, inchash::hash::end(), ipa_icf::FUNC, gcc_checking_assert, i, IDENTIFIER_HASH_VALUE, m_items, m_symtab_node_map, TREE_CODE, TREE_TYPE, type_in_anonymous_namespace_p(), TYPE_MAIN_VARIANT, TYPE_METHOD_BASETYPE, TYPE_NAME, and TYPE_UID.
Referenced by execute().
|
private |
References inchash::hash::add_int(), inchash::hash::end(), ipa_icf::FUNC, ipa_icf::sem_function::get_hash(), i, ipa_icf::sem_function::m_alias_sets_hash, m_items, and ipa_icf::sem_item::set_hash().
Referenced by execute().
|
static |
Varpool removal hook called for a NODE with a custom DATA.
References ipa_icf::optimizer, and remove_symtab_node().
Referenced by register_hooks().
void ipa_icf::sem_item_optimizer::verify_classes | ( | void | ) |
Verify congruence classes.
References ipa_icf::sem_item::cls, gcc_assert, i, m_classes, and ipa_icf::congruence_class::members.
Referenced by checking_verify_classes().
|
private |
Pops a class from worklist.
References ipa_icf::congruence_class::in_worklist, NULL, and worklist.
Referenced by process_cong_reduction().
|
private |
Adds a newly created congruence class CLS to worklist.
References ipa_icf::congruence_class::in_worklist, ipa_icf::congruence_class::referenced_by_count, and worklist.
Referenced by process_cong_reduction(), subdivide_classes_by_sensitive_refs(), and traverse_congruence_split().
void ipa_icf::sem_item_optimizer::write_summary | ( | void | ) |
Write IPA ICF summary for symbols.
References count, create_output_block(), output_block::decl_state, destroy_output_block(), ipa_icf::FUNC, i, lsei_end_p(), lsei_next_in_partition(), lsei_node(), lsei_start_in_partition(), LTO_section_ipa_icf, lto_symtab_encoder_encode(), m_symtab_node_map, output_block::main_stream, ipa_icf::sem_function::memory_access_types, NULL, produce_asm(), stream_write_tree, streamer_write_char_stream(), streamer_write_uhwi(), streamer_write_uhwi_stream(), output_block::symbol, and lto_out_decl_state::symtab_node_encoder.
Referenced by ipa_icf::ipa_icf_write_summary().
|
staticprivate |
|
private |
|
private |
Referenced by register_hooks(), and unregister_hooks().
|
private |
|
private |
Referenced by build_graph(), build_hash_based_classes(), dump_cong_classes(), filter_removed_items(), merge_classes(), parse_funcs_and_vars(), parse_nonsingleton_classes(), read_section(), sem_item_optimizer(), update_hash_by_addr_refs(), update_hash_by_memory_access_type(), and ~sem_item_optimizer().
|
private |
Referenced by fixup_points_to_sets(), fixup_pt_set(), merge_classes(), and ~sem_item_optimizer().
|
private |
Referenced by build_graph(), and do_congruence_step_for_index().
|
private |
Referenced by filter_removed_items(), and remove_symtab_node().
|
private |
|
private |
Referenced by register_hooks(), and unregister_hooks().
|
private |
Referenced by do_congruence_step(), do_congruence_step_for_index(), and traverse_congruence_split().
fibonacci_heap<unsigned, congruence_class> ipa_icf::sem_item_optimizer::worklist |
Referenced by process_cong_reduction(), worklist_pop(), and worklist_push().