GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "target.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "alloc-pool.h"
#include "gimple-ssa.h"
#include "cgraph.h"
#include "lto-streamer.h"
#include "fold-const.h"
#include "varasm.h"
#include "calls.h"
#include "print-tree.h"
#include "langhooks.h"
#include "intl.h"
#include "tree-eh.h"
#include "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-ssa.h"
#include "value-prof.h"
#include "ipa-utils.h"
#include "symbol-summary.h"
#include "tree-vrp.h"
#include "sreal.h"
#include "ipa-cp.h"
#include "ipa-prop.h"
#include "ipa-fnsummary.h"
#include "cfgloop.h"
#include "gimple-pretty-print.h"
#include "tree-dfa.h"
#include "profile.h"
#include "context.h"
#include "gimplify.h"
#include "stringpool.h"
#include "attribs.h"
#include "selftest.h"
#include "tree-into-ssa.h"
#include "ipa-inline.h"
#include "tree-nested.h"
#include "symtab-thunks.h"
#include "symtab-clones.h"
#include "tree-pass.h"
#include "cif-code.def"
#include "gt-cgraph.h"
Data Structures | |
struct | cgraph_edge_hook_list |
struct | cgraph_node_hook_list |
struct | cgraph_2edge_hook_list |
struct | cgraph_2node_hook_list |
struct | function_version_hasher |
struct | set_pure_flag_info |
Macros | |
#define | cgraph_nodes_queue ((cgraph_node *)x_cgraph_nodes_queue) |
#define | DEFCIFCODE(code, type, string) |
#define | DEFCIFCODE(code, type, string) |
Variables | |
symtab_node * | x_cgraph_nodes_queue |
symbol_table * | symtab |
static hash_table< function_version_hasher > * | cgraph_fnver_htab = NULL |
static struct cgraph_function_version_info * | version_info_node = NULL |
const char *const | cgraph_availability_names [] |
symbol_table * | saved_symtab |
#define cgraph_nodes_queue ((cgraph_node *)x_cgraph_nodes_queue) |
#define DEFCIFCODE | ( | code, | |
type, | |||
string ) |
#define DEFCIFCODE | ( | code, | |
type, | |||
string ) |
|
static |
Worker to set malloc flag.
References add_detected_attribute_1(), AVAIL_INTERPOSABLE, cgraph_node::callers, changed, symtab_node::decl, DECL_ATTRIBUTES, dyn_cast(), FOR_EACH_ALIAS, cgraph_node::get_availability(), get_identifier(), lookup_attribute(), cgraph_edge::next_caller, NULL_TREE, ipa_ref::referring, and tree_cons().
Referenced by cgraph_node::add_detected_attribute(), and add_detected_attribute_1().
|
inlinestatic |
Add call graph edge E to call site hash of its caller.
References cgraph_node::call_site_hash, cgraph_edge::call_stmt, cgraph_edge::callee, cgraph_edge::caller, hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), gcc_assert, cgraph_edge_hasher::hash(), cgraph_edge::indirect_unknown_callee, cgraph_edge::prev_callee, and cgraph_edge::speculative.
Referenced by symbol_table::create_edge(), cgraph_node::get_edge(), and cgraph_edge::set_call_stmt().
cgraph_indirect_call_info * cgraph_allocate_init_indirect_info | ( | void | ) |
Allocate cgraph_indirect_call_info and set its fields to default values.
References ggc_cleared_alloc(), and cgraph_indirect_call_info::param_index.
Referenced by cgraph_node::create_indirect_edge().
void cgraph_cc_finalize | ( | void | ) |
Reset all state within cgraph.cc so that we can rerun the compiler within the same process. For use by toplev::finalize.
References cgraph_fnver_htab, NULL, clone_info::release(), nested_function_info::release(), thunk_info::release(), symtab, version_info_node, and x_cgraph_nodes_queue.
Referenced by toplev::finalize().
Switch to THIS_CFUN if needed and print STMT to stderr.
References cfun, current_function_decl, debug_gimple_stmt(), function::decl, NULL, and set_cfun().
Referenced by cgraph_node::verify_node().
Return true when the DECL can possibly be inlined.
References DECL_POSSIBLY_INLINED, DECL_UNINLINABLE, symbol_table::global_info_ready, and symtab.
Referenced by premark_types_used_by_global_vars_helper().
const char * cgraph_inline_failed_string | ( | cgraph_inline_failed_t | reason | ) |
Return a string describing the failure REASON.
This file contains the definitions of the cgraph_inline_failed_t enums used in GCC. Copyright (C) 2008-2024 Free Software Foundation, Inc. Contributed by Doug Kwan <dougkwan@google.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/>.
The format of this file is DEFCIFCODE(code, string). Where symbol is the enumeration name without the ``''. The argument STRING is a explain the failure. Except for OK, which is a NULL pointer.
Inlining successful. This must be the first code.
Inlining failed for an unspecified reason.
Function has not be considered for inlining. This is the code for functions that have not been rejected for inlining yet.
Caller is compiled with optimizations disabled.
Inlining failed owing to unavailable function body.
Extern inline function that has been redefined.
Function is not inlinable.
Function is overwritable.
Function is not an inlining candidate.
Inlining failed because of various limit parameters.
Recursive inlining.
Call is unlikely.
Call is considered never executed.
Function is not declared as inline.
Caller and callee disagree on the arguments.
Caller is variadic thunk.
Call was originally indirect.
Ths edge represents an indirect edge with a yet-undetermined callee .
We can't inline different EH personalities together.
We can't inline if the callee can throw non-call exceptions but the caller cannot.
We can't inline because of mismatched target specific options.
We can't inline because of mismatched optimization levels.
We can't inline because the callee refers to comdat-local symbols.
We can't inline because of mismatched caller/callee sanitizer attributes.
We can't inline because the user requests only static functions but the function has external linkage for live patching purpose.
We proved that the call is unreachable.
References gcc_assert.
Referenced by dump_inline_stats(), dump_ipa_call_summary(), expand_call_inline(), and report_inline_failed_reason().
cgraph_inline_failed_type_t cgraph_inline_failed_type | ( | cgraph_inline_failed_t | reason | ) |
Return a type describing the failure REASON.
This file contains the definitions of the cgraph_inline_failed_t enums used in GCC. Copyright (C) 2008-2024 Free Software Foundation, Inc. Contributed by Doug Kwan <dougkwan@google.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/>.
The format of this file is DEFCIFCODE(code, string). Where symbol is the enumeration name without the ``''. The argument STRING is a explain the failure. Except for OK, which is a NULL pointer.
Inlining successful. This must be the first code.
Inlining failed for an unspecified reason.
Function has not be considered for inlining. This is the code for functions that have not been rejected for inlining yet.
Caller is compiled with optimizations disabled.
Inlining failed owing to unavailable function body.
Extern inline function that has been redefined.
Function is not inlinable.
Function is overwritable.
Function is not an inlining candidate.
Inlining failed because of various limit parameters.
Recursive inlining.
Call is unlikely.
Call is considered never executed.
Function is not declared as inline.
Caller and callee disagree on the arguments.
Caller is variadic thunk.
Call was originally indirect.
Ths edge represents an indirect edge with a yet-undetermined callee .
We can't inline different EH personalities together.
We can't inline if the callee can throw non-call exceptions but the caller cannot.
We can't inline because of mismatched target specific options.
We can't inline because of mismatched optimization levels.
We can't inline because the callee refers to comdat-local symbols.
We can't inline because of mismatched caller/callee sanitizer attributes.
We can't inline because the user requests only static functions but the function has external linkage for live patching purpose.
We proved that the call is unreachable.
References gcc_assert.
Referenced by can_early_inline_edge_p(), can_inline_edge_by_limits_p(), can_inline_edge_p(), check_callers(), do_estimate_growth_1(), expand_call_inline(), flatten_function(), growth_positive_p(), initialize_inline_failed(), and want_inline_small_function_p().
|
static |
Worker for cgraph_node_can_be_local_p.
References symtab_node::decl, DECL_COMDAT, DECL_STATIC_CONSTRUCTOR, DECL_STATIC_DESTRUCTOR, symtab_node::externally_visible, symtab_node::force_output, symtab_node::forced_by_abi, symtab_node::ifunc_resolver, symtab_node::same_comdat_group, symtab_node::symver, and symtab_node::used_from_object_file_p().
Referenced by cgraph_node::can_be_local_p().
|
static |
Worker for cgraph_only_called_directly_p.
References cgraph_node::only_called_directly_or_aliased_p().
Referenced by cgraph_node::only_called_directly_p().
|
inlinestatic |
Add call graph edge E to call site hash of its caller.
References cgraph_node::call_site_hash, cgraph_edge::call_stmt, cgraph_edge::caller, hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), and cgraph_edge_hasher::hash().
Referenced by update_call_stmt_hash_for_removing_direct_edge().
Update or remove the corresponding cgraph edge if a GIMPLE_CALL OLD_STMT changed into NEW_STMT. OLD_DECL is gimple_call_fndecl of OLD_STMT before it was updated (updating can happen inplace).
References cfun, cgraph_update_edges_for_call_stmt_node(), cgraph_node::clone_of, cgraph_node::clones, gcc_checking_assert, cgraph_node::get(), and cgraph_node::next_sibling_clone.
Referenced by fold_marked_statements().
|
static |
Update or remove the corresponding cgraph edge if a GIMPLE_CALL OLD_STMT changed into NEW_STMT. OLD_CALL is gimple_call_fndecl of OLD_STMT if it was previously call statement. If NEW_STMT is NULL, the call has been dropped without any replacement.
References as_a(), cgraph_edge::callee, cgraph_node::clone_of, basic_block_def::count, cgraph_edge::count, count, cgraph_node::create_edge(), symtab_node::decl, fndecl_built_in_p(), cgraph_node::former_clone_of, gcc_assert, cgraph_node::get_create(), cgraph_node::get_edge(), gimple_bb(), gimple_call_fndecl(), cgraph_edge::indirect_unknown_callee, cgraph_edge::inline_failed, is_gimple_call(), NULL, cgraph_edge::remove(), cgraph_node::remove_symbol_and_inline_clones(), and cgraph_edge::set_call_stmt().
Referenced by cgraph_update_edges_for_call_stmt().
|
static |
Return TRUE if NODE2 a clone of NODE or is equivalent to it. Return optimistically true if this cannot be determined.
References cgraph_edge::callee, cgraph_node::callees, cgraph_node::clone_of, symtab_node::decl, ipa_param_adjustments::first_param_intact_p(), cgraph_node::former_clone_of, cgraph_node::former_thunk_p(), clone_info::get(), thunk_info::get(), cgraph_edge::next_callee, NULL, clone_info::param_adjustments, cgraph_node::thunk, and cgraph_node::ultimate_alias_target().
Referenced by cgraph_edge::verify_corresponds_to_fndecl().
|
static |
Collect all callers of NODE. Worker for collect_callers_of_node.
References AVAIL_INTERPOSABLE, cgraph_edge::caller, cgraph_node::callers, cgraph_edge::indirect_inlining_edge, cgraph_edge::next_caller, NULL, cgraph_node::thunk, and cgraph_node::ultimate_alias_target().
Referenced by cgraph_node::collect_callers().
|
static |
Remove the cgraph_function_version_info node given by DECL_V.
References cgraph_fnver_htab, cgraph_function_version_info::next, NULL, cgraph_function_version_info::prev, and version_info_node.
Referenced by cgraph_node::delete_function_version_by_decl(), and cgraph_node::remove().
|
static |
Worker for cgraph_can_remove_if_no_direct_calls_p.
References cgraph_node::can_remove_if_no_direct_calls_and_refs_p().
Referenced by cgraph_node::can_remove_if_no_direct_calls_p().
void release_function_body | ( | tree | decl | ) |
Helper function for cgraph_release_function_body and free_lang_data. It releases body from function DECL without having to inspect its possibly non-existent symtab node.
References CDI_DOMINATORS, CDI_POST_DOMINATORS, function::cfg, function::curr_properties, DECL_SAVED_TREE, DECL_STRUCT_FUNCTION, delete_tree_cfg_annotations(), delete_tree_ssa(), dom_info_available_p(), function::eh, free_cfg(), free_histograms(), gcc_assert, ggc_free(), function::gimple_df, gimple_set_body(), loop_optimizer_finalize(), loops_for_fn(), NULL, and function::value_histograms.
Referenced by cgraph_node::release_body().
|
static |
Worker to set_const_flag.
References AVAIL_INTERPOSABLE, symtab_node::binds_to_current_def_p(), cgraph_node::callers, changed, symtab_node::decl, DECL_LOOPING_CONST_OR_PURE_P, DECL_PURE_P, DECL_STATIC_CONSTRUCTOR, DECL_STATIC_DESTRUCTOR, dump_file, dump_flags, dyn_cast(), FOR_EACH_ALIAS, thunk_info::get(), cgraph_node::get_availability(), cgraph_edge::next_caller, cgraph_simd_clone::next_clone, NULL, ipa_ref::referring, set_const_flag_1(), cgraph_node::simd_clones, cgraph_node::simdclone, TDF_DETAILS, TREE_READONLY, and thunk_info::virtual_offset_p.
Referenced by cgraph_node::set_const_flag(), and set_const_flag_1().
|
static |
Worker to set malloc flag.
References AVAIL_INTERPOSABLE, cgraph_node::callers, changed, symtab_node::decl, DECL_IS_MALLOC, dyn_cast(), FOR_EACH_ALIAS, cgraph_node::get_availability(), cgraph_edge::next_caller, ipa_ref::referring, and set_malloc_flag_1().
Referenced by cgraph_node::set_malloc_flag(), and set_malloc_flag_1().
|
static |
Worker to set noreturng flag.
References AVAIL_INTERPOSABLE, cgraph_node::callers, changed, symtab_node::decl, dyn_cast(), FOR_EACH_ALIAS, cgraph_node::get_availability(), cgraph_edge::next_caller, ipa_ref::referring, set_noreturn_flag_1(), and TREE_THIS_VOLATILE.
Referenced by cgraph_node::set_noreturn_flag(), and set_noreturn_flag_1().
|
static |
Worker to set nothrow flag.
References AVAIL_INTERPOSABLE, symtab_node::binds_to_current_def_p(), cgraph_edge::caller, cgraph_node::callers, cgraph_edge::can_throw_external, changed, symtab_node::decl, dyn_cast(), FOR_EACH_ALIAS, cgraph_node::get_availability(), cgraph_edge::next_caller, ipa_ref::referring, set_nothrow_flag_1(), cgraph_node::thunk, and TREE_NOTHROW.
Referenced by cgraph_node::set_nothrow_flag(), and set_nothrow_flag_1().
|
static |
Worker to set_pure_flag.
References set_pure_flag_info::changed, symtab_node::decl, DECL_LOOPING_CONST_OR_PURE_P, DECL_PURE_P, DECL_STATIC_CONSTRUCTOR, DECL_STATIC_DESTRUCTOR, set_pure_flag_info::looping, set_pure_flag_info::pure, and TREE_READONLY.
Referenced by cgraph_node::set_pure_flag().
|
static |
We always maintain first direct edge in the call site hash, if one exists. E is going to be removed. See if it is first one and update hash accordingly. INDIRECT is the indirect edge of speculative call. We assume that INDIRECT->num_speculative_call_targets_p () is already updated for removal of E.
References cgraph_node::call_site_hash, cgraph_edge::call_stmt, cgraph_edge::caller, cgraph_update_edge_in_call_site_hash(), gcc_checking_assert, cgraph_node::get_edge(), cgraph_edge::next_callee, cgraph_edge::num_speculative_call_targets_p(), and cgraph_edge::speculative.
Referenced by cgraph_edge::redirect_call_stmt_to_callee(), and cgraph_edge::resolve_speculation().
|
static |
Disable warnings about missing quoting in GCC diagnostics for the verification errors. Their format strings don't follow GCC diagnostic conventions and the calls are ultimately followed by one to internal_error.
Verify consistency of speculative call in NODE corresponding to STMT and LTO_STMT_UID. If INDIRECT is set, assume that it is the indirect edge of call sequence. Return true if error is found. This function is called to every component of indirect call (direct edges, indirect edge and refs). To save duplicated work, do full testing only in that case.
References cgraph_edge::call_stmt, cgraph_node::callees, symtab_node::dump_name(), error(), cgraph_node::get_edge(), i, cgraph_node::indirect_calls, symtab_node::iterate_reference(), cgraph_edge::lto_stmt_uid, ipa_ref::lto_stmt_uid, cgraph_edge::next_callee, NULL, cgraph_edge::num_speculative_call_targets_p(), ipa_ref::referred, refs, cgraph_edge::speculative, ipa_ref::speculative, ipa_ref::speculative_id, and ipa_ref::stmt.
Referenced by cgraph_node::verify_node().
const char* const cgraph_availability_names[] |
Names used to print out the availability enum.
Referenced by cgraph_node::dump(), and varpool_node::dump().
|
static |
Map a cgraph_node to cgraph_function_version_info using this htab. The cgraph_function_version_info has a THIS_NODE field that is the corresponding cgraph_node..
Referenced by cgraph_cc_finalize(), delete_function_version(), cgraph_node::function_version(), and cgraph_node::insert_new_function_version().
symbol_table* saved_symtab |
A stashed copy of "symtab" for use by selftest::symbol_table_test. This needs to be a global so that it can be a GC root, and thus prevent the stashed copy from being garbage-collected if the GC runs during a symbol_table_test.
symbol_table* symtab |
Symbol table global context.
Referenced by varpool_node::add(), cgraph_node::add_new_function(), add_type_duplicate(), varpool_node::analyze(), analyze_functions(), assemble_alias(), autofdo::auto_profile(), symtab_node::binds_to_current_def_p(), build_toporder_info(), can_refer_decl_in_current_unit_p(), cgraph_cc_finalize(), cgraph_function_possibly_inlined_p(), cgraph_edge::clone(), symbol_table::compile(), compile_file(), coverage_obj_init(), cgraph_node::create(), cgraph_node::create_clone(), create_dispatcher_calls(), cgraph_node::create_edge(), symbol_table::create_edge(), varpool_node::create_extra_name_alias(), ipa_fn_summary_t::create_ggc(), ipcp_transformation_t::create_ggc(), modref_summaries::create_ggc(), modref_summaries_lto::create_ggc(), cgraph_node::create_indirect_edge(), cgraph_node::create_same_body_alias(), create_target_clone(), cgraph_node::create_thunk(), cgraph_node::create_version_clone_with_body(), cgraph_node::create_virtual_clone(), default_asm_output_ident_directive(), do_compile(), do_per_function_toporder(), cgraph_node::dump(), varpool_node::dump(), dump_callgraph_transformation(), dump_possible_polymorphic_call_targets(), duplicate_thunk_for_node(), emergency_dump_function(), ipa_icf::sem_item_optimizer::execute(), execute_build_ssa_passes(), execute_ipa_pass_list(), execute_one_pass(), execute_todo(), cgraph_node::expand(), expand_all_functions(), expand_call_inline(), expand_simd_clones(), varpool_node::finalize_decl(), cgraph_node::finalize_function(), function_and_variable_visibility(), general_init(), clone_info::get(), thunk_info::get(), cgraph_node::get_create(), clone_info::get_create(), nested_function_info::get_create(), thunk_info::get_create(), cgraph_node::get_fini_priority(), symtab_node::get_for_asmname(), symtab_node::get_init_priority(), gimple_fold_builtin_acc_on_device(), gimple_fold_builtin_omp_is_initial_device(), initialize_growth_caches(), inline_call(), inline_small_functions(), input_cgraph_1(), input_node(), input_varpool_node(), ipa_check_create_edge_args(), ipa_check_create_node_params(), ipa_fn_summary_alloc(), ipa_init(), ipa_inline(), ipa_merge_profiles(), ipa_passes(), ipa_profile(), ipa_profile_generate_summary(), ipa_profile_read_summary(), ipa_prop_cc_finalize(), ipa_pta_execute(), ipa_record_return_value_range(), ipa_reduced_postorder(), ipa_reference_cc_finalize(), ipa_reference_read_optimization_summary(), ipa_register_cgraph_hooks(), ipa_reverse_postorder(), ipa_strub_set_mode_for_new_functions(), ipa_tm_create_version(), ipa_unregister_cgraph_hooks(), ipa_write_summaries(), ipcp_driver(), ipcp_propagate_stage(), ipcp_transformation_initialize(), ipcp_verify_propagated_values(), lto_input_toplevel_asms(), lto_output_toplevel_asms(), lto_streaming_expected_p(), symtab_node::make_decl_local(), cgraph_edge::make_speculative(), cgraph_node::materialize_clone(), maybe_record_nested_function(), ipa_icf::sem_function::merge(), ipa_param_adjustments::modify_call(), omp_context_selector_matches(), omp_maybe_offloaded(), omp_resolve_declare_variant(), optimize_dyn_tls_for_decl_p(), optimize_weakref(), output_in_order(), possible_inline_candidate_p(), possible_polymorphic_call_targets(), preserve_function_body_p(), symtab_node::priority_info(), process_function_and_variable_attributes(), process_references(), propagate(), propagate_malloc(), propagate_nothrow(), propagate_pure_const(), record_argument_state(), recursive_inlining(), cgraph_edge::redirect_call_stmt_to_callee(), reference_to_unused(), referenced_from_vtable_p(), ipa_icf::sem_item_optimizer::register_hooks(), symtab_node::register_symbol(), clone_info::release(), thunk_info::release(), cgraph_node::release_body(), release_section_hash_entry(), cgraph_edge::remove(), cgraph_node::remove(), clone_info::remove(), thunk_info::remove(), varpool_node::remove(), cgraph_node::remove_callees(), cgraph_node::remove_callers(), varpool_node::remove_initializer(), symbol_table::remove_unreachable_nodes(), symtab_node::resolve_alias(), save_inline_function_body(), symtab_node::set_section_for_node(), set_user_assembler_name(), tree_profiling(), type_all_ctors_visible_p(), symtab_node::unregister(), ipa_icf::sem_item_optimizer::unregister_hooks(), symtab_node::verify_base(), cgraph_edge::verify_corresponds_to_fndecl(), cgraph_node::verify_node(), symtab_node::verify_symtab_nodes(), walk_polymorphic_call_targets(), walk_polymorphic_call_targets(), and wrapup_global_declaration_2().
|
static |
Mark as GC root all allocated nodes.
Referenced by cgraph_cc_finalize(), delete_function_version(), and cgraph_node::insert_new_function_version().
symtab_node* x_cgraph_nodes_queue |
Callgraph handling code. Copyright (C) 2003-2024 Free Software Foundation, Inc. Contributed by Jan Hubicka 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/>.
This file contains basic routines manipulating call graph The call-graph is a data structure designed for inter-procedural optimization. It represents a multi-graph where nodes are functions (symbols within symbol table) and edges are call sites.
FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this.
Queue of cgraph nodes scheduled to be lowered.
Referenced by cgraph_cc_finalize().