GCC Middle and Back End API Reference
cgraph.cc File 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"
Include dependency graph for cgraph.cc:

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)   string,
 
#define DEFCIFCODE(code, type, string)   type,
 

Functions

static void delete_function_version (cgraph_function_version_info *decl_v)
 
static void cgraph_update_edge_in_call_site_hash (cgraph_edge *e)
 
static void cgraph_add_edge_to_call_site_hash (cgraph_edge *e)
 
cgraph_indirect_call_infocgraph_allocate_init_indirect_info (void)
 
static void update_call_stmt_hash_for_removing_direct_edge (cgraph_edge *e, cgraph_edge *indirect)
 
static void cgraph_update_edges_for_call_stmt_node (cgraph_node *node, gimple *old_stmt, tree old_call, gimple *new_stmt)
 
void cgraph_update_edges_for_call_stmt (gimple *old_stmt, tree old_decl, gimple *new_stmt)
 
void release_function_body (tree decl)
 
const charcgraph_inline_failed_string (cgraph_inline_failed_t reason)
 
cgraph_inline_failed_type_t cgraph_inline_failed_type (cgraph_inline_failed_t reason)
 
bool cgraph_function_possibly_inlined_p (tree decl)
 
static bool cgraph_node_cannot_be_local_p_1 (cgraph_node *node, void *)
 
static void set_nothrow_flag_1 (cgraph_node *node, bool nothrow, bool non_call, bool *changed)
 
static void set_malloc_flag_1 (cgraph_node *node, bool malloc_p, bool *changed)
 
static void add_detected_attribute_1 (cgraph_node *node, const char *attr, bool *changed)
 
static void set_noreturn_flag_1 (cgraph_node *node, bool noreturn_p, bool *changed)
 
static void set_const_flag_1 (cgraph_node *node, bool set_const, bool looping, bool *changed)
 
static bool set_pure_flag_1 (cgraph_node *node, void *data)
 
static bool nonremovable_p (cgraph_node *node, void *)
 
static bool cgraph_not_only_called_directly_p_1 (cgraph_node *node, void *)
 
static bool collect_callers_of_node_1 (cgraph_node *node, void *data)
 
static bool clone_of_p (cgraph_node *node, cgraph_node *node2)
 
static void cgraph_debug_gimple_stmt (function *this_cfun, gimple *stmt)
 
static bool verify_speculative_call (struct cgraph_node *node, gimple *stmt, unsigned int lto_stmt_uid, struct cgraph_edge *indirect)
 
void cgraph_cc_finalize (void)
 

Variables

symtab_nodex_cgraph_nodes_queue
 
symbol_tablesymtab
 
static hash_table< function_version_hasher > * cgraph_fnver_htab = NULL
 
static struct cgraph_function_version_infoversion_info_node = NULL
 
const char *const cgraph_availability_names []
 
symbol_tablesaved_symtab
 

Macro Definition Documentation

◆ cgraph_nodes_queue

#define cgraph_nodes_queue   ((cgraph_node *)x_cgraph_nodes_queue)

◆ DEFCIFCODE [1/2]

#define DEFCIFCODE ( code,
type,
string )   string,

◆ DEFCIFCODE [2/2]

#define DEFCIFCODE ( code,
type,
string )   type,

Function Documentation

◆ add_detected_attribute_1()

◆ cgraph_add_edge_to_call_site_hash()

◆ cgraph_allocate_init_indirect_info()

cgraph_indirect_call_info * cgraph_allocate_init_indirect_info ( void )
Allocate cgraph_indirect_call_info and set its fields to default values.  

References ggc_alloc().

Referenced by cgraph_node::create_indirect_edge().

◆ cgraph_cc_finalize()

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(), thunk_info::release(), nested_function_info::release(), symtab, version_info_node, and x_cgraph_nodes_queue.

Referenced by toplev::finalize().

◆ cgraph_debug_gimple_stmt()

static void cgraph_debug_gimple_stmt ( function * this_cfun,
gimple * stmt )
static
Switch to THIS_CFUN if needed and print STMT to stderr.   

References cfun, current_function_decl, debug_gimple_stmt(), ggc_alloc(), NULL, and set_cfun().

