diff mbox

[google/gcc-4_8] Backport upstream patch to fix non-deterministic order of DWARF output

Message ID CAHACq4onJY8PoGc+mR36Tz84BjdfXsRbWpfQgch=Z6fBDgjgzA@mail.gmail.com
State New
Headers show

Commit Message

Cary Coutant June 11, 2013, 10:10 p.m. UTC
This patch fixes a testsuite failure when -fdebug-types-section is
turned on, where the order of type stub DIEs is dependent on hash
table traversal order.

Backported from trunk at r199927. Bootstrapped, tested, and committed.

-cary


2013-06-10  Cary Coutant  <ccoutant@google.com>

gcc/
        * dwarf2out.c (hash_external_ref): Use die_symbol or signature
        for hash so that hash table traversal order is deterministic.
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 199902)
+++ dwarf2out.c (working copy)
@@ -7405,7 +7405,17 @@  static hashval_t
 hash_external_ref (const void *p)
 {
   const struct external_ref *r = (const struct external_ref *)p;
-  return htab_hash_pointer (r->type);
+  dw_die_ref die = r->type;
+  hashval_t h = 0;
+
+  if (! die->comdat_type_p)
+    h = htab_hash_string (die->die_id.die_symbol);
+  else
+    {
+      comdat_type_node_ref type_node = die->die_id.die_type_node;
+      memcpy (&h, type_node->signature, sizeof (h));
+    }
+  return h;
 }

 /* Compare external_refs.  */