GCC Middle and Back End API 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 } |
typedef struct ipa_agg_jf_item ipa_agg_jf_item_t |
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.
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_agg_replacement_value* ipa_agg_replacement_value_p |
typedef struct ipa_edge_args ipa_edge_args_t |
ipa_edge_args stores information related to a callsite and particularly its arguments. It can be accessed by the IPA_EDGE_REF macro.
typedef struct ipa_jump_func ipa_jump_func_t |
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.
typedef struct ipa_node_params ipa_node_params_t |
Vectors need to have typedefs of structures.
typedef struct ipa_param_descriptor ipa_param_descriptor_t |
typedef struct ipa_parm_adjustment ipa_parm_adjustment_t |
enum jump_func_type |
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.
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 * | ) |
|
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.
Referenced by ipa_read_node_info(), and try_decrement_rdesc_refcount().
|
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.
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.
|
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.
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_edge_args | ( | void | ) |
Free all ipa_edge structures.
References cgraph_edge::call_stmt, cgraph_edge::caller, cgraph_node_for_jfunc(), ipa_jump_func::jump_func_value::constant, ipa_cst_ref_desc::cs, ipa_clone_ref(), ipa_find_reference(), cgraph_edge::lto_stmt_uid, ipa_cst_ref_desc::next_duplicate, pool_alloc(), ipa_constant_data::rdesc, ipa_cst_ref_desc::refcount, ipa_ref::stmt, and ipa_jump_func::value.
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 * | ) |
|
staticread |
Return the aggregate replacements for NODE, if there are any.
Referenced by ipa_edge_removal_hook().
|
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_edge_args::jump_functions.
Referenced by ipa_node_duplication_hook(), and propagate_effects().
|
inlinestatic |
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.
|
staticread |
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 ipa_compute_jump_functions.
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().
|
inlinestatic |
Return the agg_preserved flag of an ancestor jump function JFUNC.
Referenced by remap_edge_change_prob().
|
inlinestatic |
Return the number of the caller's formal parameter that an ancestor jump function JFUNC refers to.
Referenced by remap_edge_change_prob().
|
inlinestatic |
Return the offset of an ancestor jump function JFUNC.
Referenced by remap_edge_change_prob().
|
inlinestatic |
Return the result type of an ancestor jump function JFUNC.
|
inlinestatic |
Return the type_preserved flag of an ancestor jump function JFUNC.
|
inlinestatic |
Return the constant stored in a constant jump functin JFUNC.
References IPA_JF_PASS_THROUGH, ipa_pass_through_data::operation, ipa_jump_func::jump_func_value::pass_through, ipa_jump_func::type, and ipa_jump_func::value.
|
staticread |
|
inlinestatic |
Return the base type of a known type jump function JFUNC.
References IPA_JF_PASS_THROUGH, ipa_pass_through_data::operand, ipa_jump_func::jump_func_value::pass_through, ipa_jump_func::type, and ipa_jump_func::value.
Referenced by combine_known_type_and_ancestor_jfs().
|
inlinestatic |
Return the component type of a known type jump function JFUNC.
References ipa_pass_through_data::formal_id, IPA_JF_PASS_THROUGH, ipa_jump_func::jump_func_value::pass_through, ipa_jump_func::type, and ipa_jump_func::value.
|
inlinestatic |
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().
|
inlinestatic |
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().
|
inlinestatic |
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().
|
inlinestatic |
Return the operand of a pass through jmp function JFUNC.
References IPA_JF_PASS_THROUGH, ipa_jump_func::jump_func_value::pass_through, ipa_jump_func::type, ipa_pass_through_data::type_preserved, and ipa_jump_func::value.
Referenced by update_jump_functions_after_inlining().
|
inlinestatic |
Return operation of a pass through jump function JFUNC.
Referenced by add_value_to_lattice(), copy_plats_to_inter(), remap_edge_change_prob(), set_all_contains_variable(), set_chain_of_aglats_contains_variable(), and update_jump_functions_after_inlining().
|
inlinestatic |
Return the type_preserved flag of a pass through jump function JFUNC.
Referenced by set_all_contains_variable(), and update_jump_functions_after_inlining().
|
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.
|
inlinestatic |
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 * | , |
tree | |||
) |
|
inlinestatic |
Return the move cost of Ith formal parameter of the function corresponding to INFO.
void ipa_initialize_node_params | ( | struct cgraph_node * | node | ) |
Function formal parameters related computations.
|
inlinestatic |
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().
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, detect_type_change_ssa(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_single_p(), gimple_expr_code(), HOST_WIDE_INT, ipa_get_param_decl_index(), IPA_JF_UNKNOWN, ipa_set_jf_arith_pass_through(), ipa_set_jf_simple_pass_through(), is_gimple_ip_invariant(), load_from_unmodified_param(), offset, parm_ref_data_pass_through_p(), tcc_comparison, ipa_jump_func::type, and useless_type_conversion_p().
|
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.
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.
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 instead.
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_all_agg_replacement | ( | void | ) |
Write all aggregate replacement for nodes in set.
References ipa_agg_replacement_value::by_ref, gimple_assign_load_p(), gimple_assign_rhs1(), gsi_stmt(), handled_component_p(), HOST_WIDE_INT, ipa_agg_replacement_value::index, ipa_load_from_parm_agg_1(), is_gimple_ip_invariant(), is_gimple_reg_type(), ipa_agg_replacement_value::next, ipa_agg_replacement_value::offset, offset, and ipa_agg_replacement_value::value.
Referenced by identify_dead_nodes().
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 + created.
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().
|
inlinestatic |
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().
|
inlinestatic |
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.
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.