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
 

Typedefs

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
 

Functions

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 charget_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)
 

Variables

static reference_vars_map_tipa_reference_vars_map
 
static int ipa_reference_vars_uids
 
static vec< tree > * reference_vars_to_consider
 
varpool_node_hook_listvarpool_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_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 )
static
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, ggc_alloc(), 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 )
static
Dump a set of static vars to FILE.   

References all_module_statics, EXECUTE_IF_SET_IN_BITMAP, get_static_name(), ggc_alloc(), 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)
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().

◆ get_reference_vars_info()

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

◆ get_static_name()

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

◆ ignore_edge_p()

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

◆ is_proper_for_analysis()

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

References ggc_alloc().

◆ propagate()

◆ propagate_bits()

static void propagate_bits ( ipa_reference_global_vars_info_t x_global,
struct cgraph_node * x )
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(), ggc_alloc(), cgraph_edge::next_callee, opt_for_fn, 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 )
static

◆ stream_out_bitmap()

static void stream_out_bitmap ( struct lto_simple_output_block * ob,
bitmap bits,
bitmap ltrans_statics,
int ltrans_statics_bitcount )
static
Stream out BITS&LTRANS_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&LTRANS_STATICS == BITS&LTRANS_STATICS.   

References all_module_statics, count, lto_simple_output_block::decl_state, EXECUTE_IF_AND_IN_BITMAP, ggc_alloc(), 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 )
static
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 *  )
static

◆ write_node_summary_p()

Variable Documentation

◆ all_module_statics

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

◆ ignore_module_statics

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

◆ ipa_init_p

bool ipa_init_p = false
static

◆ ipa_ref_opt_sum_summaries

◆ ipa_ref_var_info_summaries

ipa_ref_var_info_summary_t* ipa_ref_var_info_summaries = NULL
static

◆ ipa_reference_vars_map

◆ ipa_reference_vars_uids

◆ local_info_obstack

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

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

◆ no_module_statics

◆ optimization_summary_obstack

bitmap_obstack optimization_summary_obstack
static
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