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

Typedefs

typedef struct ipa_agg_jf_item ipa_agg_jf_item_t
typedef struct
ipa_agg_jump_function
ipa_agg_jump_function_p
typedef struct
ipa_agg_jump_function 
ipa_agg_jump_function_t
typedef struct ipa_jump_func ipa_jump_func_t
typedef struct ipa_param_descriptor ipa_param_descriptor_t
typedef struct
ipa_agg_replacement_value
ipa_agg_replacement_value_p
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
ipa_parm_adjustment_vec

Enumerations

enum  jump_func_type {
  IPA_JF_UNKNOWN = 0, IPA_JF_KNOWN_TYPE, IPA_JF_CONST, IPA_JF_PASS_THROUGH,
  IPA_JF_ANCESTOR
}

Functions

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

Variables

vec< ipa_node_params_tipa_node_params_vector
vec
< ipa_agg_replacement_value_p,
va_gc > * 
ipa_node_agg_replacements
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
                  argument.
   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.   
Enumerator:
IPA_JF_UNKNOWN 
IPA_JF_KNOWN_TYPE 
IPA_JF_CONST 
IPA_JF_PASS_THROUGH 
IPA_JF_ANCESTOR 

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

References build_aligned_type(), build_int_cst(), build_pointer_type(), get_addr_base_and_unit_offset(), get_object_alignment_1(), gimple_set_location(), gsi_insert_after(), gsi_insert_before(), GSI_NEW_STMT, GSI_SAME_STMT, HOST_WIDE_INT, int_const_binop(), make_ssa_name(), offset, reference_alias_ptr_type(), and unshare_expr().

Referenced by analyze_access_subtree(), build_ref_for_model(), and ipa_get_jf_ancestor_result().

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 ( )
inlinestatic
This function ensures the array of edge arguments infos is big enough to
   accommodate a structure for all edges and reallocates it if not.   

References cgraph_edge_max_uid, vec_safe_grow_cleared(), and vec_safe_length().

Referenced by ipa_analyze_node(), ipa_edge_duplication_hook(), ipa_prop_read_jump_functions(), ipa_update_after_lto_read(), ipcp_driver(), and update_indirect_edges_after_inlining().

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

References cgraph_max_uid, and ipa_node_params_vector.

Referenced by ipa_analyze_node(), ipa_make_edge_direct_to_target(), ipa_node_duplication_hook(), ipa_prop_read_jump_functions(), ipa_update_after_lto_read(), and ipcp_driver().

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.   

References ipa_parm_adjustment::base_index, ipa_parm_adjustment::copy_param, index_in_adjustments_multiple_times_p(), memset(), ipa_parm_adjustment::offset, ipa_parm_adjustment::remove_param, and ipa_parm_adjustment::type.

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 
)
static bool ipa_edge_args_info_available_for_edge_p ( )
inlinestatic
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.   

References cgraph_edge::uid, and vec_safe_length().

Referenced by ipa_print_node_jump_functions().

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.   

References ipa_agg_jump_function::by_ref, is_gimple_ip_invariant(), ipa_agg_jump_function::items, ipa_agg_jf_item::offset, and ipa_agg_jf_item::value.

Referenced by evaluate_conditions_for_known_args(), ipa_get_indirect_edge_target_1(), and try_make_edge_direct_simple_call().

void ipa_free_all_edge_args ( void  )
void ipa_free_all_node_params ( void  )
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 free_alloc_pool(), ipa_free_all_edge_args(), ipa_free_all_node_params(), ipa_unregister_cgraph_hooks(), ipcp_agg_lattice_pool, ipcp_sources_pool, and ipcp_values_pool.

Referenced by ipa_inline().

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 free_alloc_pool(), ipa_free_all_edge_args(), ipa_free_all_node_params(), ipa_unregister_cgraph_hooks(), ipcp_agg_lattice_pool, ipcp_sources_pool, and ipcp_values_pool.

Referenced by ipcp_driver().

void ipa_free_edge_args_substructures ( struct ipa_edge_args )
void ipa_free_node_params_substructures ( struct ipa_node_params )
static int ipa_get_controlled_uses ( )
inlinestatic
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
   structures.   

References ipa_node_params::descriptors.

Referenced by ipa_print_node_params(), ipa_write_node_info(), ipcp_discover_new_direct_edges(), and propagate_controlled_uses().

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.   

References ipa_get_indirect_edge_target_1().

Referenced by devirtualization_time_bonus(), and estimate_edge_devirt_benefit().

static int ipa_get_jf_ancestor_formal_id ( )
inlinestatic
static tree ipa_get_jf_ancestor_type ( )
inlinestatic
static tree ipa_get_jf_constant ( )
inlinestatic
static tree ipa_get_jf_known_type_base_type ( )
inlinestatic
static tree ipa_get_jf_known_type_component_type ( )
inlinestatic
Return the component type of a known type jump function JFUNC.   

References ipa_known_type_data::component_type, IPA_JF_KNOWN_TYPE, ipa_jump_func::jump_func_value::known_type, ipa_jump_func::type, and ipa_jump_func::value.

static HOST_WIDE_INT ipa_get_jf_known_type_offset ( )
inlinestatic
Return the offset of the component that is described by a known type jump
   function JFUNC.   

References IPA_JF_KNOWN_TYPE.

