OSDN Git Service

Fix r179381: add missing period in testsuite/Changelog.
[pf3gnuchains/gcc-fork.git] / gcc / statistics.c
index d2f665f..4883859 100644 (file)
@@ -1,5 +1,5 @@
 /* Optimization statistics functions.
-   Copyright (C) 2008
+   Copyright (C) 2008, 2010
    Free Software Foundation, Inc.
    Contributed by Richard Guenther  <rguenther@suse.de>
 
@@ -26,7 +26,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-dump.h"
 #include "statistics.h"
 #include "hashtab.h"
-#include "tm.h"
 #include "function.h"
 
 static int statistics_dump_nr;
@@ -82,7 +81,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)
@@ -294,9 +296,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))