merge from gcc
authorDJ Delorie <dj@redhat.com>
Thu, 27 Jul 2006 18:05:31 +0000 (18:05 +0000)
committerDJ Delorie <dj@redhat.com>
Thu, 27 Jul 2006 18:05:31 +0000 (18:05 +0000)
libiberty/ChangeLog
libiberty/hashtab.c

index 00c3089f8c7930b4fbbde8463da8d703e89e8552..745a2f4f9712de3ebb08b917456f713b1fddc534 100644 (file)
@@ -1,3 +1,9 @@
+2006-07-27  Jan Hubicka  <jh@suse.cz>
+
+       PR rtl-optimization/28071
+       * hashtab.c (htab_empty): Clear out n_deleted/n_elements;
+       downsize the hashtable.
+
 2006-07-04  Peter O'Gorman  <peter@pogma.com>
 
        * Makefile.in: chmod 644 before ranlib during install.
index a5671a0a768041bc12a4e62473ea12aa3afc7fc4..bf34a6d297ed09630aa6754c48df4ede92f4452a 100644 (file)
@@ -421,7 +421,28 @@ htab_empty (htab_t htab)
       if (entries[i] != HTAB_EMPTY_ENTRY && entries[i] != HTAB_DELETED_ENTRY)
        (*htab->del_f) (entries[i]);
 
-  memset (entries, 0, size * sizeof (PTR));
+  /* Instead of clearing megabyte, downsize the table.  */
+  if (size > 1024*1024 / sizeof (PTR))
+    {
+      int nindex = higher_prime_index (1024 / sizeof (PTR));
+      int nsize = prime_tab[nindex].prime;
+
+      if (htab->free_f != NULL)
+       (*htab->free_f) (htab->entries);
+      else if (htab->free_with_arg_f != NULL)
+       (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries);
+      if (htab->alloc_with_arg_f != NULL)
+       htab->entries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
+                                                          sizeof (PTR *));
+      else
+       htab->entries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *));
+     htab->size = nsize;
+     htab->size_prime_index = nindex;
+    }
+  else
+    memset (entries, 0, size * sizeof (PTR));
+  htab->n_deleted = 0;
+  htab->n_elements = 0;
 }
 
 /* Similar to htab_find_slot, but without several unwanted side effects: