Blame SOURCES/gcc34-hashtab-recursion.patch

6fdc0f
2005-05-17  Jakub Jelinek  <jakub@redhat.com>
6fdc0f
6fdc0f
	* varasm.c (struct constant_descriptor_tree): Add hash field.
6fdc0f
	(const_desc_hash): Just return hash field.
6fdc0f
	(const_desc_eq): If hash values are different, return 0 immediately.
6fdc0f
	(output_constant_def): Compute hash field of temporary key, use
6fdc0f
	htab_find_slot_with_hash instead of htab_find_slot.  Set hash in
6fdc0f
	newly built constant descriptor.
6fdc0f
	(lookup_constant_def): Compute hash field of temporary key, use
6fdc0f
	htab_find_with_hash instead of htab_find.
6fdc0f
6fdc0f
--- gcc/varasm.c	16 May 2005 21:37:01 -0000	1.510
6fdc0f
+++ gcc/varasm.c	17 May 2005 06:34:48 -0000	1.511
6fdc0f
@@ -2361,6 +2361,11 @@ struct constant_descriptor_tree GTY(())
6fdc0f
 
6fdc0f
   /* The value of the constant.  */
6fdc0f
   tree value;
6fdc0f
+
6fdc0f
+  /* Hash of value.  Computing the hash from value each time
6fdc0f
+     hashfn is called can't work properly, as that means recursive
6fdc0f
+     use of the hash table during hash table expansion.  */
6fdc0f
+  hashval_t hash;
6fdc0f
 };
6fdc0f
 
6fdc0f
 static GTY((param_is (struct constant_descriptor_tree)))
6fdc0f
@@ -2374,7 +2379,7 @@ static void maybe_output_constant_def_co
6fdc0f
 static hashval_t
6fdc0f
 const_desc_hash (const void *ptr)
6fdc0f
 {
6fdc0f
-  return const_hash_1 (((struct constant_descriptor_tree *)ptr)->value);
6fdc0f
+  return ((struct constant_descriptor_tree *)ptr)->hash;
6fdc0f
 }
6fdc0f
 
6fdc0f
 static hashval_t
6fdc0f
@@ -2474,8 +2479,11 @@ const_hash_1 (const tree exp)
6fdc0f
 static int
6fdc0f
 const_desc_eq (const void *p1, const void *p2)
6fdc0f
 {
6fdc0f
-  return compare_constant (((struct constant_descriptor_tree *)p1)->value,
6fdc0f
-			   ((struct constant_descriptor_tree *)p2)->value);
6fdc0f
+  const struct constant_descriptor_tree *c1 = p1;
6fdc0f
+  const struct constant_descriptor_tree *c2 = p2;
6fdc0f
+  if (c1->hash != c2->hash)
6fdc0f
+    return 0;
6fdc0f
+  return compare_constant (c1->value, c2->value);
6fdc0f
 }
6fdc0f
 
6fdc0f
 /* Compare t1 and t2, and return 1 only if they are known to result in
6fdc0f
@@ -2745,12 +2753,14 @@ output_constant_def (tree exp, int defer
6fdc0f
   /* Look up EXP in the table of constant descriptors.  If we didn't find
6fdc0f
      it, create a new one.  */
6fdc0f
   key.value = exp;
6fdc0f
-  loc = htab_find_slot (const_desc_htab, &key, INSERT);
6fdc0f
+  key.hash = const_hash_1 (exp);
6fdc0f
+  loc = htab_find_slot_with_hash (const_desc_htab, &key, key.hash, INSERT);
6fdc0f
 
6fdc0f
   desc = *loc;
6fdc0f
   if (desc == 0)
6fdc0f
     {
6fdc0f
       desc = build_constant_desc (exp);
6fdc0f
+      desc->hash = key.hash;
6fdc0f
       *loc = desc;
6fdc0f
     }
6fdc0f
 
6fdc0f
@@ -2853,7 +2863,8 @@ lookup_constant_def (tree exp)
6fdc0f
   struct constant_descriptor_tree key;
6fdc0f
 
6fdc0f
   key.value = exp;
6fdc0f
-  desc = htab_find (const_desc_htab, &key);
6fdc0f
+  key.hash = const_hash_1 (exp);
6fdc0f
+  desc = htab_find_with_hash (const_desc_htab, &key, key.hash);
6fdc0f
 
6fdc0f
   return (desc ? desc->rtl : NULL_RTX);
6fdc0f
 }