|
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 "tree-pass.h"#include "cgraph.h"#include "data-streamer.h"#include "calls.h"#include "ipa-utils.h"#include "ipa-reference.h"#include "alloc-pool.h"#include "symbol-summary.h"
Data Structures | |
| struct | ipa_reference_local_vars_info_d |
| struct | ipa_reference_global_vars_info_d |
| struct | ipa_reference_optimization_summary_d |
| struct | ipa_reference_vars_info_d |
| class | ipa_ref_var_info_summary_t |
| class | ipa_ref_opt_summary_t |
Typedefs | |
| typedef ipa_reference_local_vars_info_d * | ipa_reference_local_vars_info_t |
| typedef ipa_reference_global_vars_info_d * | ipa_reference_global_vars_info_t |
| typedef ipa_reference_optimization_summary_d * | ipa_reference_optimization_summary_t |
| typedef struct ipa_reference_vars_info_d * | ipa_reference_vars_info_t |
| typedef hash_map< tree, int > | reference_vars_map_t |
Variables | |
| static reference_vars_map_t * | ipa_reference_vars_map |
| static int | ipa_reference_vars_uids |
| static vec< tree > * | reference_vars_to_consider |
| varpool_node_hook_list * | varpool_node_hooks |
| static bitmap | all_module_statics |
| static bitmap | no_module_statics |
| static bitmap | ignore_module_statics |
| static bitmap_obstack | local_info_obstack |
| static bitmap_obstack | optimization_summary_obstack |
| static ipa_ref_var_info_summary_t * | ipa_ref_var_info_summaries = NULL |
| static ipa_ref_opt_summary_t * | ipa_ref_opt_sum_summaries = NULL |
| static bool | ipa_init_p = false |
| typedef struct ipa_reference_vars_info_d* ipa_reference_vars_info_t |
| typedef hash_map<tree, int> reference_vars_map_t |
This map contains all of the static variables that are being considered by the compilation level alias analysis.
|
static |
This is the main routine for finding the reference patterns for global variables within a function FN.
References all_module_statics, analyze_function(), bitmap_clear(), bitmap_set_bit, ipa_ref::cannot_lead_to_return(), cgraph_node::cannot_return_p(), symtab_node::decl, dump_file, gcc_unreachable, i, init_function_info(), IPA_REF_ADDR, IPA_REF_LOAD, IPA_REF_STORE, ipa_reference_var_get_or_insert_uid(), is_a(), is_proper_for_analysis(), symtab_node::iterate_reference(), cgraph_node::local, NULL, opt_for_fn, reference_vars_to_consider, ipa_ref::referred, ipa_reference_local_vars_info_d::statics_read, ipa_reference_local_vars_info_d::statics_written, and ipa_ref::use.
Return a copy of SET on the bitmap obstack containing SET. But if SET is NULL or the maximum set, return that instead.
References all_module_statics, BITMAP_ALLOC, bitmap_copy(), copy_static_var_set(), gcc_checking_assert, no_module_statics, and NULL.
Referenced by copy_static_var_set(), ipa_ref_opt_summary_t::duplicate(), and propagate().
|
static |
Dump a set of static vars to FILE.
References all_module_statics, dump_static_vars_set_to_file(), EXECUTE_IF_SET_IN_BITMAP, get_static_name(), no_module_statics, and NULL.
Referenced by dump_static_vars_set_to_file(), and propagate().
|
static |
Analyze each function in the cgraph to see which global or statics are read or written.
References all_module_statics, analyze_function(), AVAIL_INTERPOSABLE, bitmap_set_bit, symtab_node::decl, dump_file, EXECUTE_IF_SET_IN_BITMAP, FOR_EACH_DEFINED_FUNCTION, generate_summary(), get_reference_vars_info(), get_static_name(), i, ignore_module_statics, ipa_init(), ipa_reference_var_uid(), is_a(), is_proper_for_analysis(), ipa_reference_vars_info_d::local, NULL, opt_for_fn, ipa_ref::referred, ipa_reference_local_vars_info_d::statics_read, and ipa_reference_local_vars_info_d::statics_written.
Referenced by generate_summary(), and propagate().
|
static |
Set READ_ALL/WRITE_ALL based on decl flags of NODE or any member in the cycle of NODE.
References symtab_node::analyzed, AVAIL_INTERPOSABLE, cgraph_edge::cannot_lead_to_return_p(), symtab_node::decl, dump_file, dump_flags, ECF_CONST, cgraph_indirect_call_info::ecf_flags, ECF_PURE, gcc_checking_assert, get_read_write_all_from_node(), cgraph_edge::indirect_info, cgraph_edge::next_callee, opt_for_fn, read_write_all_from_decl(), and TDF_DETAILS.
Referenced by get_read_write_all_from_node(), and propagate().
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
References get_reference_optimization_summary(), ipa_ref_opt_sum_summaries, and NULL.
Referenced by get_reference_optimization_summary(), ipa_reference_get_read_global(), ipa_reference_get_written_global(), ipa_reference_write_optimization_summary(), and write_node_summary_p().
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
References get_reference_vars_info(), ipa_ref_var_info_summaries, and NULL.
Referenced by generate_summary(), get_reference_vars_info(), propagate(), and propagate_bits().
|
static |
Lookup the tree node for the static variable that has UID and convert the name to a string for debugging.
References fndecl_name(), get_static_name(), and reference_vars_to_consider.
Referenced by dump_static_vars_set_to_file(), generate_summary(), and get_static_name().
|
static |
Skip edges from and to nodes without ipa_reference enabled. Ignore not available symbols. This leave them out of strongly connected components and makes them easy to skip in the propagation loop below.
References AVAIL_INTERPOSABLE, symtab_node::decl, ECF_LEAF, flags_from_decl_or_type(), ignore_edge_p(), and opt_for_fn.
|
static |
Set up the persistent info for FN.
References BITMAP_ALLOC, ipa_reference_vars_info_d::global, init_function_info(), ipa_ref_var_info_summaries, ipa_reference_vars_info_d::local, local_info_obstack, NULL, ipa_reference_global_vars_info_d::statics_read, ipa_reference_local_vars_info_d::statics_read, and ipa_reference_local_vars_info_d::statics_written.
Referenced by analyze_function(), and init_function_info().
|
static |
The init routine for analyzing global static variable usage. See comments at top for description.
References symbol_table::add_varpool_removal_hook(), all_module_statics, BITMAP_ALLOC, bitmap_obstack_initialize(), dump_file, ignore_module_statics, ipa_init(), ipa_init_p, ipa_ref_opt_sum_summaries, ipa_ref_var_info_summaries, ipa_ref_var_info_summary_t::ipa_ref_var_info_summary_t(), ipa_reference_vars_map, ipa_reference_vars_uids, local_info_obstack, no_module_statics, NULL, optimization_summary_obstack, reference_vars_to_consider, symtab, varpool_node_hooks, varpool_removal_hook(), and vec_alloc().
Referenced by generate_summary(), and ipa_init().
| void ipa_reference_cc_finalize | ( | void | ) |
Reset all state within ipa-reference.cc so that we can rerun the compiler within the same process. For use by toplev::finalize.
References bitmap_obstack_release(), ipa_init_p, ipa_ref_opt_sum_summaries, ipa_reference_cc_finalize(), ipa_reference_vars_map, NULL, optimization_summary_obstack, symbol_table::remove_varpool_removal_hook(), symtab, and varpool_node_hooks.
Referenced by toplev::finalize(), and ipa_reference_cc_finalize().
| bitmap ipa_reference_get_read_global | ( | struct cgraph_node * | fn | ) |
Return a bitmap indexed by ipa_reference_var_uid for the static variables that are *not* read during the execution of the function FN. Returns NULL if no data is available.
IPA handling of references. Copyright (C) 2004-2026 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/>.
In ipa-reference.cc
References AVAIL_AVAILABLE, AVAIL_INTERPOSABLE, AVAIL_NOT_AVAILABLE, current_function_decl, symtab_node::decl, ECF_LEAF, flags_from_decl_or_type(), cgraph_node::function_symbol(), get_reference_optimization_summary(), ipa_reference_get_read_global(), no_module_statics, NULL, opt_for_fn, and ipa_reference_optimization_summary_d::statics_read.
Referenced by ipa_reference_get_read_global(), and ref_maybe_used_by_call_p_1().
| bitmap ipa_reference_get_written_global | ( | struct cgraph_node * | fn | ) |
Return a bitmap indexed by ipa_reference_var_uid for the static variables that are *not* written during the execution of the function FN. Note that variables written may or may not be read during the function call. Returns NULL if no data is available.
References AVAIL_AVAILABLE, AVAIL_INTERPOSABLE, AVAIL_NOT_AVAILABLE, current_function_decl, symtab_node::decl, ECF_LEAF, flags_from_decl_or_type(), cgraph_node::function_symbol(), get_reference_optimization_summary(), ipa_reference_get_written_global(), no_module_statics, NULL, opt_for_fn, and ipa_reference_optimization_summary_d::statics_written.
Referenced by call_may_clobber_ref_p_1(), and ipa_reference_get_written_global().
|
static |
Deserialize the ipa info for lto.
References symbol_table::add_varpool_removal_hook(), all_module_statics, BITMAP_ALLOC, bitmap_obstack_initialize(), bitmap_set_bit, dump_file, dyn_cast(), fatal_error(), lto_input_block::file_data, fndecl_name(), gcc_checking_assert, i, input_location, ipa_ref_opt_sum_summaries, ipa_ref_opt_summary_t::ipa_ref_opt_summary_t(), ipa_reference_read_optimization_summary(), ipa_reference_var_get_or_insert_uid(), ipa_reference_var_uid(), ipa_reference_vars_map, ipa_reference_vars_uids, lto_input_block::len, lto_create_simple_input_block(), lto_destroy_simple_input_block(), lto_get_file_decl_data(), lto_input_var_decl_ref(), LTO_section_ipa_reference, lto_symtab_encoder_deref(), no_module_statics, NULL, optimization_summary_obstack, ipa_reference_optimization_summary_d::statics_read, ipa_reference_optimization_summary_d::statics_written, streamer_read_hwi(), streamer_read_uhwi(), symtab, lto_file_decl_data::symtab_node_encoder, varpool_node_hooks, and varpool_removal_hook().
Referenced by ipa_reference_read_optimization_summary().
Return ID used by ipa-reference bitmaps. Create new entry if T is not in map. Set EXISTED accordingly
References symtab_node::get(), hash_map< KeyId, Value, Traits >::get_or_insert(), ipa_reference_var_get_or_insert_uid(), ipa_reference_vars_map, ipa_reference_vars_uids, and NULL.
Referenced by analyze_function(), ipa_reference_read_optimization_summary(), and ipa_reference_var_get_or_insert_uid().
| int ipa_reference_var_uid | ( | tree | t | ) |
Return ID used by ipa-reference bitmaps. -1 if failed.
References hash_map< KeyId, Value, Traits >::get(), symtab_node::get(), ipa_reference_var_uid(), ipa_reference_vars_map, and NULL.
Referenced by call_may_clobber_ref_p_1(), generate_summary(), ipa_reference_read_optimization_summary(), ipa_reference_var_uid(), ipa_reference_write_optimization_summary(), is_proper_for_analysis(), and ref_maybe_used_by_call_p_1().
|
static |
Serialize the ipa info for lto.
References bitmap_set_bit, symtab_node::decl, lto_simple_output_block::decl_state, dyn_cast(), gcc_checking_assert, get_reference_optimization_summary(), i, ipa_reference_var_uid(), ipa_reference_vars_uids, ipa_reference_write_optimization_summary(), lto_create_simple_output_block(), lto_destroy_simple_output_block(), LTO_section_ipa_reference, lto_symtab_encoder_deref(), lto_symtab_encoder_encode(), lto_symtab_encoder_size(), lto_simple_output_block::main_stream, NULL, reference_vars_to_consider, referenced_from_this_partition_p(), ipa_reference_optimization_summary_d::statics_read, ipa_reference_optimization_summary_d::statics_written, stream_out_bitmap(), streamer_write_uhwi_stream(), lto_out_decl_state::symtab_node_encoder, vec_alloc(), vec_free(), and write_node_summary_p().
Referenced by ipa_reference_write_optimization_summary().
|
static |
Helper for is_proper_for_analysis.
References DECL_PRESERVE_P, is_improper(), TREE_ADDRESSABLE, TREE_PUBLIC, TREE_READONLY, and TREE_THIS_VOLATILE.
Referenced by is_improper(), and is_proper_for_analysis().
Return true if the variable T is the right kind of static variable to perform compilation unit scope escape analysis.
References bitmap_bit_p, cgraph_node::call_for_symbol_and_aliases(), symtab_node::get(), ignore_module_statics, ipa_reference_var_uid(), is_improper(), is_proper_for_analysis(), and NULL.
Referenced by analyze_function(), generate_summary(), and is_proper_for_analysis().
| ipa_opt_pass_d * make_pass_ipa_reference | ( | gcc::context * | ctxt | ) |
References make_pass_ipa_reference().
Referenced by make_pass_ipa_reference(), and make_pass_sprintf_length().
|
static |
Produce the global information by preforming a transitive closure on the local information that was produced by ipa_analyze_function.
References all_module_statics, BITMAP_ALLOC, bitmap_copy(), bitmap_empty_p(), bitmap_equal_p(), bitmap_obstack_release(), symbol_table::cgraph_count, copy_static_var_set(), cgraph_node::dump_cgraph(), dump_file, dump_flags, dump_static_vars_set_to_file(), ECF_CONST, ECF_PURE, flags_from_decl_or_type(), FOR_EACH_DEFINED_FUNCTION, FOR_EACH_VEC_ELT, free(), gcc_assert, gcc_checking_assert, generate_summary(), get_read_write_all_from_node(), get_reference_vars_info(), ipa_reference_vars_info_d::global, i, ignore_edge_p(), ipa_discover_variable_flags(), ipa_free_postorder_info(), ipa_get_nodes_in_cycle(), ipa_print_order(), ipa_reduced_postorder(), ipa_ref_opt_sum_summaries, ipa_ref_opt_summary_t::ipa_ref_opt_summary_t(), ipa_ref_var_info_summaries, ipa_reference_vars_info_d::local, local_info_obstack, no_module_statics, NULL, opt_for_fn, optimization_summary_obstack, toplevel_node::order, propagate(), propagate_bits(), reference_vars_to_consider, ipa_reference_global_vars_info_d::statics_read, ipa_reference_local_vars_info_d::statics_read, ipa_reference_optimization_summary_d::statics_read, ipa_reference_global_vars_info_d::statics_written, ipa_reference_local_vars_info_d::statics_written, ipa_reference_optimization_summary_d::statics_written, symtab, TDF_DETAILS, TODO_remove_functions, union_static_var_sets(), and vec_free().
Referenced by propagate(), and propagate_pseudo_copies().
|
static |
Compute the union all of the statics read and written by every callee of X into X_GLOBAL->statics_read and X_GLOBAL->statics_written. X_GLOBAL is actually the set representing the cycle containing X. If the read and written sets of X_GLOBAL has been reduced to the maximum set, we don't have to look at the remaining callees.
References all_module_statics, AVAIL_INTERPOSABLE, cgraph_node::callees, ECF_CONST, ECF_LEAF, ECF_PURE, flags_from_decl_or_type(), gcc_unreachable, get_reference_vars_info(), ipa_reference_vars_info_d::global, opt_for_fn, propagate_bits(), ipa_reference_global_vars_info_d::statics_read, ipa_reference_global_vars_info_d::statics_written, union_static_var_sets(), and y.
Referenced by propagate(), and propagate_bits().
|
static |
Set READ_ALL/WRITE_ALL based on decl flags of NODE.
References AVAIL_INTERPOSABLE, dump_file, dump_flags, ECF_CONST, ECF_LEAF, ECF_PURE, flags_from_decl_or_type(), read_write_all_from_decl(), and TDF_DETAILS.
Referenced by get_read_write_all_from_node(), and read_write_all_from_decl().
|
static |
Stream out BITS<RANS_STATICS as list of decls to OB. LTRANS_STATICS_BITCOUNT specify number of bits in LTRANS_STATICS or -1. When it is positive, just output -1 when BITS<RANS_STATICS == BITS<RANS_STATICS.
References all_module_statics, cgraph_node::count, lto_simple_output_block::decl_state, EXECUTE_IF_AND_IN_BITMAP, lto_output_var_decl_ref(), lto_simple_output_block::main_stream, stream_out_bitmap(), and streamer_write_hwi_stream().
Referenced by ipa_reference_write_optimization_summary(), and stream_out_bitmap().
Compute X |= Y, taking into account the possibility that either X or Y is already the maximum set. Return true if X is the maximum set after taking the union with Y.
References all_module_statics, bitmap_equal_p(), BITMAP_FREE, bitmap_ior_into(), union_static_var_sets(), and y.
Referenced by propagate(), propagate_bits(), and union_static_var_sets().
|
static |
Delete NODE from map.
References ipa_reference_vars_map, hash_map< KeyId, Value, Traits >::remove(), and varpool_removal_hook().
Referenced by ipa_init(), ipa_reference_read_optimization_summary(), and varpool_removal_hook().
|
static |
Return true if we need to write summary of NODE.
References EXECUTE_IF_AND_COMPL_IN_BITMAP, get_reference_optimization_summary(), i, reachable_from_this_partition_p(), referenced_from_this_partition_p(), ipa_reference_optimization_summary_d::statics_read, ipa_reference_optimization_summary_d::statics_written, and write_node_summary_p().
Referenced by ipa_reference_write_optimization_summary(), and write_node_summary_p().
|
static |
Set of all interesting module statics. A bit is set for every module static we are considering. This is added to the local info when asm code is found that clobbers all memory.
Referenced by analyze_function(), copy_static_var_set(), dump_static_vars_set_to_file(), generate_summary(), ipa_init(), ipa_reference_read_optimization_summary(), propagate(), propagate_bits(), ipa_ref_opt_summary_t::remove(), stream_out_bitmap(), and union_static_var_sets().
|
static |
Set of all statics that should be ignored because they are touched by -fno-ipa-reference code.
Referenced by generate_summary(), ipa_init(), and is_proper_for_analysis().
Referenced by ipa_init(), and ipa_reference_cc_finalize().
|
static |
|
static |
Referenced by get_reference_vars_info(), init_function_info(), ipa_init(), and propagate().
|
static |
|
static |
|
static |
Obstack holding bitmaps of local analysis (live from analysis to propagation)
Referenced by init_function_info(), ipa_init(), and propagate().
|
static |
|
static |
Obstack holding global analysis live forever.
Referenced by ipa_init(), ipa_reference_cc_finalize(), ipa_reference_read_optimization_summary(), and propagate().
Referenced by analyze_function(), get_static_name(), ipa_init(), ipa_reference_write_optimization_summary(), and propagate().
| varpool_node_hook_list* varpool_node_hooks |
Referenced by ipa_init(), ipa_reference_cc_finalize(), and ipa_reference_read_optimization_summary().