GCC Middle and Back End API Reference
|
Data Structures | |
struct | histogram_entry |
struct | histogram_hash |
Variables | |
vec< histogram_entry * > | histogram |
static alloc_pool | histogram_pool |
static vec< tree > | static_ctors |
static vec< tree > | static_dtors |
|
static |
Account TIME and SIZE executed COUNT times into HISTOGRAM. HASHTABLE is the on-side hash kept to avoid duplicates.
References cgraph_edge::count, hash_table< Descriptor, Allocator >::find_slot(), and pool_alloc().
Referenced by ipa_profile_generate_summary(), and ipa_profile_read_summary().
|
static |
Return true when there is a reference to node and it is not vtable.
References symtab_node_base::decl, IPA_REF_ADDR, ipa_ref_referring_varpool_node(), ipa_ref::referring, and varpool_node::symbol.
Referenced by comdat_can_be_unshared_p_1().
|
static |
Define global constructors/destructor functions for the CDTORS, of which they are LEN. The CDTORS are sorted by initialization priority. If CTOR_P is true, these are constructors; otherwise, they are destructors.
References append_to_statement_list(), build_call_expr(), cgraph_build_static_cdtor_1(), len, priority(), and targetm.
Referenced by build_cdtor_fns().
|
static |
Generate functions to call static constructors and destructors for targets that do not support .ctors/.dtors sections. These functions have magic names which are detected by collect2.
References build_cdtor(), compare_ctor(), compare_dtor(), and targetm.
Referenced by ipa_cdtor_merge().
bool can_replace_by_local_alias | ( | ) |
Return true if reference to NODE can be replaced by a local alias. Local aliases save dynamic linking overhead and enable more optimizations.
References AVAIL_OVERWRITABLE, symtab_can_be_discarded(), and symtab_node_availability().
Referenced by function_and_variable_visibility().
void cgraph_build_static_cdtor | ( | ) |
Generate and emit a static constructor or destructor. WHICH must be one of 'I' (for a constructor) or 'D' (for a destructor). BODY is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the initialization priority for this constructor or destructor.
References cgraph_build_static_cdtor_1().
|
static |
Generate and emit a static constructor or destructor. WHICH must be one of 'I' (for a constructor) or 'D' (for a destructor). BODY is a STATEMENT_LIST containing GENERIC statements. PRIORITY is the initialization priority for this constructor or destructor. FINAL specify whether the externally visible name for collect2 should be produced.
References allocate_struct_function(), build_function_type_list(), cfun, cgraph_add_new_function(), current_function_decl, decl_fini_priority_insert(), decl_init_priority_insert(), function::function_end_locus, get_file_function_name(), gimplify_function_tree(), input_location, set_cfun(), and targetm.
Referenced by build_cdtor(), and cgraph_build_static_cdtor().
|
static |
Return true when function NODE should be considered externally visible.
References comdat_can_be_unshared_p(), symtab_node_base::decl, symtab_node_base::definition, lookup_attribute(), cgraph_node::symbol, symtab_used_from_object_file_p(), VISIBILITY_HIDDEN, and VISIBILITY_INTERNAL.
Referenced by function_and_variable_visibility().
|
static |
Return true when function can be marked local.
References cgraph_for_node_and_aliases(), cgraph_function_or_thunk_node(), cgraph_non_local_node_p_1(), cgraph_node::thunk, and cgraph_thunk_info::thunk_p.
Referenced by function_and_variable_visibility(), and symtab_remove_unreachable_nodes().
|
static |
@verbatim Basic IPA optimizations and utilities.
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/.
Return true when NODE can not be local. Worker for cgraph_local_node_p.
References cgraph_only_called_directly_or_aliased_p(), symtab_node_base::decl, symtab_node_base::definition, symtab_node_base::externally_visible, symtab_node_base::in_other_partition, ipa_ref_has_aliases_p(), symtab_node_base::ref_list, cgraph_node::symbol, and symtab_node_base::used_from_other_partition.
Referenced by cgraph_local_node_p().
int cmp_counts | ( | ) |
References histogram_entry::count.
Referenced by ipa_profile_generate_summary(), and ipa_profile_read_summary().
|
static |
COMDAT functions must be shared only if they have address taken, otherwise we can produce our own private implementation with -fwhole-program. Return true when turning COMDAT functoin static can not lead to wrong code when the resulting object links with a library defining same COMDAT. Virtual functions do have their addresses taken from the vtables, but in C++ there is no way to compare their addresses for equality.
References comdat_can_be_unshared_p_1().
Referenced by cgraph_externally_visible_p(), and varpool_externally_visible_p().
|
static |
A helper for comdat_can_be_unshared_p.
References address_taken_from_non_vtable_p().
Referenced by comdat_can_be_unshared_p().
|
static |
Comparison function for qsort. P1 and P2 are actually of type "tree *" and point to static constructors. DECL_INIT_PRIORITY is used to determine the sort order.
Referenced by build_cdtor_fns().
|
static |
Comparison function for qsort. P1 and P2 are actually of type "tree *" and point to static destructors. DECL_FINI_PRIORITY is used to determine the sort order.
Referenced by build_cdtor_fns().
|
static |
Dump HISTOGRAM to FILE.
References cgraph_edge::count, dump_file, HOST_WIDEST_INT, HOST_WIDEST_INT_PRINT_DEC, and overall_size.
Referenced by ipa_profile().
|
static |
Add symtab NODE to queue starting at FIRST. The queue is linked via AUX pointers and terminated by pointer to 1. We enqueue nodes at two occasions: when we find them reachable or when we find their bodies needed for further clonning. In the second case we mark them by pointer to 2 after processing so they are re-queue when they become reachable.
References first, and pointer_set_contains().
Referenced by process_references(), and symtab_remove_unreachable_nodes().
|
static |
Free inline summary.
References inline_free_summary().
|
static |
Mark visibility of all functions. A local function is one whose calls can occur only in the current compilation unit and all its calls are explicit, so we can change its calling convention. We simply mark all static functions whose address is not taken as local. We also change the TREE_PUBLIC flag of all declarations that are public in language point of view but we want to overwrite this default via visibilities for the backend point of view.
References alias_pairs, cgraph_edge::callee, cgraph_node::callees, cgraph_edge::caller, cgraph_node::callers, can_replace_by_local_alias(), cgraph(), cgraph_externally_visible_p(), cgraph_function_flags_ready, cgraph_function_node(), cgraph_local_node_p(), cgraph_node_name(), cgraph_redirect_edge_call_stmt_to_callee(), cgraph_redirect_edge_callee(), symtab_node_base::decl, symtab_node_base::definition, dump_file, symtab_node_base::externally_visible, flags_from_decl_or_type(), symtab_node_base::force_output, symtab_node_base::forced_by_abi, gimple_has_body_p(), cgraph_node::global, cgraph_global_info::inlined_to, cgraph_local_info::local, cgraph_node::local, pop_cfun(), push_cfun(), symtab_node_base::same_comdat_group, cgraph_node::symbol, varpool_node::symbol, symtab_dissolve_same_comdat_group_list(), symtab_make_decl_local(), symtab_nonoverwritable_alias(), cgraph_node::thunk, cgraph_thunk_info::thunk_p, symtab_node_base::unique_name, varpool_externally_visible_p(), varpool_node_name(), and symtab_node_base::weakref.
Referenced by local_function_and_variable_visibility(), and whole_program_function_and_variable_visibility().
|
static |
Perform the pass when we have no ctors/dtors support or at LTO time to merge multiple constructors into single function.
References targetm.
|
static |
|
static |
Do not re-run on ltrans stage.
|
static |
Return true when NODE has ADDR reference.
References IPA_REF_ADDR, symtab_node_base::ref_list, and cgraph_node::symbol.
Referenced by symtab_remove_unreachable_nodes().
|
static |
Look for constructors and destructors and produce function calling them. This is needed for targets not supporting ctors or dtors, but we perform the transformation also at linktime to merge possibly numerous constructors/destructors into single function to improve code locality and reduce size.
References build_cdtor_fns(), symtab_node_base::decl, record_cdtor_fn(), and cgraph_node::symbol.
void ipa_discover_readonly_nonaddressable_vars | ( | void | ) |
Discover variables that have no longer address taken or that are read only and update their flags. FIXME: This can not be done in between gimplify and omp_expand since readonly flag plays role on what is shared and what is not. Currently we do this transformation as part of whole program visibility and re-do at ipa-reference pass (to take into account clonning), but it would make sense to do it before early optimizations.
References symtab_node_base::decl, symtab_node_base::definition, dump_file, IPA_REF_ADDR, IPA_REF_LOAD, IPA_REF_STORE, symtab_node_base::ref_list, varpool_node::symbol, varpool_all_refs_explicit_p(), and varpool_node_name().
Referenced by propagate(), and whole_program_function_and_variable_visibility().
|
static |
Simple ipa profile pass propagating frequencies across the callgraph.
References apply_scale(), symtab_node_base::aux, AVAIL_OVERWRITABLE, cgraph_edge::callee, cgraph_node::callees, cgraph(), cgraph_function_body_availability(), cgraph_maybe_hot_edge_p(), cgraph_n_nodes, cgraph_node_name(), cgraph_propagate_frequency(), cgraph_turn_edge_to_speculative(), cgraph_indirect_call_info::common_target_id, cgraph_indirect_call_info::common_target_probability, cgraph_node::count, cgraph_edge::count, del_node_map(), dump_file, dump_histogram(), find_func_by_profile_id(), free(), free_alloc_pool(), cgraph_edge::frequency, get_hot_bb_threshold(), HOST_WIDEST_INT, HOST_WIDEST_INT_PRINT_DEC, cgraph_node::indirect_calls, cgraph_edge::indirect_info, init_node_map(), inline_update_overall_summary(), ipa_reverse_postorder(), cgraph_local_info::local, cgraph_node::local, cgraph_edge::next_callee, symtab_node_base::order, order, overall_size, set_hot_bb_threshold(), cgraph_node::symbol, symtab_can_be_discarded(), and symtab_nonoverwritable_alias().
|
static |
Collect histogram from CFG profiles.
References account_time_size(), cgraph_edge(), cmp_counts(), cgraph_indirect_call_info::common_target_id, cgraph_indirect_call_info::common_target_probability, basic_block_def::count, histogram_value_t::counters, hash_table< Descriptor, Allocator >::create(), create_alloc_pool(), symtab_node_base::decl, hash_table< Descriptor, Allocator >::dispose(), dump_file, eni_size_weights, eni_time_weights, estimate_num_insns(), gimple_call_fndecl(), gimple_histogram_value_of_type(), gimple_remove_histogram_value(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), HIST_TYPE_INDIR_CALL, histogram_value_t::hvalue, cgraph_edge::indirect_info, and cgraph_node::symbol.
|
static |
Deserialize the ipa info for lto.
References account_time_size(), cmp_counts(), cgraph_edge::count, hash_table< Descriptor, Allocator >::create(), create_alloc_pool(), hash_table< Descriptor, Allocator >::dispose(), len, lto_create_simple_input_block(), lto_destroy_simple_input_block(), lto_get_file_decl_data(), LTO_section_ipa_profile, streamer_read_gcov_count(), and streamer_read_uhwi().
|
static |
Serialize the ipa info for lto.
References lto_create_simple_output_block(), lto_destroy_simple_output_block(), LTO_section_ipa_profile, lto_simple_output_block::main_stream, streamer_write_gcov_count_stream(), and streamer_write_uhwi_stream().
|
static |
Local function pass handling visibilities. This happens before LTO streaming so in particular -fwhole-program should be ignored at this level.
References function_and_variable_visibility().
ipa_opt_pass_d* make_pass_ipa_cdtor_merge | ( | ) |
simple_ipa_opt_pass* make_pass_ipa_free_inline_summary | ( | ) |
simple_ipa_opt_pass* make_pass_ipa_function_and_variable_visibility | ( | ) |
ipa_opt_pass_d* make_pass_ipa_profile | ( | ) |
ipa_opt_pass_d* make_pass_ipa_whole_program_visibility | ( | ) |
|
static |
Process references.
References ctor_for_folding(), enqueue_node(), pointer_set_insert(), and ipa_ref::referred.
Referenced by symtab_remove_unreachable_nodes().
|
static |
When target does not have ctors and dtors, we call all constructor and destructor by special initialization/destruction function recognized by collect2. When we are going to build this function, collect all constructors and destructors and turn them into normal functions.
References cgraph_get_node(), symtab_node_base::decl, and cgraph_node::symbol.
Referenced by ipa_cdtor_merge().
bool symtab_remove_unreachable_nodes | ( | ) |
Perform reachability analysis and reclaim all unreachable nodes. The algorithm is basically mark&sweep but with some extra refinements: - reachable extern inline functions needs special handling; the bodies needs to stay in memory until inlining in hope that they will be inlined. After inlining we release their bodies and turn them into unanalyzed nodes even when they are reachable. BEFORE_INLINING_P specify whether we are before or after inlining. - virtual functions are kept in callgraph even if they seem unreachable in hope calls to them will be devirtualized. Again we remove them after inlining. In late optimization some devirtualization may happen, but it is not importnat since we won't inline the call. In theory early opts and IPA should work out all important cases. - virtual clones needs bodies of their origins for later materialization; this means that we want to keep the body even if the origin is unreachable otherwise. To avoid origin from sitting in the callgraph and being walked by IPA passes, we turn them into unanalyzed nodes with body defined. We maintain set of function declaration where body needs to stay in body_needed_for_clonning Inline clones represent special case: their declaration match the declaration of origin and cgraph_remove_node already knows how to reshape callgraph and preserve body when offline copy of function or inline clone is being removed. - C++ virtual tables keyed to other unit are represented as DECL_EXTERNAL variables with DECL_INITIAL set. We finalize these and keep reachable ones around for constant folding purposes. After inlining we however stop walking their references to let everything static referneced by them to be removed when it is otherwise unreachable. We maintain queue of both reachable symbols (i.e. defined symbols that needs to stay) and symbols that are in boundary (i.e. external symbols referenced by reachable symbols or origins of clones). The queue is represented as linked list by AUX pointer terminated by 1. A the end we keep all reachable symbols. For symbols in boundary we always turn definition into a declaration, but we may keep function body around based on body_needed_for_clonning All symbols that enter the queue have AUX pointer non-zero and are in the boundary. Pointer set REACHABLE is used to track reachable symbols. Every symbol can be visited twice - once as part of boundary and once as real reachable symbol. enqueue_node needs to decide whether the node needs to be re-queued for second processing. For this purpose we set AUX pointer of processed symbols in the boundary to constant 2.
References symtab_node_base::address_taken, symtab_node_base::alias, symtab_node_base::analyzed, symtab_node_base::aux, cgraph_edge::callee, cgraph_node::callers, cgraph_can_remove_if_no_direct_calls_and_refs_p(), cgraph_first_function(), cgraph_for_node_and_aliases(), cgraph_function_with_gimple_body_p(), cgraph_get_create_real_symbol_node(), cgraph_local_node_p(), cgraph_next_function(), cgraph_node_name(), cgraph_node_remove_callees(), cgraph_propagate_frequency(), cgraph_release_function_body(), cgraph_remove_node(), changed, cgraph_node::clone_of, cgraph_node::clones, symtab_node_base::cpp_implicit_alias, ctor_for_folding(), symtab_node_base::decl, symtab_node_base::definition, dyn_cast(), enqueue_node(), first, cgraph_node::global, has_addr_references_p(), symtab_node_base::in_other_partition, inline_edge_summary_vec, cgraph_edge::inline_failed, cgraph_global_info::inlined_to, ipa_remove_all_references(), cgraph_local_info::local, cgraph_node::local, cgraph_edge::next_callee, pointer_set_contains(), pointer_set_create(), pointer_set_destroy(), pointer_set_insert(), process_references(), symtab_node_base::ref_list, ipa_ref::referred, cgraph_node::symbol, varpool_node::symbol, update_inlined_to_pointer(), cgraph_node::used_as_abstract_origin, symtab_node_base::used_from_other_partition, varpool_can_remove_if_no_refs(), varpool_first_variable(), varpool_next_variable(), varpool_node_name(), varpool_remove_initializer(), varpool_remove_node(), verify_symtab(), and symtab_node_base::weakref.
|
static |
Look for all functions inlined to NODE and update their inlined_to pointers to INLINED_TO.
References cgraph_edge::callee, cgraph_node::callees, cgraph_node::global, cgraph_global_info::inlined_to, and cgraph_edge::next_callee.
Referenced by symtab_remove_unreachable_nodes().
bool varpool_externally_visible_p | ( | ) |
Return true when variable VNODE should be considered externally visible.
References comdat_can_be_unshared_p(), symtab_node_base::decl, lookup_attribute(), varpool_node::symbol, symtab_used_from_object_file_p(), VISIBILITY_HIDDEN, and VISIBILITY_INTERNAL.
|
static |
Bring functionss local at LTO time with -fwhole-program.
References function_and_variable_visibility(), and ipa_discover_readonly_nonaddressable_vars().
vec<histogram_entry *> histogram |
Histogram of profile values. The histogram is represented as an ordered vector of entries allocated via histogram_pool. During construction a separate hashtable is kept to lookup duplicate entries.
Referenced by gimple_divmod_fixed_value_transform(), gimple_ic_transform(), gimple_mod_pow2_value_transform(), gimple_mod_subtract_transform(), gimple_stringops_transform(), and stringop_block_profile().
|
static |