This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Feedback optimization errors running SPEC with GCC 3.4 on Darwin 6.4 (Fwd)
- From: Jan Hubicka <jh at suse dot cz>
- To: David Edelsohn <dje at watson dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Cc: Jan Hubicka <jh at suse dot cz>, Mostafa Hagog <MUSTAFA at il dot ibm dot com>,Ayal Zaks <zaks at il dot ibm dot com>
- Date: Mon, 29 Sep 2003 23:20:53 +0200
- Subject: Re: Feedback optimization errors running SPEC with GCC 3.4 on Darwin 6.4 (Fwd)
- References: <20030928075413.GA2396@kam.mff.cuni.cz> <200309281605.h8SG5Zg27444@makai.watson.ibm.com>
> >>>>> Jan Hubicka writes:
>
> Jan> It would be enought to send dumps up to bpro, but there are not that
> Jan> many afterwards. These bugs are especially irritating to hunt down
> Jan> without a machine to test :(
>
> PR 12283 reports the bug for x86.
At least the x86 problem is caused by corruption of input buffer in last
gcov file handling rewrite.
I also added some sanity checking so we should catch similar bugs more
easilly in the future. Does this help to your problem?
I commited this patch after bootstrapping it.
Mon Sep 29 23:02:40 CEST 2003 Jan Hubicka <jh@suse.cz>
PR optimization/12286
* gcov-io.c (gcov_read_words): Fix memmove call.
* profile.c (compute_branch_probabilities): Add extra sanity checks.
Index: gcov-io.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.c,v
retrieving revision 1.12
diff -c -3 -p -r1.12 gcov-io.c
*** gcov-io.c 10 Jul 2003 14:12:58 -0000 1.12
--- gcov-io.c 29 Sep 2003 21:02:24 -0000
*************** gcov_read_words (unsigned words)
*** 361,367 ****
memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
}
#else
! memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, excess);
#endif
gcov_var.offset = 0;
gcov_var.length = excess;
--- 361,367 ----
memcpy (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
}
#else
! memmove (gcov_var.buffer, gcov_var.buffer + gcov_var.offset, excess * 4);
#endif
gcov_var.offset = 0;
gcov_var.length = excess;
Index: profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.125
diff -c -3 -p -r1.125 profile.c
*** profile.c 2 Aug 2003 10:30:48 -0000 1.125
--- profile.c 29 Sep 2003 21:02:24 -0000
*************** compute_branch_probabilities (void)
*** 280,285 ****
--- 280,298 ----
gcov_type *exec_counts = get_exec_counts ();
int exec_counts_pos = 0;
+ /* Very simple sanity checks so we catch bugs in our profiling code. */
+ if (profile_info->run_max * profile_info->runs < profile_info->sum_max)
+ {
+ error ("corrupted profile info: run_max * runs < sum_max");
+ exec_counts = NULL;
+ }
+
+ if (profile_info->sum_all < profile_info->sum_max)
+ {
+ error ("corrupted profile info: sum_all is smaller than sum_max");
+ exec_counts = NULL;
+ }
+
/* Attach extra info block to each bb. */
alloc_aux_for_blocks (sizeof (struct bb_info));
*************** compute_branch_probabilities (void)
*** 315,320 ****
--- 328,338 ----
if (exec_counts)
{
e->count = exec_counts[exec_counts_pos++];
+ if (e->count > profile_info->sum_max)
+ {
+ error ("corrupted profile info: edge from %i to %i exceeds maximal count",
+ bb->index, e->dest->index);
+ }
}
else
e->count = 0;