This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't hash pointers for IPA ICF, instead hash ->order ints (PR ipa/65521)


Hi!

The recent IPA ICF hashing changes broke -fcompare-debug, hashing in
pointers is not stable not just for -fcompare-debug, but supposedly even
just different runs with the exact same options could yield different
assembly.  Hashing on DECL_UID is not good either, that is not guaranteed to
be the same for -g/-g0.
symtab_node::order is printed in the -fdump-final-insns= dumps, so I assume
it must be stable across -g/-g0.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2014-03-23  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/65521
	* ipa-icf.c (sem_item::update_hash_by_addr_refs): Hash
	ultimate_alias_target ()->order ints instead of
	ultimate_alias_target () pointers.

	* gcc.dg/pr65521.c: New test.

--- gcc/ipa-icf.c.jj	2015-03-23 08:47:53.000000000 +0100
+++ gcc/ipa-icf.c	2015-03-23 11:02:53.129630089 +0100
@@ -575,7 +575,7 @@ sem_item::update_hash_by_addr_refs (hash
     {
       ref = node->iterate_reference (i, ref);
       if (ref->address_matters_p () || !m_symtab_node_map.get (ref->referred))
-	hstate.add_ptr (ref->referred->ultimate_alias_target ());
+	hstate.add_int (ref->referred->ultimate_alias_target ()->order);
     }
 
   if (is_a <cgraph_node *> (node))
@@ -585,7 +585,7 @@ sem_item::update_hash_by_addr_refs (hash
 	{
 	  sem_item **result = m_symtab_node_map.get (e->callee);
 	  if (!result)
-	    hstate.add_ptr (e->callee->ultimate_alias_target ());
+	    hstate.add_int (e->callee->ultimate_alias_target ()->order);
 	}
     }
 
--- gcc/testsuite/gcc.dg/pr65521.c.jj	2015-03-23 11:03:16.190252436 +0100
+++ gcc/testsuite/gcc.dg/pr65521.c	2015-03-23 11:02:07.000000000 +0100
@@ -0,0 +1,39 @@
+/* PR ipa/65521 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+struct S { int s; };
+int f6 (void *, unsigned long);
+int f7 (int, int *, unsigned long);
+int f8 (void);
+int f9 (void (*) (void));
+
+int
+f1 (void *p)
+{
+  return f6 (p, 256UL);
+}
+
+int
+f2 (void *p)
+{
+  return f6 (p, 256UL);
+}
+
+int
+f3 (struct S *x)
+{
+  return f7 (f8 (), &x->s, 16UL);
+}
+
+int
+f4 (struct S *x)
+{
+  return f7 (f8 (), &x->s, 16UL);
+}
+
+void
+f5 (void)
+{
+  f9 (f5);
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]