From: Jan Hubicka Date: Fri, 20 Nov 2020 19:36:14 +0000 (+0100) Subject: Improve hashing of decls in ipa-icf-gimple X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d1081010a1addfcf156b7042f581f0698ea25f61;p=gcc.git Improve hashing of decls in ipa-icf-gimple Another remaining case is that we end up comparing calls with mismatching number of parameters or with different permutations of them. This is because we hash decls to nothing. This patch improves that by hashing decls by their code and parm decls by indexes that are stable. Also for defualt defs in SSA_NAMEs we can add the corresponding decl (that is usually parm decls). Still we could improve on this by hasing ssa names by their definit parameters and possibly making maps of other decls and assigning them stable function local IDs. * ipa-icf-gimple.c (func_checker::hash_operand): Improve hashing of decls. --- diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index be5a23d6e02..7e2b3c4624c 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -242,13 +242,29 @@ func_checker::hash_operand (const_tree arg, inchash::hash &hstate, switch (TREE_CODE (arg)) { + case PARM_DECL: + { + unsigned int index = 0; + if (DECL_CONTEXT (arg)) + for (tree p = DECL_ARGUMENTS (DECL_CONTEXT (arg)); + p && index < 32; p = DECL_CHAIN (p), index++) + if (p == arg) + break; + hstate.add_int (PARM_DECL); + hstate.add_int (index); + } + return; case FUNCTION_DECL: case VAR_DECL: case LABEL_DECL: - case PARM_DECL: case RESULT_DECL: case CONST_DECL: + hstate.add_int (TREE_CODE (arg)); + return; case SSA_NAME: + hstate.add_int (SSA_NAME); + if (SSA_NAME_IS_DEFAULT_DEF (arg)) + hash_operand (SSA_NAME_VAR (arg), hstate, flags); return; case FIELD_DECL: inchash::add_expr (DECL_FIELD_OFFSET (arg), hstate, flags); @@ -265,6 +281,8 @@ func_checker::hash_operand (const_tree arg, inchash::hash &hstate, hstate.add_int (0xc10bbe5); return; } + gcc_assert (!DECL_P (arg)); + gcc_assert (!TYPE_P (arg)); return operand_compare::hash_operand (arg, hstate, flags); }