Hi,
main purpose of obj_type_ref is to hold the type that was used in
virutal call.  We do not hash this info in hash_operand that causes a
lot of miscompares at ICF time.  With LTO this is quite important for
icf performance and in that case we do have manged type names (for
non-anonymous types)

Building libxul without patch we get 1477890 miscompares at:
libxul.so.wpa.076i.icf:  false returned: 'operand_equal_p failed' in 
compare_operand at ../../gcc/ipa-icf-gimple.c:356
With patch this turns into 242454.

Bootstrapped/regtested x86_64-linux, OK?
Honza
        PR ipa/92535
        * fold-const.c (operand_compare::hash_operand): Hash ODR name of
        obj_type_ref_class.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index ddf18f27cb7..e759ddb1e60 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -3866,6 +3866,16 @@ operand_compare::hash_operand (const_tree t, 
inchash::hash &hstate,
              inchash::add_expr (OBJ_TYPE_REF_EXPR (t), hstate, flags);
              inchash::add_expr (OBJ_TYPE_REF_TOKEN (t), hstate, flags);
              inchash::add_expr (OBJ_TYPE_REF_OBJECT (t), hstate, flags);
+             if (tree c = obj_type_ref_class (t))
+             {
+               c = TYPE_NAME (TYPE_MAIN_VARIANT (c));
+               /* We compute mangled names only when free_lang_data is run.
+                  In that case we can hash precisely.  */
+               if (DECL_ASSEMBLER_NAME_SET_P (c))
+                 hstate.add_object
+                        (IDENTIFIER_HASH_VALUE
+                                (DECL_ASSEMBLER_NAME (c)));
+             }
              return;
            default:
              break;

Reply via email to