This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Allow reporting statistics when current_pass->id is -1
- From: Andrey Belevantsev <abel at ispras dot ru>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Richard Guenther <richard dot guenther at gmail dot com>
- Date: Wed, 03 Jun 2009 18:08:44 +0400
- Subject: [PATCH] Allow reporting statistics when current_pass->id is -1
Hello,
The statistics.c code crashes when trying to record an event during the
pass which number is -1. This doesn't allow reporting statistics for
alias export when the event gets added rom pass_clean_state. Fixed as
follows (with assert that this would not happen again), bootstrapped and
tested on x86-64, and it also works with alias export. Ok for trunk?
Andrey
2009-06-03 Andrey Belevantsev <abel@ispras.ru>
* statistics.c (statistics_counter_event): Do not record event in pass
dump if its number == -1.
(curr_statistics_hash): Add assert that we never get passes with static
number == -1.
Index: gcc/statistics.c
===================================================================
*** gcc/statistics.c (revision 148120)
--- gcc/statistics.c (working copy)
*************** hash_statistics_free (void *p)
*** 82,88 ****
static htab_t
curr_statistics_hash (void)
{
! unsigned idx = current_pass->static_pass_number;
if (idx < nr_statistics_hashes
&& statistics_hashes[idx] != NULL)
--- 82,91 ----
static htab_t
curr_statistics_hash (void)
{
! 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)
*************** statistics_counter_event (struct functio
*** 294,302 ****
|| incr == 0)
return;
! 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))
--- 297,308 ----
|| incr == 0)
return;
! 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))