GCC Middle and Back End API Reference
|
Go to the source code of this file.
Data Structures | |
struct | ipa_dfs_info |
Typedefs | |
typedef odr_type_d * | odr_type |
Variables | |
bool | thunk_expansion |
typedef odr_type_d* odr_type |
void build_type_inheritance_graph | ( | void | ) |
Initialize IPA devirt and build inheritance tree graph.
References symtab_node::decl, DECL_CONTEXT, DECL_VIRTUAL_P, dump_begin(), dump_end(), dump_type_inheritance_graph(), FOR_EACH_SYMBOL, free_odr_warning_data(), get_odr_type(), is_a(), odr_hash, polymorphic_type_binfo_p(), symtab_node::real_symbol_p(), TDI_inheritance, timevar_pop(), timevar_push(), TREE_CODE, TREE_TYPE, TYPE_BINFO, TYPE_MAIN_VARIANT, and TYPE_METHOD_BASETYPE.
Referenced by analyze_functions(), and symbol_table::remove_unreachable_nodes().
Recognize special cases of builtins that are by themselves not const but function using them is.
References BUILT_IN_NORMAL, CASE_BUILT_IN_ALLOCA, DECL_BUILT_IN_CLASS, and DECL_FUNCTION_CODE().
Referenced by check_call(), and propagate_pure_const().
void compare_virtual_tables | ( | varpool_node * | prevailing, |
varpool_node * | vtable ) |
Compare two virtual tables, PREVAILING and VTABLE and output ODR violation warnings.
References symtab_node::decl, DECL_CONTEXT, DECL_SIZE, DECL_SOURCE_LOCATION, DECL_VIRTUAL_P, symtab_node::definition, gcc_assert, get_odr_type(), inform(), symtab_node::iterate_reference(), methods_equal_p(), odr_type_d::odr_violated, odr_violation_reported, polymorphic_type_binfo_p(), ipa_ref::referred, ipa_ref::referring, odr_type_d::rtti_broken, TREE_CODE, TYPE_BINFO, TYPE_NAME, symtab_node::ultimate_alias_target(), VAR_P, and warning_at().
bool contains_polymorphic_type_p | ( | const_tree | type | ) |
References contains_polymorphic_type_p(), DECL_ARTIFICIAL, DECL_CHAIN, polymorphic_type_binfo_p(), RECORD_OR_UNION_TYPE_P, TREE_CODE, TREE_TYPE, TYPE_BINFO, TYPE_FIELDS, and TYPE_MAIN_VARIANT.
Referenced by check_stmt_for_type_change(), ipa_icf_gimple::func_checker::compatible_polymorphic_types_p(), contains_polymorphic_type_p(), ipa_polymorphic_call_context::ipa_polymorphic_call_context(), ipa_polymorphic_call_context::restrict_to_inner_class(), ipa_polymorphic_call_context::set_by_decl(), ipa_polymorphic_call_context::speculation_consistent_p(), and ipa_icf::sem_item_optimizer::update_hash_by_addr_refs().
We know that the instance is stored in variable or parameter (not dynamically allocated) and we want to disprove the fact that it may be in construction at invocation of CALL. BASE represents memory location where instance is stored. If BASE is NULL, it is assumed to be global memory. OUTER_TYPE is known type of the instance or NULL if not known. For the variable to be in construction we actually need to be in constructor of corresponding global variable or the inline stack of CALL must contain the constructor. Check this condition. This check works safely only before IPA passes, because inline stacks may become out of date later.
References auto_var_in_fn_p(), BLOCK_SUPERCONTEXT, DECL_ABSTRACT_ORIGIN, DECL_CXX_CONSTRUCTOR_P, DECL_CXX_DESTRUCTOR_P, DECL_P, DECL_STRUCT_FUNCTION, ECF_CONST, ECF_PURE, flags_from_decl_or_type(), gcc_assert, gimple_block(), inlined_polymorphic_ctor_dtor_block_p(), is_global_var(), polymorphic_type_binfo_p(), TREE_CODE, TREE_TYPE, TYPE_BINFO, TYPE_MAIN_VARIANT, TYPE_METHOD_BASETYPE, types_odr_comparable(), types_same_for_odr(), and VAR_P.
Referenced by symbol_table::create_edge(), and ipa_polymorphic_call_context::ipa_polymorphic_call_context().
void dump_possible_polymorphic_call_targets | ( | FILE * | f, |
tree | otr_type, | ||
HOST_WIDE_INT | otr_token, | ||
const ipa_polymorphic_call_context & | ctx, | ||
bool | verbose ) |
Dump all possible targets of a polymorphic call.
References ipa_polymorphic_call_context::dump(), dump_targets(), gcc_assert, get_odr_type(), IPA_SSA, ipa_polymorphic_call_context::maybe_derived_type, ipa_polymorphic_call_context::maybe_in_construction, NULL, possible_polymorphic_call_targets(), print_generic_expr(), ipa_polymorphic_call_context::speculative_maybe_derived_type, symbol_table::state, symtab, TDF_SLIM, TYPE_MAIN_VARIANT, and verbose.
Referenced by dump_possible_polymorphic_call_targets(), eliminate_dom_walker::eliminate_stmt(), ipa_devirt(), and walk_polymorphic_call_targets().
|
inline |
Dump possible targets of a polymorphic call E into F.
References dump_possible_polymorphic_call_targets(), cgraph_edge::indirect_info, cgraph_indirect_call_info::otr_token, cgraph_indirect_call_info::otr_type, and verbose.
void enable_odr_based_tbaa | ( | tree | type | ) |
Set tbaa_enabled flag for TYPE.
References get_odr_type(), and odr_type_d::tbaa_enabled.
Return bitmap of all basic blocks whose first statements are known to execute on every invocation of the function. If assume_return_or_eh we can further assume that the function ends either by retrn statement or EH (no trapping or infinite loops). This is useful when sumarizing function in passes like ipa-modref. Seeing assume_return_or_eh to false is used to prove that given statmeent will be executed even if the function gets into infinite loop or trap.
References hash_set< KeyId, Lazy, Traits >::add(), BITMAP_ALLOC, bitmap_print(), bitmap_set_bit, bitmap_tree_view(), calculate_dominance_info(), CDI_DOMINATORS, hash_set< KeyId, Lazy, Traits >::contains(), function::decl, dom_info_available_p(), dominated_by_p(), dump_file, dump_flags, ECF_CONST, ECF_LOOPING_CONST_OR_PURE, ECF_PURE, EDGE_COUNT, ENTRY_BLOCK_PTR_FOR_FN, EXIT_BLOCK, EXIT_BLOCK_PTR_FOR_FN, finite_loop_p(), basic_block_def::flags, flags_from_decl_or_type(), FOR_EACH_EDGE, gcc_obstack_init, gsi_end_p(), gsi_next_nondebug(), gsi_start_nondebug_after_labels_bb(), gsi_stmt(), basic_block_def::index, mark_dfs_back_edges(), MAX, MIN, NULL, obstack, basic_block_def::preds, si, single_succ_edge(), stmt_may_terminate_function_p(), basic_block_def::succs, TDF_DETAILS, visited, and worklist.
bool finite_function_p | ( | ) |
In ipa-pure-const.cc
Return true if function is known to be finite.
References cfun, dump_file, dump_flags, finite_loop_p(), flow_loops_dump(), loop_optimizer_finalize(), loop_optimizer_init(), LOOPS_HAVE_PREHEADERS, LOOPS_HAVE_RECORDED_EXITS, LOOPS_HAVE_SIMPLE_LATCHES, mark_dfs_back_edges(), mark_irreducible_loops(), NULL, loop::num, scev_finalize(), scev_initialize(), and TDF_DETAILS.
Referenced by analyze_function().
Given a memory reference T, will return the variable at the bottom of the access. Unlike get_base_address, this will recurse through INDIRECT_REFS.
References CONSTANT_CLASS_P, SSA_VAR_P, TREE_CODE, and TREE_OPERAND.
Referenced by symtab_node::maybe_create_reference(), and record_reference().
|
inline |
If TYPE has mangled ODR name, return it. Otherwise return NULL. The function works only when free_lang_data is run.
References DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, IDENTIFIER_POINTER, NULL, NULL_TREE, TREE_CODE, and TYPE_NAME.
Referenced by debug_tree_odr_name(), and warn_types_mismatch().
Get ODR type hash entry for TYPE. If INSERT is true, create possibly new entry.
References hash_set< KeyId, Lazy, Traits >::add(), add_type_duplicate(), odr_type_d::all_derivations_known, odr_type_d::anonymous_namespace, odr_type_d::bases, BINFO_BASE_BINFO, BINFO_N_BASE_BINFOS, BINFO_TYPE, can_be_name_hashed_p(), COMPLETE_TYPE_P, odr_type_d::derived_types, hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), gcc_assert, gcc_checking_assert, get_odr_type(), ggc_cleared_alloc(), hash_odr_name(), i, odr_type_d::id, insert(), NULL, odr_hash, odr_types, odr_types_ptr, polymorphic_type_binfo_p(), TREE_CODE, odr_type_d::type, type(), type_all_derivations_known_p(), TYPE_BINFO, TYPE_CANONICAL, type_in_anonymous_namespace_p(), TYPE_MAIN_VARIANT, TYPE_STRUCTURAL_EQUALITY_P, type_with_linkage_p(), odr_type_d::types_set, vec_safe_push(), and vNULL.
Referenced by add_type_duplicate(), build_type_inheritance_graph(), compare_virtual_tables(), dump_possible_polymorphic_call_targets(), enable_odr_based_tbaa(), get_odr_type(), obj_type_ref_class(), odr_based_tbaa_p(), odr_subtypes_equivalent_p(), odr_type_violation_reported_p(), possible_polymorphic_call_targets(), prevailing_odr_type(), register_odr_type(), set_type_canonical_for_odr_type(), type_known_to_have_no_derivations_p(), and update_type_inheritance_graph().
Return a FUNCTION_DECL if BLOCK represents a constructor or destructor. If CHECK_CLONES is true, also check for clones of ctor/dtors.
References block_ultimate_origin(), NULL, NULL_TREE, polymorphic_ctor_dtor_p(), and TREE_CODE.
Referenced by decl_maybe_in_construction_p(), noncall_stmt_may_be_vtbl_ptr_store(), param_type_may_change_p(), and remove_unused_scope_block_p().
bool ipa_edge_within_scc | ( | struct cgraph_edge * | cs | ) |
Return true iff the CS is an edge within a strongly connected component as computed by ipa_reduced_postorder.
References symtab_node::aux, cgraph_edge::callee, cgraph_edge::caller, cgraph_node::function_symbol(), and ipa_dfs_info::scc_no.
Referenced by ipcp_lattice< valtype >::add_value(), has_undead_caller_from_outside_scc_p(), propagate_constants_topo(), propagate_vals_across_ancestor(), propagate_vals_across_arith_jfunc(), propagate_vr_across_jump_function(), and spread_undeadness().
void ipa_free_postorder_info | ( | void | ) |
Deallocate all ipa_dfs_info structures pointed to by the aux pointer of call graph nodes.
References symtab_node::aux, FOR_EACH_DEFINED_FUNCTION, free(), and NULL.
Referenced by free_toporder_info(), inline_small_functions(), propagate(), propagate_malloc(), propagate_nothrow(), and propagate_pure_const().
vec< cgraph_node * > ipa_get_nodes_in_cycle | ( | struct cgraph_node * | node | ) |
Get the set of nodes for the cycle in the reduced call graph starting from NODE.
References symtab_node::aux, ipa_dfs_info::next_cycle, and vNULL.
Referenced by propagate(), and propagate_constants_topo().
void ipa_icf_cc_finalize | ( | void | ) |
In ipa-icf.cc
Reset all state within ipa-icf.cc so that we can rerun the compiler within the same process. For use by toplev::finalize.
References NULL, and ipa_icf::optimizer.
Referenced by toplev::finalize().
bool ipa_make_function_const | ( | struct cgraph_node * | node, |
bool | looping, | ||
bool | local ) |
Make function const and output warning. If LOCAL is true, return true if anything changed. Otherwise return true if we may have introduced removale ctors.
References cgraph_node::call_for_symbol_and_aliases(), cdtor_p(), dbg_cnt(), symtab_node::decl, DECL_LOOPING_CONST_OR_PURE_P, dump_file, symtab_node::dump_name(), NULL, cgraph_node::set_const_flag(), skip_function_for_local_pure_const(), TREE_READONLY, and warn_function_const().
Referenced by propagate_pure_const().
bool ipa_make_function_pure | ( | struct cgraph_node * | node, |
bool | looping, | ||
bool | local ) |
Make function const and output warning. If LOCAL is true, return true if anything changed. Otherwise return true if we may have introduced removale ctors.
References cgraph_node::call_for_symbol_and_aliases(), cdtor_p(), dbg_cnt(), symtab_node::decl, DECL_LOOPING_CONST_OR_PURE_P, DECL_PURE_P, dump_file, symtab_node::dump_name(), NULL, cgraph_node::set_pure_flag(), skip_function_for_local_pure_const(), TREE_READONLY, and warn_function_pure().
Referenced by propagate_pure_const().
void ipa_merge_profiles | ( | struct cgraph_node * | dst, |
struct cgraph_node * | src, | ||
bool | preserve_body ) |
SRC and DST are going to be merged. Take SRC's profile and merge it into DST so it is not going to be lost. Possibly destroy SRC's body on the way unless PRESERVE_BODY is set.
References symtab_node::alias, profile_count::apply_scale(), BASIC_BLOCK_FOR_FN, cgraph_edge::call_stmt, cgraph_node::callees, hash_table< Descriptor, Lazy, Allocator >::clear_slot(), compute_fn_summary(), compute_function_frequency(), copy_node(), basic_block_def::count, cgraph_edge::count, cgraph_node::count, symtab_node::decl, DECL_ARGUMENTS, DECL_INITIAL, DECL_RESULT, DECL_STRUCT_FUNCTION, symtab_node::definition, profile_count::dump(), symbol_table::dump_file, symtab_node::dump_name(), dyn_cast(), EDGE_COUNT, EDGE_SUCC, ENTRY_BLOCK_PTR_FOR_FN, hash_table< Descriptor, Lazy, Allocator >::find_slot(), cgraph_edge::first_speculative_call_target(), lto_in_decl_state::fn_decl, FOR_ALL_BB_FN, cgraph_node::frequency, lto_file_decl_data::function_decl_states, gcc_assert, cgraph_node::get_untransformed_body(), gimple_bb(), i, basic_block_def::index, cgraph_node::indirect_calls, profile_count::initialized_p(), profile_count::ipa(), last_basic_block_for_fn, symtab_node::lto_file_data, cgraph_edge::make_speculative(), n_basic_blocks_for_fn, cgraph_edge::next_callee, cgraph_edge::next_speculative_call_target(), profile_count::nonzero_p(), NULL, pop_cfun(), profile_count::probability_in(), cgraph_node::profile_id, push_cfun(), cgraph_edge::redirect_callee(), cgraph_node::release_body(), cgraph_edge::resolve_speculation(), scale_ipa_profile_for_fn(), cgraph_edge::speculative, cgraph_edge::speculative_call_for_target(), basic_block_def::succs, symtab, cgraph_node::thunk, cgraph_node::tp_first_run, update_max_bb_count(), and profile_count::zero().
Referenced by ipa_icf::sem_function::merge().
void ipa_print_order | ( | FILE * | out, |
const char * | note, | ||
struct cgraph_node ** | order, | ||
int | count ) |
In ipa-utils.cc
Utilities for ipa analysis. Copyright (C) 2005-2024 Free Software Foundation, Inc. Contributed by Kenneth Zadeck <zadeck@naturalbridge.com> 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/>.
Debugging function for postorder and inorder code. NOTE is a string that is printed before the nodes are printed. ORDER is an array of cgraph_nodes that has COUNT useful nodes in it.
Referenced by propagate(), propagate_nothrow(), and propagate_pure_const().
void ipa_profile_cc_finalize | ( | void | ) |
Reset all state within ipa-profile.cc so that we can rerun the compiler within the same process. For use by toplev::finalize.
References call_sums, and NULL.
Referenced by toplev::finalize().
bool ipa_propagate_frequency | ( | struct cgraph_node * | node | ) |
In ipa-profile.cc
See if the frequency of NODE can be updated based on frequencies of its callers.
References symtab_node::alias, symtab_node::analyzed, cgraph_node::call_for_symbol_and_aliases(), changed, contains_hot_call_p(), cgraph_node::count, symtab_node::decl, DECL_VIRTUAL_P, dump_file, dump_flags, symtab_node::dump_name(), cgraph_node::frequency, gcc_assert, get_hot_bb_threshold(), ipa_propagate_frequency_1(), cgraph_node::local, ipa_propagate_frequency_data::maybe_executed_once, ipa_propagate_frequency_data::maybe_unlikely_executed, NODE_FREQUENCY_EXECUTED_ONCE, NODE_FREQUENCY_HOT, NODE_FREQUENCY_NORMAL, NODE_FREQUENCY_UNLIKELY_EXECUTED, cgraph_node::only_called_at_exit, ipa_propagate_frequency_data::only_called_at_exit, cgraph_node::only_called_at_startup, ipa_propagate_frequency_data::only_called_at_startup, opt_for_fn, TDF_DETAILS, and profile_count::zero().
Referenced by inline_update_callee_summaries(), ipa_profile(), and symbol_table::remove_unreachable_nodes().
int ipa_reduced_postorder | ( | struct cgraph_node ** | order, |
bool | reduce, | ||
bool(* | ignore_edge )(struct cgraph_edge *) ) |
Topsort the call graph by caller relation. Put the result in ORDER. The REDUCE flag is true if you want the cycles reduced to single nodes. You can use ipa_get_nodes_in_cycle to obtain a vector containing all real call graph nodes in a reduced node. Set ALLOW_OVERWRITABLE if nodes with such availability should be included. IGNORE_EDGE, if non-NULL is a hook that may make some edges insignificant for the topological sort.
References symtab_node::aux, AVAIL_INTERPOSABLE, symbol_table::cgraph_count, env, FOR_EACH_DEFINED_FUNCTION, free(), cgraph_node::get_availability(), cgraph_node::get_uid(), ipa_dfs_info::new_node, ipa_dfs_info::next_cycle, NULL, ipa_dfs_info::on_stack, searchc_env::reduce, searchc_env::result, searchc(), and symtab.
Referenced by build_toporder_info(), inline_small_functions(), propagate(), propagate_nothrow(), and propagate_pure_const().
int ipa_reverse_postorder | ( | struct cgraph_node ** | order | ) |
Fill array order with all nodes with output flag set in the reverse topological order. Return the number of elements in the array. FIXME: While walking, consider aliases, too.
References symtab_node::address_taken, symtab_node::alias, symtab_node::aux, cgraph_node::callers, symbol_table::cgraph_count, dyn_cast(), postorder_stack::edge, FOR_EACH_FUNCTION, free(), cgraph_node::inlined_to, IPA_REF_ALIAS, symtab_node::iterate_referring(), cgraph_edge::next_caller, postorder_stack::node, NULL, cgraph_node::only_called_directly_p(), postorder_stack::ref, symtab, and cgraph_node::thunk.
Referenced by do_per_function_toporder(), expand_all_functions(), ipa_inline(), ipa_profile(), ipa_write_summaries(), and propagate_malloc().
void ipa_sra_cc_finalize | ( | void | ) |
In ipa-sra.cc
Reset all state within ipa-sra.cc so that we can rerun the compiler within the same process. For use by toplev::finalize.
References call_sums, func_sums, ggc_delete(), and NULL.
Referenced by toplev::finalize().
|
inline |
Return true if we are going to do LTO streaming.
References INCREMENTAL_LINK_LTO, IPA_SSA_AFTER_INLINING, symbol_table::state, and symtab.
Referenced by ipa_icf_gimple::func_checker::compare_operand(), and ipa_icf::sem_function::hash_stmt().
bool odr_based_tbaa_p | ( | const_tree | type | ) |
True if canonical type of TYPE is determined using ODR name.
References get_odr_type(), odr_hash, RECORD_OR_UNION_TYPE_P, and odr_type_d::tbaa_enabled.
Referenced by gimple_canonical_types_compatible_p(), and record_component_aliases().
bool odr_or_derived_type_p | ( | const_tree | t | ) |
Return true if T is either ODR type or compound type based from it. If the function return true, we know that T is a type originating from C++ source even at link-time.
References compound_type_base(), odr_or_derived_type_p(), odr_type_p(), TREE_CHAIN, TREE_CODE, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, TYPE_MAIN_VARIANT, and TYPE_METHOD_BASETYPE.
Referenced by odr_or_derived_type_p(), odr_types_equivalent_p(), and type_mismatch_p().
|
inline |
Return true of T is type with One Definition Rule info attached. It means that either it is anonymous type or it has assembler name set.
References DECL_ASSEMBLER_NAME_SET_P, gcc_checking_assert, TREE_CODE, and TYPE_NAME.
Referenced by can_be_name_hashed_p(), get_alias_set(), gimple_canonical_types_compatible_p(), local_tree_p(), odr_or_derived_type_p(), odr_subtypes_equivalent_p(), record_component_aliases(), ipa_polymorphic_call_context::restrict_to_inner_class(), ipa_polymorphic_call_context::speculation_consistent_p(), types_odr_comparable(), and verify_type_variant().
Return true if we reported some ODR violation on TYPE.
References get_odr_type(), and odr_type_d::odr_violated.
Return true if TYPE1 and TYPE2 are equivalent for One Definition Rule.
References gcc_checking_assert, NULL, odr_or_derived_type_p(), odr_types_equivalent_p(), UNKNOWN_LOCATION, and visited.
Return a FUNCTION_DECL if FN represent a constructor or destructor. If CHECK_CLONES is true, also check for clones of ctor/dtors.
References DECL_ABSTRACT_ORIGIN, DECL_CXX_CONSTRUCTOR_P, DECL_CXX_DESTRUCTOR_P, ECF_CONST, ECF_PURE, flags_from_decl_or_type(), NULL_TREE, TREE_CODE, and TREE_TYPE.
Referenced by inlined_polymorphic_ctor_dtor_block_p(), and remove_unused_locals().
|
inline |
Return true if BINFO corresponds to a type with virtual methods. Every type has several BINFOs. One is the BINFO associated by the type while other represents bases of derived types. The BINFOs representing bases do not have BINFO_VTABLE pointer set when this is the single inheritance (because vtables are shared). Look up the BINFO of type and check presence of its vtable.
References BINFO_TYPE, BINFO_VTABLE, and TYPE_BINFO.
Referenced by add_type_duplicate(), build_type_inheritance_graph(), compare_virtual_tables(), contains_polymorphic_type_p(), decl_maybe_in_construction_p(), get_odr_type(), odr_types_equivalent_p(), possible_placement_new(), record_known_type(), record_target_from_binfo(), record_targets_from_bases(), ipa_polymorphic_call_context::restrict_to_inner_class(), and subbinfo_with_vtable_at_offset().
|
inline |
Return true if N can be possibly target of a polymorphic call of E.
References cgraph_edge::indirect_info, cgraph_indirect_call_info::otr_token, cgraph_indirect_call_info::otr_type, and possible_polymorphic_call_target_p().
bool possible_polymorphic_call_target_p | ( | tree | ref, |
gimple * | stmt, | ||
struct cgraph_node * | n ) |
Return true if N can be possibly target of a polymorphic call of OBJ_TYPE_REF expression REF in STMT.
References current_function_decl, gimple_call_fn(), obj_type_ref_class(), OBJ_TYPE_REF_TOKEN, possible_polymorphic_call_target_p(), and tree_to_uhwi().
Referenced by possible_polymorphic_call_target_p().
bool possible_polymorphic_call_target_p | ( | tree | otr_type, |
HOST_WIDE_INT | otr_token, | ||
const ipa_polymorphic_call_context & | ctx, | ||
struct cgraph_node * | n ) |
Return true if N can be possibly target of a polymorphic call of OTR_TYPE/OTR_TOKEN.
References BUILT_IN_NORMAL, symtab_node::decl, DECL_FUNCTION_CODE(), symtab_node::definition, fndecl_built_in_p(), i, is_cxa_pure_virtual_p(), odr_hash, possible_polymorphic_call_targets(), and symtab_node::semantically_equivalent_p().
Referenced by gimple_fold_call(), ipa_get_indirect_edge_target_1(), ipa_profile(), possible_polymorphic_call_target_p(), and try_make_edge_direct_virtual_call().
|
inline |
Return vector containing possible targets of polymorphic call E. If COMPLETEP is non-NULL, store true if the list is complete. CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry in the target cache. If user needs to visit every target list just once, it can memoize them. Returned vector is placed into cache. It is NOT caller's responsibility to free it. The vector can be freed on cgraph_remove_node call if the particular node is a virtual function present in the cache.
References cgraph_edge::indirect_info, cgraph_indirect_call_info::otr_token, cgraph_indirect_call_info::otr_type, and possible_polymorphic_call_targets().
|
inline |
Same as above but taking OBJ_TYPE_REF as an parameter.
References current_function_decl, obj_type_ref_class(), OBJ_TYPE_REF_TOKEN, possible_polymorphic_call_targets(), and tree_to_uhwi().
vec< cgraph_node * > possible_polymorphic_call_targets | ( | tree | otr_type, |
HOST_WIDE_INT | otr_token, | ||
ipa_polymorphic_call_context | context, | ||
bool * | completep, | ||
void ** | cache_token, | ||
bool | speculative ) |
Return vector containing possible targets of polymorphic call of type OTR_TYPE calling method OTR_TOKEN within type of OTR_OUTER_TYPE and OFFSET. If INCLUDE_BASES is true, walk also base types of OUTER_TYPES containing OTR_TYPE and include their virtual method. This is useful for types possibly in construction or destruction where the virtual table may temporarily change to one of base types. INCLUDE_DERIVED_TYPES make us to walk the inheritance graph for all derivations. If COMPLETEP is non-NULL, store true if the list is complete. CACHE_TOKEN (if non-NULL) will get stored to an unique ID of entry in the target cache. If user needs to visit every target list just once, it can memoize them. If SPECULATIVE is set, the list will not contain targets that are not speculatively taken. Returned vector is placed into cache. It is NOT caller's responsibility to free it. The vector can be freed on cgraph_remove_node call if the particular node is a virtual function present in the cache.
References hash_set< KeyId, Lazy, Traits >::add(), symbol_table::add_cgraph_removal_hook(), symbol_table::add_varpool_removal_hook(), odr_type_d::all_derivations_known, BINFO_VTABLE, cached_polymorphic_call_targets, ipa_polymorphic_call_context::clear_outer_type(), ipa_polymorphic_call_context::clear_speculation(), polymorphic_call_target_d::context, decl_warn_count::count, decl_warn_count::decl, DECL_CONTEXT, DECL_CXX_DESTRUCTOR_P, DECL_FINAL_P, final_warning_record::decl_warnings, odr_type_d::derived_types, devirt_node_removal_hook(), devirt_variable_node_removal_hook(), decl_warn_count::dyn_count, final_warning_record::dyn_count, final_warning_records, hash_table< Descriptor, Lazy, Allocator >::find_slot(), gcc_assert, hash_map< KeyId, Value, Traits >::get(), get_binfo_at_offset(), get_odr_type(), hash_map< KeyId, Value, Traits >::get_or_insert(), gimple_get_virt_method_for_binfo(), final_warning_record::grow_type_warnings(), i, odr_type_d::id, ipa_polymorphic_call_context::invalid, ipa_polymorphic_call_context::maybe_derived_type, ipa_polymorphic_call_context::maybe_in_construction, maybe_record_node(), MIN, polymorphic_call_target_d::n_odr_types, NULL, odr_hash, odr_types, odr_violation_reported, ipa_polymorphic_call_context::offset, polymorphic_call_target_d::otr_token, ipa_polymorphic_call_context::outer_type, polymorphic_call_target_hash, possible_polymorphic_call_targets_1(), record_targets_from_bases(), ipa_polymorphic_call_context::restrict_to_inner_class(), polymorphic_call_target_d::speculative, ipa_polymorphic_call_context::speculative_maybe_derived_type, ipa_polymorphic_call_context::speculative_offset, ipa_polymorphic_call_context::speculative_outer_type, symtab, timevar_pop(), timevar_push(), TREE_CODE, TREE_TYPE, odr_type_d::type, polymorphic_call_target_d::type, type(), type_all_derivations_known_p(), TYPE_BINFO, TYPE_FINAL_P, TYPE_MAIN_VARIANT, type_or_derived_type_possibly_instantiated_p(), type_possibly_instantiated_p(), final_warning_record::type_warnings, types_same_for_odr(), vNULL, and profile_count::zero().
Referenced by compute_ltrans_boundary(), dump_possible_polymorphic_call_targets(), eliminate_dom_walker::eliminate_stmt(), fold_gimple_assign(), gimple_fold_call(), ipa_devirt(), ipa_get_indirect_edge_target_1(), possible_polymorphic_call_target_p(), possible_polymorphic_call_targets(), possible_polymorphic_call_targets(), try_make_edge_direct_virtual_call(), try_speculative_devirtualization(), walk_polymorphic_call_targets(), and walk_polymorphic_call_targets().
Return type that in ODR type hash prevailed TYPE. Be careful and punt on ODR violations.
References get_odr_type(), odr_type_d::odr_violated, odr_type_d::type, and type().
Referenced by get_alias_set().
void rebuild_type_inheritance_graph | ( | void | ) |
Force rebuilding type inheritance graph from scratch. This is use to make sure that we do not keep references to types which was not visible to free_lang_data.
References free_polymorphic_call_targets_hash(), NULL, odr_hash, and odr_types_ptr.
Return true if call to DEST is known to be self-recusive call withing FUNC.
References symtab_node::alias, AVAIL_AVAILABLE, FOR_EACH_ALIAS, gcc_assert, cgraph_node::get_create(), symtab_node::semantically_equivalent_p(), and cgraph_node::ultimate_alias_target().
Referenced by check_call(), estimate_bb_frequencies(), find_tail_calls(), predict_loops(), and tree_bb_level_predictions().
void register_odr_enum | ( | tree | t | ) |
Register ODR enum so we later stream record about its values.
References odr_enums, and vec_safe_push().
void register_odr_type | ( | tree | type | ) |
Add TYPE of ODR type hash.
References BINFO_BASE_BINFO, BINFO_N_BASE_BINFOS, BINFO_TYPE, COMPLETE_TYPE_P, hash_set< KeyId, Lazy, Traits >::contains(), get_odr_type(), i, odr_hash, RECORD_OR_UNION_TYPE_P, register_odr_type(), TREE_CHAIN, TREE_CODE, TREE_TYPE, odr_type_d::type, TYPE_BINFO, TYPE_FIELDS, TYPE_MAIN_VARIANT, type_with_linkage_p(), and odr_type_d::types_set.
Referenced by register_odr_type().
Set TYPE_CANONICAL of type and all its variants and duplicates to CANONICAL.
References FOR_EACH_VEC_ELT, get_odr_type(), i, odr_type_d::type, TYPE_CANONICAL, TYPE_NEXT_VARIANT, and odr_type_d::types.
Return true if stmt may terminate execution of function. If assume_return_or_eh we can further assume that the function ends either by retrn statement or EH (no trapping or infinite loops).
References dyn_cast(), ECF_CONST, ECF_LOOPING_CONST_OR_PURE, ECF_PURE, get_modref_function_summary(), gimple_asm_volatile_p(), gimple_call_flags(), gimple_could_trap_p(), NULL, modref_summary::side_effects, and stmt_can_throw_external().
Referenced by find_always_executed_bbs().
Look up base of BINFO that has virtual table VTABLE with OFFSET.
References BINFO_BASE_ITERATE, BINFO_VTABLE, DECL_ASSEMBLER_NAME, gcc_unreachable, i, NULL, offset, polymorphic_type_binfo_p(), subbinfo_with_vtable_at_offset(), and vtable_pointer_value_to_vtable().
Referenced by extr_type_from_vtbl_ptr_store(), subbinfo_with_vtable_at_offset(), and vtable_pointer_value_to_binfo().
cgraph_node * try_speculative_devirtualization | ( | tree | otr_type, |
HOST_WIDE_INT | otr_token, | ||
ipa_polymorphic_call_context | ctx ) |
Try to speculatively devirtualize call to OTR_TYPE with OTR_TOKEN with context CTX.
References AVAIL_INTERPOSABLE, symtab_node::can_be_discarded_p(), symtab_node::decl, DECL_ARTIFICIAL, DECL_EXTERNAL, symtab_node::definition, cgraph_node::function_symbol(), cgraph_node::get_availability(), i, likely_target_p(), NULL, and possible_polymorphic_call_targets().
Referenced by ipa_get_indirect_edge_target_1(), and try_make_edge_direct_virtual_call().
bool type_all_derivations_known_p | ( | const_tree | t | ) |
Return TRUE if all derived types of T are known and thus we may consider the walk of derived type complete. This is typically true only for final anonymous namespace types and types defined within functions (that may be COMDAT and thus shared across units, but with the same set of derived types).
References decl_function_context(), NULL, TREE_CODE, TYPE_FINAL_P, type_in_anonymous_namespace_p(), and TYPE_NAME.
Referenced by get_odr_type(), possible_polymorphic_call_targets(), possible_polymorphic_call_targets_1(), and type_known_to_have_no_derivations_p().
|
inline |
Return true if T is in anonymous namespace. This works only on those C++ types with linkage defined.
References DECL_ASSEMBLER_NAME, DECL_ASSEMBLER_NAME_SET_P, gcc_checking_assert, IDENTIFIER_POINTER, TREE_PUBLIC, TYPE_NAME, TYPE_STUB_DECL, and type_with_linkage_p().
Referenced by devirt_variable_node_removal_hook(), odr_name_hasher::equal(), get_odr_type(), hash_odr_name(), local_tree_p(), maybe_record_node(), odr_subtypes_equivalent_p(), odr_types_equivalent_p(), type_all_ctors_visible_p(), type_all_derivations_known_p(), types_same_for_odr(), ipa_icf::sem_item_optimizer::update_hash_by_addr_refs(), walk_polymorphic_call_targets(), walk_polymorphic_call_targets(), and warn_types_mismatch().
Return true if type is known to have no derivations.
References get_odr_type(), odr_hash, type_all_derivations_known_p(), and TYPE_FINAL_P.
Referenced by ipa_polymorphic_call_context::restrict_to_inner_class().
|
inline |
Return true if T is a type with linkage defined.
References DECL_ASSEMBLER_NAME_SET_P, gcc_checking_assert, RECORD_OR_UNION_TYPE_P, TREE_CODE, TYPE_CONTEXT, TYPE_MAIN_VARIANT, and TYPE_NAME.
Referenced by odr_name_hasher::equal(), get_odr_type(), hash_odr_name(), local_tree_p(), need_assembler_name_p(), odr_subtypes_equivalent_p(), odr_types_equivalent_p(), register_odr_type(), ipa_polymorphic_call_context::restrict_to_inner_class(), type_in_anonymous_namespace_p(), types_same_for_odr(), and warn_types_mismatch().
Return true if T1 and T2 are ODR equivalent. If ODR equivalency is not known, be conservative and return false.
References TYPE_MAIN_VARIANT, types_odr_comparable(), and types_same_for_odr().
Referenced by ipa_polymorphic_call_context::combine_speculation_with(), ipa_polymorphic_call_context::combine_with(), ipa_icf::sem_item::compare_referenced_symbol_properties(), ipa_icf_gimple::func_checker::compatible_polymorphic_types_p(), ipa_polymorphic_call_context::meet_speculation_with(), ipa_polymorphic_call_context::meet_with(), ipa_polymorphic_call_context::restrict_to_inner_class(), and ipa_polymorphic_call_context::speculation_consistent_p().
Return true if we can decide on ODR equivalency. In non-LTO it is always decide, in LTO however it depends in the type has ODR info attached.
References odr_type_p(), and TYPE_MAIN_VARIANT.
Referenced by add_type_duplicate(), ipa_polymorphic_call_context::combine_with(), decl_maybe_in_construction_p(), ipa_polymorphic_call_context::equal_to(), odr_subtypes_equivalent_p(), ipa_polymorphic_call_context::restrict_to_inner_class(), types_must_be_same_for_odr(), and warn_types_mismatch().
void update_type_inheritance_graph | ( | void | ) |
After callgraph construction new external nodes may appear. Add them into the graph.
References symtab_node::decl, DECL_VIRTUAL_P, symtab_node::definition, FOR_EACH_FUNCTION, free_polymorphic_call_targets_hash(), get_odr_type(), odr_hash, symtab_node::real_symbol_p(), timevar_pop(), timevar_push(), TREE_TYPE, and TYPE_METHOD_BASETYPE.
Referenced by analyze_functions().
tree vtable_pointer_value_to_binfo | ( | const_tree | t | ) |
T is known constant value of virtual table pointer. Return BINFO of the instance type.
References DECL_CONTEXT, NULL_TREE, offset, subbinfo_with_vtable_at_offset(), TYPE_BINFO, and vtable_pointer_value_to_vtable().
bool vtable_pointer_value_to_vtable | ( | const_tree | t, |
tree * | v, | ||
unsigned HOST_WIDE_INT * | offset ) |
T is known constant value of virtual table pointer. Store virtual table to V and its offset to OFFSET. Return false if T does not look like virtual table reference.
References DECL_VIRTUAL_P, offset, TREE_CODE, TREE_OPERAND, and tree_to_uhwi().
Referenced by extr_type_from_vtbl_ptr_store(), gimple_get_virt_method_for_binfo(), ipa_get_indirect_edge_target_1(), subbinfo_with_vtable_at_offset(), try_make_edge_direct_virtual_call(), and vtable_pointer_value_to_binfo().
void warn_function_returns_nonnull | ( | tree | decl | ) |
References suggest_attribute().
Referenced by execute_ranger_vrp().
Types T1 and T2 was found to be incompatible in a context they can't (either used to declare a symbol of same assembler name or unified by ODR rule). We already output warning about this, but if possible, output extra information on how the types mismatch. This is hard to do in general. We basically handle the common cases. If LOC1 and LOC2 are meaningful locations, use it in the case the types themselves do not have one.
References BUILTINS_LOCATION, COMPLETE_TYPE_P, count, DECL_NAME, DECL_SOURCE_LOCATION, expand_location(), free(), gcc_assert, get_odr_name_for_type(), i1, i2, inform(), NULL, operand_equal_p(), POINTER_TYPE_P, prototype_p(), TREE_CHAIN, TREE_CODE, TREE_TYPE, TREE_VALUE, TYPE_ARG_TYPES, TYPE_DOMAIN, type_in_anonymous_namespace_p(), TYPE_MAIN_VARIANT, TYPE_MAX_VALUE, type_mismatch_p(), TYPE_NAME, type_with_linkage_p(), types_odr_comparable(), types_same_for_odr(), UNKNOWN_LOCATION, and warn_types_mismatch().
Referenced by add_type_duplicate(), odr_types_equivalent_p(), and warn_types_mismatch().
|
extern |
HACK alert: this is used to communicate with ipa-inline-transform that thunk is being expanded and there is no need to clear the polymorphic call target cache.
Referenced by devirt_node_removal_hook(), and inline_call().