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

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


typedef ipa_reference_local_vars_info_dipa_reference_local_vars_info_t
typedef ipa_reference_global_vars_info_dipa_reference_global_vars_info_t
typedef ipa_reference_optimization_summary_dipa_reference_optimization_summary_t
typedef struct ipa_reference_vars_info_dipa_reference_vars_info_t
typedef hash_map< tree, int > reference_vars_map_t


int ipa_reference_var_uid (tree t)
int ipa_reference_var_get_or_insert_uid (tree t, bool *existed)
static ipa_reference_vars_info_t get_reference_vars_info (struct cgraph_node *node)
static ipa_reference_optimization_summary_t get_reference_optimization_summary (struct cgraph_node *node)
bitmap ipa_reference_get_read_global (struct cgraph_node *fn)
bitmap ipa_reference_get_written_global (struct cgraph_node *fn)
static bool is_improper (symtab_node *n, void *v)
static bool is_proper_for_analysis (tree t)
static const char * get_static_name (int index)
static void dump_static_vars_set_to_file (FILE *f, bitmap set)
static bool union_static_var_sets (bitmap &x, bitmap y)
static bitmap copy_static_var_set (bitmap set, bool for_propagation)
static void propagate_bits (ipa_reference_global_vars_info_t x_global, struct cgraph_node *x)
static void varpool_removal_hook (varpool_node *node, void *)
static void ipa_init (void)
static ipa_reference_local_vars_info_t init_function_info (struct cgraph_node *fn)
static void analyze_function (struct cgraph_node *fn)
static void generate_summary (void)
static void read_write_all_from_decl (struct cgraph_node *node, bool &read_all, bool &write_all)
static void get_read_write_all_from_node (struct cgraph_node *node, bool &read_all, bool &write_all)
static bool ignore_edge_p (cgraph_edge *e)
static unsigned int propagate (void)
static bool write_node_summary_p (struct cgraph_node *node, lto_symtab_encoder_t encoder, bitmap ltrans_statics)
static void stream_out_bitmap (struct lto_simple_output_block *ob, bitmap bits, bitmap ltrans_statics, int ltrans_statics_bitcount)
static void ipa_reference_write_optimization_summary (void)
static void ipa_reference_read_optimization_summary (void)
ipa_opt_pass_dmake_pass_ipa_reference (gcc::context *ctxt)
void ipa_reference_cc_finalize (void)


static reference_vars_map_tipa_reference_vars_map
static int ipa_reference_vars_uids
static vec< tree > * reference_vars_to_consider
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_tipa_ref_var_info_summaries = NULL
static ipa_ref_opt_summary_tipa_ref_opt_sum_summaries = NULL
static bool ipa_init_p = false

Typedef Documentation

◆ ipa_reference_global_vars_info_t

◆ ipa_reference_local_vars_info_t

◆ ipa_reference_optimization_summary_t

◆ ipa_reference_vars_info_t

◆ reference_vars_map_t

This map contains all of the static variables that are
being considered by the compilation level alias analysis.   

Function Documentation

◆ analyze_function()

◆ copy_static_var_set()

static bitmap copy_static_var_set ( bitmap set,
bool for_propagation )
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().

◆ dump_static_vars_set_to_file()

static void dump_static_vars_set_to_file ( FILE * f,
bitmap set )
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().

◆ generate_summary()

◆ get_read_write_all_from_node()

◆ get_reference_optimization_summary()

static ipa_reference_optimization_summary_t get_reference_optimization_summary ( struct cgraph_node * node)
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().

◆ get_reference_vars_info()

static ipa_reference_vars_info_t get_reference_vars_info ( struct cgraph_node * node)
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().

◆ get_static_name()

static const char * get_static_name ( int index)
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().

◆ ignore_edge_p()

static bool ignore_edge_p ( cgraph_edge * e)
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.

Referenced by propagate().

◆ init_function_info()

◆ ipa_init()

◆ ipa_reference_cc_finalize()

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, symbol_table::remove_varpool_removal_hook(), symtab, and varpool_node_hooks.

Referenced by toplev::finalize().

◆ ipa_reference_get_read_global()

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

◆ ipa_reference_get_written_global()

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

◆ ipa_reference_read_optimization_summary()

◆ ipa_reference_var_get_or_insert_uid()

int ipa_reference_var_get_or_insert_uid ( tree t,
bool * existed )
Return ID used by ipa-reference bitmaps.  Create new entry if
T is not in map.  Set EXISTED accordinly   

References symtab_node::get(), hash_map< KeyId, Value, Traits >::get_or_insert(), ipa_reference_vars_map, ipa_reference_vars_uids, and NULL.

Referenced by analyze_function(), and ipa_reference_read_optimization_summary().

◆ ipa_reference_var_uid()

◆ ipa_reference_write_optimization_summary()

◆ is_improper()

static bool is_improper ( symtab_node * n,
void * v )
Hepler for is_proper_for_analysis.   


Referenced by is_proper_for_analysis().

◆ is_proper_for_analysis()

static bool is_proper_for_analysis ( tree t)
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().

◆ make_pass_ipa_reference()

ipa_opt_pass_d * make_pass_ipa_reference ( gcc::context * ctxt)

◆ propagate()

static unsigned int propagate ( void )
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(), symbol_table::cgraph_count, 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().

◆ propagate_bits()

static void propagate_bits ( ipa_reference_global_vars_info_t x_global,
struct cgraph_node * x )
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().

◆ read_write_all_from_decl()

static void read_write_all_from_decl ( struct cgraph_node * node,
bool & read_all,
bool & write_all )

◆ stream_out_bitmap()

static void stream_out_bitmap ( struct lto_simple_output_block * ob,
bitmap bits,
bitmap ltrans_statics,
int ltrans_statics_bitcount )
Stream out BITS&LTRANS_STATICS as list of decls to OB.
or -1.  When it is positive, just output -1 when

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

◆ union_static_var_sets()

static bool union_static_var_sets ( bitmap & x,
bitmap y )
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().

◆ varpool_removal_hook()

static void varpool_removal_hook ( varpool_node * node,
void *  )

◆ write_node_summary_p()

Variable Documentation

◆ all_module_statics

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

◆ ignore_module_statics

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

◆ ipa_init_p

bool ipa_init_p = false

◆ ipa_ref_opt_sum_summaries

◆ ipa_ref_var_info_summaries

ipa_ref_var_info_summary_t* ipa_ref_var_info_summaries = NULL

◆ ipa_reference_vars_map

◆ ipa_reference_vars_uids

◆ local_info_obstack

bitmap_obstack local_info_obstack
Obstack holding bitmaps of local analysis (live from analysis to

Referenced by init_function_info(), ipa_init(), and propagate().

◆ no_module_statics

◆ optimization_summary_obstack

bitmap_obstack optimization_summary_obstack
Obstack holding global analysis live forever.   

Referenced by ipa_init(), ipa_reference_cc_finalize(), ipa_reference_read_optimization_summary(), and propagate().

◆ reference_vars_to_consider

◆ varpool_node_hooks