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, 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.
Referenced by generate_summary().
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(), gcc_checking_assert, no_module_statics, and NULL.
Referenced by ipa_ref_opt_summary_t::duplicate(), and propagate().
|
static |
Dump a set of static vars to FILE.
References all_module_statics, EXECUTE_IF_SET_IN_BITMAP, get_static_name(), no_module_statics, and NULL.
Referenced by propagate().
|
static |
Analyze each function in the cgraph to see which global or statics are read or written.
References symtab_node::alias, all_module_statics, analyze_function(), AVAIL_INTERPOSABLE, bitmap_set_bit, symtab_node::decl, dump_file, symtab_node::dump_name(), EXECUTE_IF_SET_IN_BITMAP, FOR_EACH_DEFINED_FUNCTION, cgraph_node::get_availability(), get_reference_vars_info(), get_static_name(), i, ignore_module_statics, ipa_init(), ipa_reference_var_uid(), is_a(), is_proper_for_analysis(), symtab_node::iterate_reference(), 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 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::callee, cgraph_node::callees, cgraph_edge::cannot_lead_to_return_p(), symtab_node::decl, dump_file, dump_flags, ECF_CONST, cgraph_indirect_call_info::ecf_flags, ECF_PURE, cgraph_node::function_symbol(), gcc_checking_assert, cgraph_node::get_availability(), cgraph_node::indirect_calls, cgraph_edge::indirect_info, cgraph_edge::next_callee, opt_for_fn, read_write_all_from_decl(), and TDF_DETAILS.
Referenced by propagate().
|
inlinestatic |
Return the ipa_reference_vars structure starting from the cgraph NODE.
References ipa_ref_opt_sum_summaries, and NULL.
Referenced by 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 ipa_ref_var_info_summaries, and NULL.
Referenced by generate_summary(), 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(), and reference_vars_to_consider.
Referenced by dump_static_vars_set_to_file(), and generate_summary().
|
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 bellow.
References AVAIL_INTERPOSABLE, cgraph_edge::callee, cgraph_edge::caller, symtab_node::decl, ECF_LEAF, flags_from_decl_or_type(), cgraph_node::function_or_virtual_thunk_symbol(), and opt_for_fn.
|
static |
Set up the persistent info for FN.
References BITMAP_ALLOC, ipa_reference_vars_info_d::global, 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().
|
static |
The init routine for analyzing global static variable usage. See comments at top for description.
References all_module_statics, BITMAP_ALLOC, bitmap_obstack_initialize(), dump_file, ignore_module_statics, ipa_init_p, ipa_ref_opt_sum_summaries, ipa_ref_var_info_summaries, 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().
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_vars_map, NULL, optimization_summary_obstack, symtab, and varpool_node_hooks.
Referenced by toplev::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.
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(), no_module_statics, NULL, opt_for_fn, and ipa_reference_optimization_summary_d::statics_read.
Referenced by 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(), no_module_statics, NULL, opt_for_fn, and ipa_reference_optimization_summary_d::statics_written.
Referenced by call_may_clobber_ref_p_1().
|
static |
Deserialize the ipa info for lto.
References all_module_statics, BITMAP_ALLOC, bitmap_obstack_initialize(), bitmap_set_bit, symtab_node::dump_asm_name(), 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_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().
Return ID used by ipa-reference bitmaps. Create new entry if T is not in map. Set EXISTED accordinly
References symtab_node::get(), ipa_reference_vars_map, ipa_reference_vars_uids, and NULL.
Referenced by analyze_function(), and ipa_reference_read_optimization_summary().
int ipa_reference_var_uid | ( | tree | t | ) |
Return ID used by ipa-reference bitmaps. -1 if failed.
References symtab_node::get(), ipa_reference_vars_map, and NULL.
Referenced by call_may_clobber_ref_p_1(), generate_summary(), ipa_reference_read_optimization_summary(), 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, count, 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, 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().
|
static |
Hepler for is_proper_for_analysis.
References symtab_node::decl, DECL_PRESERVE_P, TREE_ADDRESSABLE, TREE_PUBLIC, TREE_READONLY, and TREE_THIS_VOLATILE.
Referenced by 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(), and NULL.
Referenced by analyze_function(), and generate_summary().
ipa_opt_pass_d * make_pass_ipa_reference | ( | gcc::context * | ctxt | ) |
|
static |
Produce the global information by preforming a transitive closure on the local information that was produced by ipa_analyze_function.
References symtab_node::alias, all_module_statics, BITMAP_ALLOC, bitmap_copy(), bitmap_empty_p(), bitmap_equal_p(), bitmap_obstack_release(), cgraph_node::cannot_return_p(), copy_static_var_set(), symtab_node::decl, symtab_node::dump_asm_name(), cgraph_node::dump_cgraph(), dump_file, dump_flags, symtab_node::dump_name(), 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(), cgraph_node::inlined_to, 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_var_info_summaries, ipa_reference_vars_info_d::local, local_info_obstack, no_module_statics, NULL, opt_for_fn, optimization_summary_obstack, symtab_node::order, 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_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_edge::callee, cgraph_node::callees, cgraph_edge::cannot_lead_to_return_p(), ECF_CONST, ECF_LEAF, ECF_PURE, flags_from_decl_or_type(), cgraph_node::function_symbol(), gcc_unreachable, get_reference_vars_info(), ipa_reference_vars_info_d::global, cgraph_edge::next_callee, opt_for_fn, 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().
|
static |
Set READ_ALL/WRITE_ALL based on decl flags of NODE.
References AVAIL_INTERPOSABLE, cgraph_node::cannot_return_p(), symtab_node::decl, dump_file, dump_flags, symtab_node::dump_name(), ECF_CONST, ECF_LEAF, ECF_PURE, flags_from_decl_or_type(), cgraph_node::get_availability(), and TDF_DETAILS.
Referenced by get_read_write_all_from_node().
|
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, count, lto_simple_output_block::decl_state, EXECUTE_IF_AND_IN_BITMAP, lto_output_var_decl_ref(), lto_simple_output_block::main_stream, and streamer_write_hwi_stream().
Referenced by ipa_reference_write_optimization_summary().
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(), and y.
Referenced by propagate(), and propagate_bits().
|
static |
Delete NODE from map.
References symtab_node::decl, and ipa_reference_vars_map.
Referenced by ipa_init(), and ipa_reference_read_optimization_summary().
|
static |
Return true if we need to write summary of NODE.
References symtab_node::definition, EXECUTE_IF_AND_COMPL_IN_BITMAP, get_reference_optimization_summary(), i, cgraph_node::inlined_to, reachable_from_this_partition_p(), referenced_from_this_partition_p(), ipa_reference_optimization_summary_d::statics_read, and ipa_reference_optimization_summary_d::statics_written.
Referenced by ipa_reference_write_optimization_summary().
|
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().