GCC Middle and Back End API Reference
ipa-prop.h File Reference

Go to the source code of this file.

Data Structures

struct  ipa_known_type_data
struct  ipa_constant_data
struct  ipa_pass_through_data
struct  ipa_ancestor_jf_data
struct  ipa_agg_jf_item
struct  ipa_agg_jump_function
struct  ipa_jump_func
union  ipa_jump_func::jump_func_value
struct  ipa_param_descriptor
struct  ipa_node_params
struct  ipa_agg_replacement_value
struct  ipa_edge_args
struct  ipa_parm_adjustment


typedef struct ipa_agg_jf_item ipa_agg_jf_item_t
typedef struct
typedef struct
typedef struct ipa_jump_func ipa_jump_func_t
typedef struct ipa_param_descriptor ipa_param_descriptor_t
typedef struct
typedef struct ipa_edge_args ipa_edge_args_t
typedef struct ipa_node_params ipa_node_params_t
typedef struct ipa_parm_adjustment ipa_parm_adjustment_t
typedef vec
< ipa_parm_adjustment_t


enum  jump_func_type {


static HOST_WIDE_INT ipa_get_jf_known_type_offset ()
static tree ipa_get_jf_known_type_base_type ()
static tree ipa_get_jf_known_type_component_type ()
static tree ipa_get_jf_constant ()
static struct ipa_cst_ref_descipa_get_jf_constant_rdesc ()
static tree ipa_get_jf_pass_through_operand ()
static int ipa_get_jf_pass_through_formal_id ()
static enum tree_code ipa_get_jf_pass_through_operation ()
static bool ipa_get_jf_pass_through_agg_preserved ()
static bool ipa_get_jf_pass_through_type_preserved ()
static HOST_WIDE_INT ipa_get_jf_ancestor_offset ()
static tree ipa_get_jf_ancestor_type ()
static int ipa_get_jf_ancestor_formal_id ()
static bool ipa_get_jf_ancestor_agg_preserved ()
static bool ipa_get_jf_ancestor_type_preserved ()
static int ipa_get_param_count ()
static tree ipa_get_param ()
static int ipa_get_param_move_cost ()
static void ipa_set_param_used ()
static int ipa_get_controlled_uses ()
static void ipa_set_controlled_uses ()
static bool ipa_is_param_used ()
void ipa_set_node_agg_value_chain (struct cgraph_node *node, struct ipa_agg_replacement_value *aggvals)
static int ipa_get_cs_argument_count ()
static struct ipa_jump_funcipa_get_ith_jump_func ()
void ipa_create_all_node_params (void)
void ipa_create_all_edge_args (void)
void ipa_free_edge_args_substructures (struct ipa_edge_args *)
void ipa_free_node_params_substructures (struct ipa_node_params *)
void ipa_free_all_node_params (void)
void ipa_free_all_edge_args (void)
void ipa_free_all_structures_after_ipa_cp (void)
void ipa_free_all_structures_after_iinln (void)
void ipa_register_cgraph_hooks (void)
static void ipa_check_create_node_params ()
static void ipa_check_create_edge_args ()
static bool ipa_edge_args_info_available_for_edge_p ()
static struct
ipa_get_agg_replacements_for_node ()
void ipa_initialize_node_params (struct cgraph_node *node)
bool ipa_propagate_indirect_call_infos (struct cgraph_edge *cs, vec< cgraph_edge_p > *new_edges)
tree ipa_get_indirect_edge_target (struct cgraph_edge *ie, vec< tree >, vec< tree >, vec< ipa_agg_jump_function_p >)
struct cgraph_edgeipa_make_edge_direct_to_target (struct cgraph_edge *, tree)
tree ipa_binfo_from_known_type_jfunc (struct ipa_jump_func *)
tree ipa_intraprocedural_devirtualization (gimple)
void ipa_analyze_node (struct cgraph_node *)
tree ipa_find_agg_cst_for_param (struct ipa_agg_jump_function *, HOST_WIDE_INT, bool)
bool ipa_load_from_parm_agg (struct ipa_node_params *, gimple, tree, int *, HOST_WIDE_INT *, bool *)
void ipa_print_node_params (FILE *, struct cgraph_node *node)
void ipa_print_all_params (FILE *)
void ipa_print_node_jump_functions (FILE *f, struct cgraph_node *node)
void ipa_print_all_jump_functions (FILE *f)
void ipcp_verify_propagated_values (void)
vec< treeipa_get_vector_of_formal_parms (tree fndecl)
void ipa_modify_formal_parameters (tree fndecl, ipa_parm_adjustment_vec, const char *)
void ipa_modify_call_arguments (struct cgraph_edge *, gimple, ipa_parm_adjustment_vec)
ipa_parm_adjustment_vec ipa_combine_adjustments (ipa_parm_adjustment_vec, ipa_parm_adjustment_vec)
void ipa_dump_param_adjustments (FILE *, ipa_parm_adjustment_vec, tree)
void ipa_dump_agg_replacement_values (FILE *f, struct ipa_agg_replacement_value *av)
void ipa_prop_write_jump_functions (void)
void ipa_prop_read_jump_functions (void)
void ipa_prop_write_all_agg_replacement (void)
void ipa_prop_read_all_agg_replacement (void)
void ipa_update_after_lto_read (void)
int ipa_get_param_decl_index (struct ipa_node_params *, tree)
tree ipa_value_from_jfunc (struct ipa_node_params *info, struct ipa_jump_func *jfunc)
unsigned int ipcp_transform_function (struct cgraph_node *node)
void ipa_dump_param (FILE *, struct ipa_node_params *info, int i)
tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree, gimple_stmt_iterator *, bool)