Referenced by combine_known_type_and_ancestor_jfs().

static bool ipa_get_jf_pass_through_agg_preserved ( )
inlinestatic
static tree ipa_get_jf_pass_through_operand ( )
inlinestatic
static tree ipa_get_param ( )
inlinestatic
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.  

References ipa_node_params::descriptors.

Referenced by inline_node_duplication_hook(), and ipa_analyze_params_uses().

int ipa_get_param_decl_index ( struct ipa_node_params ,
tree   
)
static int ipa_get_param_move_cost ( )
inlinestatic
Return the move cost of Ith formal parameter of the function corresponding
   to INFO.   

References ipa_node_params::descriptors.

Referenced by gather_context_independent_values(), and ipa_write_node_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 ( )
inlinestatic
Return the used flag corresponding to the Ith formal parameter of the
   function associated with INFO.   

References ipa_node_params::descriptors.

Referenced by create_specialized_node(), gather_context_independent_values(), ipa_print_node_params(), and ipa_write_node_info().

bool ipa_load_from_parm_agg ( struct ipa_node_params info,
gimple  stmt,
tree  op,
int *  index_p,
HOST_WIDE_INT offset_p,
bool *  by_ref_p 
)
Just like the previous function, just without the param_analysis_info
   pointer, for users outside of this file.   

References ipa_node_params::descriptors, and ipa_load_from_parm_agg_1().

Referenced by unmodified_parm_or_parm_agg_item().

struct cgraph_edge* ipa_make_edge_direct_to_target ( struct cgraph_edge ,
tree   
)
read
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.   

References ipa_parm_adjustment::alias_ptr_type, ipa_parm_adjustment::base, ipa_parm_adjustment::base_index, build_aligned_type(), build_int_cst(), ipa_parm_adjustment::by_ref, cgraph_edge::callee, CDI_DOMINATORS, cgraph_get_node(), cgraph_set_call_stmt(), ipa_parm_adjustment::copy_param, current_function_decl, symtab_node_base::decl, decl_debug_args_insert(), dump_file, dump_flags, fold_convert_loc(), fold_convertible_p(), force_gimple_operand_gsi(), free_dominance_info(), get_addr_base_and_unit_offset(), get_pointer_alignment_1(), gimple_block(), gimple_build_call_vec(), gimple_call_arg(), gimple_call_chain(), gimple_call_copy_flags(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_set_chain(), gimple_call_set_lhs(), gimple_has_location(), gimple_location(), gimple_set_block(), gimple_set_location(), gsi_end_p(), gsi_for_stmt(), gsi_insert_before(), gsi_prev(), gsi_replace(), GSI_SAME_STMT, gsi_stmt(), HOST_WIDE_INT, int_const_binop(), ipa_record_stmt_references(), ipa_remove_stmt_references(), is_gimple_reg_type(), len, double_int::low, ipa_parm_adjustment::offset, print_gimple_stmt(), ipa_parm_adjustment::remove_param, double_int::sext(), cgraph_node::symbol, tree_to_double_int(), ipa_parm_adjustment::type, unshare_expr(), update_ssa(), useless_type_conversion_p(), vec_safe_iterate(), and vec_safe_push().

Referenced by convert_callers(), and convert_callers_for_node().

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.   

References ipa_parm_adjustment::base, ipa_parm_adjustment::base_index, build_distinct_type_copy(), build_function_type(), build_pointer_type(), ipa_parm_adjustment::by_ref, ipa_parm_adjustment::copy_param, create_tmp_var_name(), get_vector_of_formal_parm_types(), ipa_get_vector_of_formal_parms(), layout_decl(), len, NOT_BUILT_IN, nreverse(), ipa_parm_adjustment::reduction, ipa_parm_adjustment::remove_param, tree_last(), and ipa_parm_adjustment::type.

Referenced by modify_function().

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  )
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 +
   created.   

References cgraph_edge::callee, changed, propagate_controlled_uses(), and propagate_info_to_inlined_callees().

Referenced by inline_call().

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

References ipa_node_params::descriptors.

Referenced by ipa_analyze_params_uses(), ipa_read_node_info(), ipcp_discover_new_direct_edges(), and propagate_controlled_uses().

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.   

References cgraph_max_uid, cgraph_node::uid, vec_safe_grow_cleared(), and vec_safe_length().

Referenced by create_specialized_node(), ipa_node_duplication_hook(), and read_agg_replacement_chain().

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

References ipa_node_params::descriptors.

Referenced by ipa_analyze_params_uses(), ipa_read_node_info(), and visit_ref_for_mod_analysis().

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.   

References ipa_check_create_edge_args(), and ipa_check_create_node_params().

Referenced by ipa_inline(), and ipcp_propagate_stage().

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.   

References ipcp_lattice::bottom, ipcp_lattice::contains_variable, count, dump_file, ipa_get_param_count(), ipa_get_scalar_lat(), print_all_lattices(), and ipcp_lattice::values_count.

Referenced by ipcp_propagate_stage().


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 create_specialized_node(), early_inliner(), estimate_function_body_sizes(), evaluate_properties_for_edge(), inline_merge_summary(), inline_node_duplication_hook(), ipa_check_create_node_params(), and remap_edge_change_prob().

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

Referenced by ipa_free_all_structures_after_iinln(), and ipa_free_all_structures_after_ipa_cp().