GCC Middle and Back End API Reference
|
#include <ipa-icf-gimple.h>
Public Types | |
enum | operand_access_type { OP_MEMORY , OP_NORMAL } |
typedef hash_set< tree > | operand_access_type_map |
Static Public Member Functions | |
static bool | compatible_polymorphic_types_p (tree t1, tree t2, bool compare_ptr) |
static bool | compatible_types_p (tree t1, tree t2) |
static void | classify_operands (const gimple *stmt, operand_access_type_map *map) |
static operand_access_type | get_operand_access_type (operand_access_type_map *map, tree) |
Private Types | |
enum | ao_ref_diff { SEMANTICS = 1 , BASE_ALIAS_SET = 2 , REF_ALIAS_SET = 4 , ACCESS_PATH = 8 , DEPENDENCE_CLIQUE = 16 } |
Private Member Functions | |
int | compare_ao_refs (ao_ref *ref1, ao_ref *ref2, bool lto_streaming_safe, bool tbaa) |
void | hash_ao_ref (ao_ref *ref, bool lto_streaming_safe, bool tbaa, inchash::hash &hstate) |
bool | verify_hash_value (const_tree arg0, const_tree arg1, unsigned int flags, bool *ret) |
Private Attributes | |
vec< int > | m_source_ssa_names |
vec< int > | m_target_ssa_names |
tree | m_source_func_decl |
tree | m_target_func_decl |
hash_set< symtab_node * > * | m_ignored_source_nodes |
hash_set< symtab_node * > * | m_ignored_target_nodes |
hash_map< edge, edge > | m_edge_map |
hash_map< const_tree, const_tree > | m_decl_map |
hash_map< const_tree, int > | m_label_bb_map |
bool | m_ignore_labels |
bool | m_tbaa |
bool | m_total_scalarization_limit_known_p |
unsigned HOST_WIDE_INT | m_total_scalarization_limit |
A class aggregating all connections and semantic equivalents for a given pair of semantic function candidates.
|
inherited |
|
inline |
References m_source_ssa_names, and m_target_ssa_names.
ipa_icf_gimple::func_checker::func_checker | ( | tree | source_func_decl, |
tree | target_func_decl, | ||
bool | ignore_labels = false, | ||
bool | tbaa = true, | ||
hash_set< symtab_node * > * | ignored_source_nodes = NULL, | ||
hash_set< symtab_node * > * | ignored_target_nodes = NULL ) |
Initialize internal structures for a given SOURCE_FUNC_DECL and TARGET_FUNC_DECL. Strict polymorphic comparison is processed if an option COMPARE_POLYMORPHIC is true. For special cases, one can set IGNORE_LABELS to skip label comparison. Similarly, IGNORE_SOURCE_DECLS and IGNORE_TARGET_DECLS are sets of declarations that can be skipped.
References DECL_STRUCT_FUNCTION, i, m_source_ssa_names, m_target_ssa_names, and SSANAMES.
|
virtual |
Memory release routine.
References m_source_ssa_names, and m_target_ssa_names.
|
static |
Compute hash map determining access types of operands.
References map, ipa_icf_gimple::visit_load_store(), and walk_stmt_load_store_ops().
Referenced by compare_gimple_asm(), compare_gimple_assign(), compare_gimple_call(), and ipa_icf::sem_function::hash_stmt().
|
inherited |
Compare REF1 and REF2 and return flags specifying their differences. If LTO_STREAMING_SAFE is true do not use alias sets and canonical types that are going to be recomputed. If TBAA is true also compare TBAA metadata.
References ao_compare::ACCESS_PATH, alias_ptr_types_compatible_p(), ao_ref_alias_ptr_type(), ao_ref_alias_set(), ao_ref_base(), ao_ref_base_alias_ptr_type(), ao_ref_base_alias_set(), ao_compare::BASE_ALIAS_SET, component_ref_to_zero_sized_trailing_array_p(), DECL_BIT_FIELD, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_SIZE, ao_compare::DEPENDENCE_CLIQUE, ends_tbaa_access_path_p(), get_object_alignment_1(), get_ref_base_and_extent(), handled_component_p(), i, known_eq, ao_ref::max_size, MR_DEPENDENCE_BASE, MR_DEPENDENCE_CLIQUE, NULL, OEP_ADDRESS_OF, OEP_MATCH_SIDE_EFFECTS, ao_ref::offset, operand_compare::operand_equal_p(), ao_ref::ref, ao_compare::REF_ALIAS_SET, same_type_for_tbaa(), ao_compare::SEMANTICS, ao_ref::size, TREE_CODE, TREE_OPERAND, TREE_THIS_VOLATILE, TREE_TYPE, TYPE_SIZE, types_compatible_p(), types_equal_for_same_type_for_tbaa_p(), and view_converted_memref_p().
Referenced by compare_operand().
bool ipa_icf_gimple::func_checker::compare_asm_inputs_outputs | ( | tree | t1, |
tree | t2, | ||
operand_access_type_map * | map ) |
References compare_operand(), gcc_assert, get_operand_access_type(), map, return_false, TREE_CHAIN, TREE_CODE, TREE_PURPOSE, TREE_STRING_POINTER, and TREE_VALUE.
Referenced by compare_gimple_asm().
Basic block equivalence comparison function that returns true if basic blocks BB1 and BB2 (from functions FUNC1 and FUNC2) correspond. In general, a collection of equivalence dictionaries is built for types like SSA names, declarations (VAR_DECL, PARM_DECL, ..). This infrastructure is utilized by every statement-by-statement comparison function.
References as_a(), ipa_icf_gimple::sem_bb::bb, compare_gimple_asm(), compare_gimple_assign(), compare_gimple_call(), compare_gimple_cond(), compare_gimple_goto(), compare_gimple_label(), compare_gimple_resx(), compare_gimple_return(), compare_gimple_switch(), compare_loops(), DECL_STRUCT_FUNCTION, gimple_eh_dispatch_region(), gsi_end_p(), gsi_next_nondebug(), gsi_start_nondebug_bb(), gsi_stmt(), lookup_stmt_eh_lp_fn(), m_source_func_decl, m_target_func_decl, return_different_stmts, return_false, and return_false_with_msg.
Referenced by ipa_icf::sem_function::equals_private().
bool ipa_icf_gimple::func_checker::compare_decl | ( | const_tree | t1, |
const_tree | t2 ) |
Verification function for declaration trees T1 and T2 that come from functions FUNC1 and FUNC2.
References auto_var_in_fn_p(), compatible_types_p(), DECL_BY_REFERENCE, DECL_SIZE, hash_map< KeyId, Value, Traits >::get_or_insert(), m_decl_map, m_source_func_decl, m_target_func_decl, OEP_MATCH_SIDE_EFFECTS, operand_equal_p(), return_false, return_false_with_msg, return_with_debug, TREE_CODE, and TREE_TYPE.
Referenced by compare_variable_decl(), ipa_icf::sem_function::equals_private(), and operand_equal_p().
Verification function for edges E1 and E2.
References hash_map< KeyId, Value, Traits >::get_or_insert(), m_edge_map, and return_with_debug.
Referenced by ipa_icf::sem_function::compare_phi_node(), and ipa_icf::sem_function::equals_private().
Verifies for given GIMPLEs S1 and S2 that ASM statements are equivalent. For the beginning, the pass only supports equality for '__asm__ __volatile__ ("", "", "", "memory")'.
References classify_operands(), compare_asm_inputs_outputs(), gimple_asm_basic_p(), gimple_asm_clobber_op(), gimple_asm_inline_p(), gimple_asm_input_op(), gimple_asm_nclobbers(), gimple_asm_ninputs(), gimple_asm_nlabels(), gimple_asm_noutputs(), gimple_asm_output_op(), gimple_asm_string(), gimple_asm_volatile_p(), i, map, OEP_ONLY_CONST, operand_equal_p(), return_false_with_msg, and TREE_VALUE.
Referenced by compare_bb().
Verifies for given GIMPLEs S1 and S2 that assignment statements are semantically equivalent.
References classify_operands(), compare_operand(), compatible_types_p(), get_operand_access_type(), gimple_assign_rhs_code(), gimple_num_ops(), gimple_op(), gimple_store_p(), i, map, return_false_with_msg, and TREE_TYPE.
Referenced by compare_bb().
Verifies for given GIMPLEs S1 and S2 that call statements are semantically equivalent.
References classify_operands(), comp_type_attributes(), compare_operand(), compatible_types_p(), cgraph_node::get(), cgraph_node::get_edge(), get_operand_access_type(), gimple_call_alloca_for_var_p(), gimple_call_arg(), gimple_call_chain(), gimple_call_ctrl_altering_p(), gimple_call_fn(), gimple_call_fndecl(), gimple_call_fntype(), gimple_call_from_new_or_delete(), gimple_call_from_thunk_p(), gimple_call_internal_fn(), gimple_call_internal_p(), gimple_call_num_args(), gimple_call_return_slot_opt_p(), gimple_call_tail_p(), gimple_call_va_arg_pack_p(), gimple_get_lhs(), i, ipa_edge_args_sum, ipa_get_cs_argument_count(), ipa_get_ith_jump_func(), ipa_jump_functions_equivalent_p(), m_source_func_decl, m_target_func_decl, map, return_false, return_false_with_msg, TREE_TYPE, and types_compatible_p().
Referenced by compare_bb().
Verifies for given GIMPLEs S1 and S2 that condition statements are semantically equivalent.
References compare_operand(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), and OP_NORMAL.
Referenced by compare_bb().
Verifies for given GIMPLEs S1 and S2 that goto statements are semantically equivalent.
References compare_operand(), gimple_goto_dest(), OP_NORMAL, and TREE_CODE.
Referenced by compare_bb().
Verifies for given GIMPLE_LABEL stmts S1 and S2 that label statements are semantically equivalent.
References FORCED_LABEL, gimple_label_label(), m_ignore_labels, and return_false_with_msg.
Referenced by compare_bb().
Verifies for given GIMPLE_RESX stmts S1 and S2 that resx statements are semantically equivalent.
References gimple_resx_region().
Referenced by compare_bb().
Verifies for given GIMPLE_RETURN stmts S1 and S2 that return statements are semantically equivalent.
References compare_operand(), get_operand_access_type(), gimple_return_retval(), map, and NULL.
Referenced by compare_bb().
Verifies for given GIMPLE_SWITCH stmts S1 and S2 that switch statements are semantically equivalent.
References CASE_HIGH, CASE_LABEL, CASE_LOW, compare_operand(), gimple_switch_index(), gimple_switch_label(), gimple_switch_num_labels(), i, OP_NORMAL, return_false_with_msg, TREE_CODE, and tree_int_cst_equal().
Referenced by compare_bb().
bool ipa_icf_gimple::func_checker::compare_loops | ( | basic_block | bb1, |
basic_block | bb2 ) |
Compare loop information for basic blocks BB1 and BB2.
References loop::any_upper_bound, loop::can_be_parallel, compare_variable_decl(), loop::dont_vectorize, loop::finite_p, loop::force_vectorize, loop::header, loop::latch, basic_block_def::loop_father, loop::nb_iterations_upper_bound, NULL, return_false, return_false_with_msg, loop::safelen, loop::simdlen, loop::simduid, and loop::unroll.
Referenced by compare_bb().
bool ipa_icf_gimple::func_checker::compare_operand | ( | tree | t1, |
tree | t2, | ||
operand_access_type | access ) |
Function responsible for comparison of various operands T1 and T2 which are accessed as ACCESS. If these components, from functions FUNC1 and FUNC2, are equal, true is returned.
References ao_compare::ACCESS_PATH, ao_ref_init(), ao_compare::BASE_ALIAS_SET, ao_compare::compare_ao_refs(), ao_compare::DEPENDENCE_CLIQUE, gcc_unreachable, lto_streaming_expected_p(), m_tbaa, OEP_MATCH_SIDE_EFFECTS, OP_MEMORY, operand_equal_p(), ao_compare::REF_ALIAS_SET, return_false_with_msg, safe_for_total_scalarization_p(), and ao_compare::SEMANTICS.
Referenced by compare_asm_inputs_outputs(), compare_gimple_assign(), compare_gimple_call(), compare_gimple_cond(), compare_gimple_goto(), compare_gimple_return(), compare_gimple_switch(), ipa_icf::sem_function::compare_phi_node(), and compare_ssa_name().
bool ipa_icf_gimple::func_checker::compare_ssa_name | ( | const_tree | t1, |
const_tree | t2 ) |
Verifies that trees T1 and T2 are equivalent from perspective of ICF.
References compare_operand(), gcc_assert, i1, i2, m_source_ssa_names, m_target_ssa_names, OP_NORMAL, SSA_NAME_IS_DEFAULT_DEF, SSA_NAME_VAR, SSA_NAME_VERSION, and TREE_CODE.
Referenced by operand_equal_p().
bool ipa_icf_gimple::func_checker::compare_variable_decl | ( | const_tree | t1, |
const_tree | t2 ) |
Verifies that trees T1 and T2 do correspond.
References compare_decl(), DECL_ALIGN, DECL_ASSEMBLER_NAME_RAW, DECL_HARD_REGISTER, decl_in_symtab_p(), return_false_with_msg, and return_with_debug.
Referenced by compare_loops(), and operand_equal_p().
|
static |
Return true if T1 and T2 are same for purposes of ipa-polymorphic-call analysis. COMPARE_PTR indicates if types of pointers needs to be considered.
References compare_ptr(), compatible_polymorphic_types_p(), contains_polymorphic_type_p(), gcc_assert, POINTER_TYPE_P, return_false_with_msg, TREE_CODE, TREE_TYPE, and types_must_be_same_for_odr().
Referenced by compatible_polymorphic_types_p(), and ipa_icf::sem_function::equals_wpa().
Return true if types are compatible from perspective of ICF.
References return_false_with_msg, TREE_CODE, TYPE_RESTRICT, and types_compatible_p().
Referenced by compare_decl(), compare_gimple_assign(), compare_gimple_call(), ipa_icf::sem_function::compatible_parm_types_p(), ipa_icf::sem_variable::equals(), ipa_icf::sem_variable::equals(), and ipa_icf::sem_function::equals_wpa().
|
static |
Return access type of a given operand.
References map, OP_MEMORY, and OP_NORMAL.
Referenced by compare_asm_inputs_outputs(), compare_gimple_assign(), compare_gimple_call(), compare_gimple_return(), and ipa_icf::sem_function::hash_stmt().
|
inherited |
Hash REF to HSTATE. If LTO_STREAMING_SAFE do not use alias sets and canonical types.
References inchash::hash::add_int(), inchash::hash::add_poly_int(), ao_ref_alias_set(), ao_ref_base(), ao_ref_base_alias_set(), DECL_BIT_FIELD, DECL_FIELD_BIT_OFFSET, DECL_FIELD_OFFSET, DECL_SIZE, operand_compare::hash_operand(), known_eq, ao_ref::max_size, OEP_ADDRESS_OF, OEP_MATCH_SIDE_EFFECTS, ao_ref::offset, r, ao_ref::ref, ao_ref::size, TREE_CODE, TREE_OPERAND, TREE_TYPE, and TYPE_SIZE.
|
finaloverridevirtual |
Generate a hash value for an expression. This can be used iteratively by passing a previous result as the HSTATE argument.
Reimplemented from operand_compare.
Referenced by ipa_icf::sem_function::hash_stmt(), ipa_icf::sem_function::init(), and ipa_icf::sem_variable::init().
void ipa_icf_gimple::func_checker::hash_operand | ( | const_tree | , |
inchash::hash & | , | ||
unsigned | flags, | ||
operand_access_type | access ) |
|
finaloverridevirtual |
Return nonzero if two operands (typically of the same tree node) are necessarily equal. FLAGS modifies behavior as follows: If OEP_ONLY_CONST is set, only return nonzero for constants. This function tests whether the operands are indistinguishable; it does not test whether they are equal using C's == operation. The distinction is important for IEEE floating point, because (1) -0.0 and 0.0 are distinguishable, but -0.0==0.0, and (2) two NaNs may be indistinguishable, but NaN!=NaN. If OEP_ONLY_CONST is unset, a VAR_DECL is considered equal to itself even though it may hold multiple values during a function. This is because a GCC tree node guarantees that nothing else is executed between the evaluation of its "operands" (which may often be evaluated in arbitrary order). Hence if the operands themselves don't side-effect, the VAR_DECLs, PARM_DECLs etc... must hold the same value in each operand/subexpression. Hence leaving OEP_ONLY_CONST unset means assuming isochronic (or instantaneous) tree equivalence. Unless comparing arbitrary expression trees, such as from different statements, this flag can usually be left unset. If OEP_PURE_SAME is set, then pure functions with identical arguments are considered the same. It is used when the caller has other ways to ensure that global memory is unchanged in between. If OEP_ADDRESS_OF is set, we are actually comparing addresses of objects, not values of expressions. If OEP_LEXICOGRAPHIC is set, then also handle expressions with side-effects such as MODIFY_EXPR, RETURN_EXPR, as well as STATEMENT_LISTs. If OEP_BITWISE is set, then require the values to be bitwise identical rather than simply numerically equal. Do not take advantage of things like math-related flags or undefined behavior; only return true for values that are provably bitwise identical in all circumstances. If OEP_ASSUME_WRAPV is set, then require the values to be bitwise identical under two's compliment arithmetic (ignoring any possible Undefined Behaviour) rather than just numerically equivalent. The compared expressions must however perform the same operations but may do intermediate computations in differing signs. Because this comparison ignores any possible UB it cannot be used blindly without ensuring that the context you are using it in itself doesn't guarantee that there will be no UB. Conditional expressions are excluded from this relaxation. When OEP_ASSUME_WRAPV is used operand_compare::hash_operand may return differing hashes even for cases where operand_compare::operand_equal_p compares equal. Unless OEP_MATCH_SIDE_EFFECTS is set, the function returns false on any operand with side effect. This is unnecesarily conservative in the case we know that arg0 and arg1 are in disjoint code paths (such as in ?: operator). In addition OEP_MATCH_SIDE_EFFECTS is used when comparing addresses with TREE_CONSTANT flag set so we know that &var == &var even if var is volatile.
Reimplemented from operand_compare.
References compare_decl(), compare_ssa_name(), compare_variable_decl(), hash_map< KeyId, Value, Traits >::get(), m_label_bb_map, NULL, operand_compare::operand_equal_p(), r, return_false, return_with_debug, TREE_CLOBBER_P, TREE_CODE, and operand_compare::verify_hash_value().
Referenced by compare_decl(), compare_gimple_asm(), and compare_operand().
void ipa_icf_gimple::func_checker::parse_labels | ( | sem_bb * | bb | ) |
Function visits all gimple labels and creates corresponding mapping between basic blocks and labels.
References ipa_icf_gimple::sem_bb::bb, dyn_cast(), gcc_assert, gimple_label_label(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), basic_block_def::index, m_label_bb_map, hash_map< KeyId, Value, Traits >::put(), and TREE_CODE.
Referenced by ipa_icf::sem_function::equals_private().
Return true if either T1 and T2 cannot be totally scalarized or if doing so would result in copying the same memory. Otherwise return false.
References AGGREGATE_TYPE_P, DECL_STRUCT_FUNCTION, gcc_assert, m_target_func_decl, m_total_scalarization_limit, m_total_scalarization_limit_known_p, pop_cfun(), push_cfun(), sra_get_max_scalarization_size(), sra_total_scalarization_would_copy_same_data_p(), tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, and TYPE_SIZE.
Referenced by compare_operand().
|
protectedinherited |
References inchash::hash::end(), gcc_assert, operand_compare::hash_operand(), OEP_ASSUME_WRAPV, OEP_DECL_NAME, OEP_HASH_CHECK, OEP_NO_HASH_CHECK, and operand_compare::operand_equal_p().
Referenced by operand_equal_p(), and operand_compare::operand_equal_p().
|
private |
Referenced by compare_decl().
Referenced by compare_edge().
|
private |
Referenced by compare_gimple_label().
|
private |
|
private |
|
private |
Referenced by operand_equal_p(), and parse_labels().
|
private |
Referenced by compare_bb(), compare_decl(), and compare_gimple_call().
|
private |
Referenced by compare_ssa_name(), func_checker(), func_checker(), and ~func_checker().
|
private |
Referenced by compare_bb(), compare_decl(), compare_gimple_call(), and safe_for_total_scalarization_p().
|
private |
Referenced by compare_ssa_name(), func_checker(), func_checker(), and ~func_checker().
|
private |
Referenced by compare_operand().
|
private |
Referenced by safe_for_total_scalarization_p().
|
private |
Referenced by safe_for_total_scalarization_p().