GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "alloc-pool.h"
#include "cgraph.h"
#include "lto-streamer.h"
#include "dumpfile.h"
#include "splay-tree.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 "tree-eh.h"
#include "gimple-iterator.h"
#include "ipa-modref-tree.h"
#include "ipa-modref.h"
#include "tree-ssa-loop-niter.h"
#include "calls.h"
#include "cfgloop.h"
#include "cfganal.h"
Data Structures | |
struct | searchc_env |
struct | postorder_stack |
Functions | |
void | ipa_print_order (FILE *out, const char *note, struct cgraph_node **order, int count) |
static void | searchc (struct searchc_env *env, struct cgraph_node *v, bool(*ignore_edge)(struct cgraph_edge *)) |
int | ipa_reduced_postorder (struct cgraph_node **order, bool reduce, bool(*ignore_edge)(struct cgraph_edge *)) |
void | ipa_free_postorder_info (void) |
vec< cgraph_node * > | ipa_get_nodes_in_cycle (struct cgraph_node *node) |
bool | ipa_edge_within_scc (struct cgraph_edge *cs) |
int | ipa_reverse_postorder (struct cgraph_node **order) |
tree | get_base_var (tree t) |
void | scale_ipa_profile_for_fn (struct cgraph_node *node, profile_count orig_count) |
void | ipa_merge_profiles (struct cgraph_node *dst, struct cgraph_node *src, bool preserve_body) |
bool | recursive_call_p (tree func, tree dest) |
bool | stmt_may_terminate_function_p (function *fun, gimple *stmt, bool assume_return_or_eh) |
bitmap | find_always_executed_bbs (function *fun, bool assume_return_or_eh) |
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.
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().
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_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 ) |
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().
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().
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 scale_ipa_profile_for_fn | ( | struct cgraph_node * | node, |
profile_count | orig_count ) |
Scale function of calls in NODE by ratio ORIG_COUNT/NODE->count.
References profile_count::adjust_for_ipa_scaling(), profile_count::apply_scale(), cgraph_node::callees, cgraph_edge::count, cgraph_node::count, cgraph_node::indirect_calls, cgraph_edge::next_callee, and postorder_stack::node.
Referenced by ipa_merge_profiles().
|
static |
This is an implementation of Tarjan's strongly connected region finder as reprinted in Aho Hopcraft and Ullman's The Design and Analysis of Computer Programs (1975) pages 192-193. This version has been customized for cgraph_nodes. The env parameter is because it is recursive and there are no nested functions here. This function should only be called from itself or ipa_reduced_postorder. ENV is a stack env and would be unnecessary if C had nested functions. V is the node to start searching from.
References symtab_node::aux, AVAIL_INTERPOSABLE, cgraph_node::callees, ipa_dfs_info::dfn_number, env, cgraph_node::get_uid(), last, ipa_dfs_info::low_link, ipa_dfs_info::new_node, cgraph_edge::next_callee, ipa_dfs_info::next_cycle, NULL, ipa_dfs_info::on_stack, ipa_dfs_info::scc_no, searchc(), and cgraph_node::ultimate_alias_target().
Referenced by ipa_reduced_postorder(), and searchc().
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().