vec< ipa_node_params_tipa_node_params_vector
< ipa_agg_replacement_value_p,
va_gc > * 
vec< ipa_edge_args_t, va_gc > * ipa_edge_args_vector
alloc_pool ipcp_values_pool
alloc_pool ipcp_sources_pool
alloc_pool ipcp_agg_lattice_pool

Typedef Documentation

   An element in an aggegate part of a jump function describing a known value
   at a given offset.  When it is part of a pass-through jump function with
   agg_preserved set or an ancestor jump function with agg_preserved set, all
   unlisted positions are assumed to be preserved but the value can be a type
   node, which means that the particular piece (starting at offset and having
   the size of the type) is clobbered with an unknown value.  When
   agg_preserved is false or the type of the containing jump function is
   different, all unlisted parts are assumed to be unknown and all values must
   fulfill is_gimple_ip_invariant.  
   ipa_edge_args stores information related to a callsite and particularly its
   arguments.  It can be accessed by the IPA_EDGE_REF macro.  
   A jump function for a callsite represents the values passed as actual
   arguments of the callsite. See enum jump_func_type for the various
   types of jump functions supported.  
   Vectors need to have typedefs of structures.  

Enumeration Type Documentation

   ipa-prop.c stuff (ipa-cp, indirect inlining):  
   A jump function for a callsite represents the values passed as actual
   arguments of the callsite.  They were originally proposed in a paper called
   "Interprocedural Constant Propagation", by David Callahan, Keith D Cooper,
   Ken Kennedy, Linda Torczon in Comp86, pg 152-161.  There are three main
   types of values :

   Pass-through - the caller's formal parameter is passed as an actual
                  argument, possibly one simple operation performed on it.
   Constant     - a constant (is_gimple_ip_invariant)is passed as an actual
   Unknown      - neither of the above.

   IPA_JF_ANCESTOR is a special pass-through jump function, which means that
   the result is an address of a part of the object pointed to by the formal
   parameter to which the function refers.  It is mainly intended to represent
   getting addresses of of ancestor fields in C++
   (e.g. &this_1(D)->D.1766.D.1756).  Note that if the original pointer is
   NULL, ancestor jump function must behave like a simple pass-through.

   Other pass-through functions can either simply pass on an unchanged formal
   parameter or can apply one simple binary operation to it (such jump
   functions are called polynomial).

   IPA_JF_KNOWN_TYPE is a special type of an "unknown" function that applies
   only to pointer parameters.  It means that even though we cannot prove that
   the passed value is an interprocedural constant, we still know the exact
   type of the containing object which may be valuable for devirtualization.

   Jump functions are computed in ipa-prop.c by function
   update_call_notes_after_inlining.  Some information can be lost and jump
   functions degraded accordingly when inlining, see
   update_call_notes_after_inlining in the same file.  

