OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / statistics.c
index 1f0090c..b7bfd45 100644 (file)
@@ -53,7 +53,7 @@ static unsigned nr_statistics_hashes;
 static hashval_t
 hash_statistics_hash (const void *p)
 {
-  statistics_counter_t *c = (statistics_counter_t *)p;
+  const statistics_counter_t *const c = (const statistics_counter_t *)p;
   return htab_hash_string (c->id) + c->val;
 }
 
@@ -62,8 +62,8 @@ hash_statistics_hash (const void *p)
 static int
 hash_statistics_eq (const void *p, const void *q)
 {
-  statistics_counter_t *c1 = (statistics_counter_t *)p;
-  statistics_counter_t *c2 = (statistics_counter_t *)q;
+  const statistics_counter_t *const c1 = (const statistics_counter_t *)p;
+  const statistics_counter_t *const c2 = (const statistics_counter_t *)q;
   return c1->val == c2->val && strcmp (c1->id, c2->id) == 0;
 }
 
@@ -72,7 +72,7 @@ hash_statistics_eq (const void *p, const void *q)
 static void
 hash_statistics_free (void *p)
 {
-  free ((void *)((statistics_counter_t *)p)->id);
+  free (CONST_CAST(char *, ((statistics_counter_t *)p)->id));
   free (p);
 }
 
@@ -82,7 +82,10 @@ hash_statistics_free (void *p)
 static htab_t
 curr_statistics_hash (void)
 {
-  unsigned idx = current_pass->static_pass_number;
+  unsigned idx;
+
+  gcc_assert (current_pass->static_pass_number >= 0);
+  idx = current_pass->static_pass_number;
 
   if (idx < nr_statistics_hashes
       && statistics_hashes[idx] != NULL)
@@ -90,8 +93,7 @@ curr_statistics_hash (void)
 
   if (idx >= nr_statistics_hashes)
     {
-      statistics_hashes = xrealloc (statistics_hashes,
-                                   (idx + 1) * sizeof (htab_t));
+      statistics_hashes = XRESIZEVEC (struct htab *, statistics_hashes, idx+1);
       memset (statistics_hashes + nr_statistics_hashes, 0,
              (idx + 1 - nr_statistics_hashes) * sizeof (htab_t));
       nr_statistics_hashes = idx + 1;
@@ -295,9 +297,12 @@ statistics_counter_event (struct function *fn, const char *id, int incr)
       || incr == 0)
     return;
 
-  counter = lookup_or_add_counter (curr_statistics_hash (), id, 0, false);
-  gcc_assert (!counter->histogram_p);
-  counter->count += incr;
+  if (current_pass->static_pass_number != -1)
+    {
+      counter = lookup_or_add_counter (curr_statistics_hash (), id, 0, false);
+      gcc_assert (!counter->histogram_p);
+      counter->count += incr;
+    }
 
   if (!statistics_dump_file
       || !(statistics_dump_flags & TDF_DETAILS))