Referenced by cgraph_node::verify_node().

◆ cgraph_function_possibly_inlined_p()

bool cgraph_function_possibly_inlined_p ( tree decl)
Return true when the DECL can possibly be inlined.   

References DECL_POSSIBLY_INLINED, DECL_UNINLINABLE, symbol_table::global_info_ready, and symtab.

Referenced by gen_field_die(), and premark_types_used_by_global_vars_helper().

◆ cgraph_inline_failed_string()

const char * cgraph_inline_failed_string ( cgraph_inline_failed_t reason)
Return a string describing the failure REASON.   

References CIF_N_REASONS, gcc_assert, and ggc_alloc().

Referenced by dump_inline_stats(), dump_ipa_call_summary(), expand_call_inline(), and report_inline_failed_reason().

◆ cgraph_inline_failed_type()

◆ cgraph_node_cannot_be_local_p_1()

◆ cgraph_not_only_called_directly_p_1()

static bool cgraph_not_only_called_directly_p_1 ( cgraph_node * node,
void *  )
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().

◆ cgraph_update_edge_in_call_site_hash()

static void cgraph_update_edge_in_call_site_hash ( cgraph_edge * e)
inlinestatic

◆ cgraph_update_edges_for_call_stmt()

void cgraph_update_edges_for_call_stmt ( gimple * old_stmt,
tree old_decl,
gimple * new_stmt )
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(), ggc_alloc(), and cgraph_node::next_sibling_clone.

Referenced by fold_marked_statements().

◆ cgraph_update_edges_for_call_stmt_node()

static void cgraph_update_edges_for_call_stmt_node ( cgraph_node * node,
gimple * old_stmt,
tree old_call,
gimple * new_stmt )
static

◆ clone_of_p()

◆ collect_callers_of_node_1()

static bool collect_callers_of_node_1 ( cgraph_node * node,
void * data )
static

◆ delete_function_version()

static void delete_function_version ( cgraph_function_version_info * decl_v)
static
Remove the cgraph_function_version_info node given by DECL_V.   

References cgraph_fnver_htab, ggc_alloc(), NULL, and version_info_node.

Referenced by cgraph_node::delete_function_version_by_decl(), and cgraph_node::remove().

◆ nonremovable_p()

static bool nonremovable_p ( cgraph_node * node,
void *  )
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().

◆ release_function_body()

void release_function_body ( tree decl)

◆ set_const_flag_1()

◆ set_malloc_flag_1()

◆ set_noreturn_flag_1()

◆ set_nothrow_flag_1()

◆ set_pure_flag_1()

◆ update_call_stmt_hash_for_removing_direct_edge()

static void update_call_stmt_hash_for_removing_direct_edge ( cgraph_edge * e,
cgraph_edge * indirect )
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().

◆ verify_speculative_call()

static bool verify_speculative_call ( struct cgraph_node * node,
gimple * stmt,
unsigned int lto_stmt_uid,
struct cgraph_edge * indirect )
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(), ggc_alloc(), 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().

Variable Documentation

◆ cgraph_availability_names

const char* const cgraph_availability_names[]
Initial value:
=
{"unset", "not_available", "overwritable", "available", "local"}
Names used to print out the availability enum.   

Referenced by cgraph_node::dump(), and varpool_node::dump().

◆ cgraph_fnver_htab

hash_table<function_version_hasher>* cgraph_fnver_htab = NULL
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().

◆ saved_symtab

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.   

◆ symtab

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(), modref_summaries::create_ggc(), modref_summaries_lto::create_ggc(), ipcp_transformation_t::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(), clone_info::get_create(), thunk_info::get_create(), nested_function_info::get_create(), cgraph_node::get_create(), cgraph_node::get_fini_priority(), symtab_node::get_for_asmname(), symtab_node::get_init_priority(), gimple_fold_builtin_acc_on_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(), clone_info::remove(), thunk_info::remove(), cgraph_node::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().

◆ version_info_node

struct cgraph_function_version_info* version_info_node = NULL
static
Mark as GC root all allocated nodes.   

Referenced by cgraph_cc_finalize(), delete_function_version(), and cgraph_node::insert_new_function_version().

◆ x_cgraph_nodes_queue

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().