Function Documentation

tree build_ref_for_offset ( location_t  loc,
tree  base,
HOST_WIDE_INT  offset,
tree  exp_type,
gimple_stmt_iterator gsi,
bool  insert_after 
   From tree-sra.c:  
   Construct a MEM_REF that would reference a part of aggregate BASE of type
   EXP_TYPE at the given OFFSET.  If BASE is something for which
   get_addr_base_and_unit_offset returns NULL, gsi must be non-NULL and is used
   to insert new statements either before or below the current one as specified
   by INSERT_AFTER.  This function is not capable of handling bitfields.

   BASE must be either a declaration or a memory reference that has correct
   alignment ifformation embeded in it (e.g. a pre-existing one in SRA).  
     get_addr_base_and_unit_offset returns NULL for references with a variable
     offset such as array[var_index].  
void ipa_analyze_node ( struct cgraph_node )
   Functions related to both.  
tree ipa_binfo_from_known_type_jfunc ( struct ipa_jump_func )
static void ipa_check_create_edge_args ( )
   This function ensures the array of edge arguments infos is big enough to
   accommodate a structure for all edges and reallocates it if not.  

Referenced by ipa_read_node_info(), and try_decrement_rdesc_refcount().

static void ipa_check_create_node_params ( )
   This function ensures the array of node param infos is big enough to
   accommodate a structure for all nodes and reallocates it if not.  

Referenced by ipa_edge_removal_hook(), and ipa_read_node_info().

ipa_parm_adjustment_vec ipa_combine_adjustments ( ipa_parm_adjustment_vec  inner,
ipa_parm_adjustment_vec  outer 
   Return adjustments that should have the same effect on function parameters
   and call arguments as if they were first changed according to adjustments in
   INNER and then by adjustments in OUTER.  
         FIXME:  Create nonlocal value too.  
void ipa_create_all_edge_args ( void  )
void ipa_create_all_node_params ( void  )
   Creating and freeing ipa_node_params and ipa_edge_args.  
void ipa_dump_agg_replacement_values ( FILE *  f,
struct ipa_agg_replacement_value av 
void ipa_dump_param ( FILE *  ,
struct ipa_node_params info,
int  i 
void ipa_dump_param_adjustments ( FILE *  file,
ipa_parm_adjustment_vec  adjustments,
tree  fndecl 
   Dump the adjustments in the vector ADJUSTMENTS to dump_file in a human
   friendly way, assuming they are meant to be applied to FNDECL.  
static bool ipa_edge_args_info_available_for_edge_p ( )
   Returns true if the array of edge infos is large enough to accommodate an
   info for EDGE.  The main purpose of this function is that debug dumping
   function can check info availability without causing reallocations.  
tree ipa_find_agg_cst_for_param ( struct ipa_agg_jump_function agg,
HOST_WIDE_INT  offset,
bool  by_ref 
   Aggregate jump function related functions.  
   Retrieve value from aggregate jump function AGG for the given OFFSET or
   return NULL if there is not any.  BY_REF specifies whether the value has to
   be passed by reference or by value.  
           Currently we do not have clobber values, return NULL for them once
           we do.  

References ipa_jump_func::agg, cgraph_indirect_call_info::agg_contents, cgraph_indirect_call_info::by_ref, cgraph_edge::callee, cgraph_node_for_jfunc(), cgraph_edge::indirect_info, ipa_find_agg_cst_for_param(), IPA_JF_CONST, ipa_make_edge_direct_to_target(), ipa_value_from_jfunc(), cgraph_indirect_call_info::offset, try_decrement_rdesc_refcount(), and ipa_jump_func::type.

Referenced by ipa_find_agg_cst_for_param(), and set_hint_predicate().

void ipa_free_all_node_params ( void  )
   Free all ipa_node_params structures.  
void ipa_free_all_structures_after_iinln ( void  )
   Free all ipa_node_params and all ipa_edge_args structures if they are no
   longer needed after indirect inlining.  

References ipa_parm_adjustment::base, ipa_parm_adjustment::base_index, ipa_parm_adjustment::copy_param, and ipa_parm_adjustment::remove_param.

void ipa_free_all_structures_after_ipa_cp ( void  )
   Free all ipa_node_params and all ipa_edge_args structures if they are no
   longer needed after ipa-cp.  

References get_vector_of_formal_parm_types(), and tree_last().

void ipa_free_edge_args_substructures ( struct ipa_edge_args )
void ipa_free_node_params_substructures ( struct ipa_node_params )
static struct ipa_agg_replacement_value* ipa_get_agg_replacements_for_node ( )
   Return the aggregate replacements for NODE, if there are any.  

Referenced by ipa_edge_removal_hook().

static int ipa_get_controlled_uses ( )
   Return how many uses described by ipa-prop a parameter has or
   IPA_UNDESCRIBED_USE if there is a use that is not described by these

References ipa_edge_args::jump_functions.

Referenced by ipa_node_duplication_hook(), and propagate_effects().

static int ipa_get_cs_argument_count ( )
   ipa_edge_args access functions.  Please use these to access fields that
   are or will be shared among various passes.  
   Return the number of actual arguments. 

References cgraph_node::uid, and vec_safe_length().

Referenced by estimate_ipcp_clone_size_and_time(), ipa_analyze_node(), propagate_aggs_accross_jump_function(), remap_edge_change_prob(), and update_specialized_profile().

tree ipa_get_indirect_edge_target ( struct cgraph_edge ie,
vec< tree known_vals,
vec< tree known_binfos,
vec< ipa_agg_jump_function_p known_aggs 
   Indirect edge and binfo processing.  
   If an indirect edge IE can be turned into a direct one based on KNOWN_VALS
   (which can contain both constants and binfos), KNOWN_BINFOS (which can be
   NULL) or KNOWN_AGGS (which also can be NULL) return the destination.  
static struct ipa_jump_func* ipa_get_ith_jump_func ( )
   Returns a pointer to the jump function for the ith argument.  Please note
   there is no setter function as jump functions are all set up in

Referenced by combine_known_type_and_ancestor_jfs(), copy_plats_to_inter(), estimate_ipcp_clone_size_and_time(), ipa_analyze_node(), ipa_initialize_node_params(), propagate_aggs_accross_jump_function(), remap_edge_change_prob(), and update_specialized_profile().

static bool ipa_get_jf_ancestor_agg_preserved ( )
   Return the agg_preserved flag of an ancestor jump function JFUNC.  

Referenced by remap_edge_change_prob().

static int ipa_get_jf_ancestor_formal_id ( )
   Return the number of the caller's formal parameter that an ancestor jump
   function JFUNC refers to.  

Referenced by remap_edge_change_prob().

static HOST_WIDE_INT ipa_get_jf_ancestor_offset ( )
   Return the offset of an ancestor jump function JFUNC.  

Referenced by remap_edge_change_prob().

static tree ipa_get_jf_ancestor_type ( )
   Return the result type of an ancestor jump function JFUNC.  
static bool ipa_get_jf_ancestor_type_preserved ( )
   Return the type_preserved flag of an ancestor jump function JFUNC.  
static tree ipa_get_jf_constant ( )
static tree ipa_get_jf_known_type_base_type ( )
static tree ipa_get_jf_known_type_component_type ( )
static HOST_WIDE_INT ipa_get_jf_known_type_offset ( )
   Return the offset of the component that is described by a known type jump
   function JFUNC.  

References ipa_jump_func::jump_func_value::constant, IPA_JF_CONST, ipa_constant_data::rdesc, ipa_jump_func::type, and ipa_jump_func::value.

Referenced by combine_known_type_and_ancestor_jfs().

static bool ipa_get_jf_pass_through_agg_preserved ( )
   Return the agg_preserved flag of a pass through jump function JFUNC.  

Referenced by combine_known_type_and_ancestor_jfs(), remap_edge_change_prob(), try_make_edge_direct_virtual_call(), and update_jump_functions_after_inlining().

static int ipa_get_jf_pass_through_formal_id ( )
   Return the number of the caller's formal parameter that a pass through jump
   function JFUNC refers to.  

Referenced by copy_plats_to_inter(), estimate_ipcp_clone_size_and_time(), remap_edge_change_prob(), set_chain_of_aglats_contains_variable(), try_make_edge_direct_virtual_call(), and update_jump_functions_after_inlining().

static tree ipa_get_jf_pass_through_operand ( )
static enum tree_code ipa_get_jf_pass_through_operation ( )
static bool ipa_get_jf_pass_through_type_preserved ( )
   Return the type_preserved flag of a pass through jump function JFUNC.  

Referenced by set_all_contains_variable(), and update_jump_functions_after_inlining().

static tree ipa_get_param ( )
   Return the declaration of Ith formal parameter of the function corresponding
   to INFO.  Note there is no setter function as this array is built just once
   using ipa_initialize_node_params. 
static int ipa_get_param_count ( )
   ipa_node_params access functions.  Please use these to access fields that
   are or will be shared among various passes.  
   Return the number of formal parameters. 

References HOST_WIDE_INT, ipa_agg_replacement_value::index, ipa_agg_replacement_value::next, offset, and ipa_agg_replacement_value::value.

Referenced by propagate_aggs_accross_jump_function(), remap_edge_change_prob(), and update_specialized_profile().

int ipa_get_param_decl_index ( struct ipa_node_params ,
static int ipa_get_param_move_cost ( )
   Return the move cost of Ith formal parameter of the function corresponding
   to INFO.  
vec<tree> ipa_get_vector_of_formal_parms ( tree  fndecl)
void ipa_initialize_node_params ( struct cgraph_node node)
   Function formal parameters related computations.  
tree ipa_intraprocedural_devirtualization ( gimple  )
static bool ipa_is_param_used ( )
   Return the used flag corresponding to the Ith formal parameter of the
   function associated with INFO.  

Referenced by ipa_node_duplication_hook(), and update_profiling_info().

struct cgraph_edge* ipa_make_edge_direct_to_target ( struct cgraph_edge ,
void ipa_modify_call_arguments ( struct cgraph_edge cs,
gimple  stmt,
ipa_parm_adjustment_vec  adjustments 
   Modify actual arguments of a function call CS as indicated in ADJUSTMENTS.
   If this is a directly recursive call, CS must be NULL.  Otherwise it must
   contain the corresponding call graph edge.  
             We create a new parameter out of the value of the old one, we can
             do the following kind of transformations:

             - A scalar passed by reference is converted to a scalar passed by
               value.  (adj->by_ref is false and the type of the original
               actual argument is a pointer to a scalar).

             - A part of an aggregate is passed instead of the whole aggregate.
               The part can be passed either by value or by reference, this is
               determined by value of adj->by_ref.  Moreover, the code below
               handles both situations when the original aggregate is passed by
               value (its type is not a pointer) and when it is passed by
               reference (it is a pointer to an aggregate).

             When the new argument is passed by reference (adj->by_ref is true)
             it must be a part of an aggregate and therefore we form it by
             simply taking the address of a reference inside the original
                 Aggregate arguments can have non-invariant addresses.  

References ipa_parm_adjustment::base, ipa_parm_adjustment::base_index, decl_debug_args_insert(), fold_convert_loc(), fold_convertible_p(), gimple_call_arg(), gimple_location(), gsi_insert_before(), GSI_SAME_STMT, unshare_expr(), useless_type_conversion_p(), vec_safe_iterate(), and vec_safe_push().

void ipa_modify_formal_parameters ( tree  fndecl,
ipa_parm_adjustment_vec  adjustments,
const char *  synth_parm_prefix 
   Modify the function declaration FNDECL and its type according to the plan in
   ADJUSTMENTS.  It also sets base fields of individual adjustments structures
   to reflect the actual parameters being modified which are determined by the
   base_index field.  
     The following test is an ugly hack, some functions simply don't have any
     arguments in their type.  This is probably a bug but well... 
     Use copy_node to preserve as much as possible from original type
     (debug info, attribute lists etc.)
     Exception is METHOD_TYPEs must have THIS argument.
     When we are asked to remove it, we need to build new FUNCTION_TYPE
     When signature changes, we need to clear builtin info.  
     This is a new type, not a copy of an old type.  Need to reassociate
     variants.  We can handle everything except the main variant lazily.  
void ipa_print_all_jump_functions ( FILE *  f)
void ipa_print_all_params ( FILE *  )
void ipa_print_node_jump_functions ( FILE *  f,
struct cgraph_node node 
void ipa_print_node_params ( FILE *  ,
struct cgraph_node node 
   Debugging interface.  
void ipa_prop_read_all_agg_replacement ( void  )
   Read IPA-CP aggregate replacements.  

Referenced by identify_dead_nodes().

void ipa_prop_read_jump_functions ( void  )
   Read ipcp jump functions.  
void ipa_prop_write_jump_functions ( void  )
   Write jump functions for nodes in SET.  
     Process all of the functions.  
bool ipa_propagate_indirect_call_infos ( struct cgraph_edge cs,
vec< cgraph_edge_p > *  new_edges 
   Update jump functions and call note functions on inlining the call site CS.
   CS is expected to lead to a node already cloned by
   cgraph_clone_inline_nodes.  Newly discovered indirect edges will be added to
   *NEW_EDGES, unless NEW_EDGES is NULL.  Return true iff a new edge(s) were +
     Do nothing if the preparation phase has not been carried out yet
     (i.e. during early inlining).  
void ipa_register_cgraph_hooks ( void  )
   Register our cgraph hooks if they are not already there.  

Referenced by spread_undeadness().

static void ipa_set_controlled_uses ( )
   Set the controlled counter of a given parameter.  

Referenced by propagate_effects().

void ipa_set_node_agg_value_chain ( struct cgraph_node node,
struct ipa_agg_replacement_value aggvals 
   Set the aggregate replacements of NODE to be AGGVALS.  

Referenced by ipa_edge_removal_hook().

static void ipa_set_param_used ( )
   Set the used flag corresponding to the Ith formal parameter of the function
   associated with INFO to VAL.  

References ipa_edge_args::jump_functions, and vec_safe_length().

Referenced by ipa_analyze_call_uses(), and ipa_analyze_virtual_call_uses().

void ipa_update_after_lto_read ( void  )
   After merging units, we can get mismatch in argument counts.
   Also decl merging might've rendered parameter lists obsolete.
   Also compute called_with_variable_arg info.  
tree ipa_value_from_jfunc ( struct ipa_node_params info,
struct ipa_jump_func jfunc 
unsigned int ipcp_transform_function ( struct cgraph_node node)
void ipcp_verify_propagated_values ( void  )
   If checking is enabled, verify that no lattice is in the TOP state, i.e. not
   bottom, not containing a variable component and without any known value at
   the same time.  

Variable Documentation

vec<ipa_edge_args_t, va_gc>* ipa_edge_args_vector
   Vector where the parameter infos are actually stored. 
vec<ipa_agg_replacement_value_p, va_gc>* ipa_node_agg_replacements
   Vector of known aggregate values in cloned nodes.  
vec<ipa_node_params_t> ipa_node_params_vector
   Types of vectors holding the infos.  
   Vector where the parameter infos are actually stored. 
   Vector where the parameter infos are actually stored. 

Referenced by estimate_ipcp_clone_size_and_time(), and inline_node_removal_hook().

alloc_pool ipcp_agg_lattice_pool
alloc_pool ipcp_sources_pool
alloc_pool ipcp_values_pool
   Allocation pools for values and their sources in ipa-cp.