Bug 46528 - [4.6 Regression] profiledbootstrap failure
Summary: [4.6 Regression] profiledbootstrap failure
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-17 23:14 UTC by Steven Bosscher
Modified: 2010-12-06 19:30 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-11-18 21:43:15


Attachments
preprocessed file (36.53 KB, text/plain)
2010-11-24 21:00 UTC, Uroš Bizjak
Details
corresponding profile (1.61 KB, text/plain)
2010-11-24 21:01 UTC, Uroš Bizjak
Details
-fno-inline preprocessed source (35.60 KB, text/plain)
2010-11-24 22:10 UTC, Uroš Bizjak
Details
corresponding -fno-inline profile (1.62 KB, text/plain)
2010-11-24 22:12 UTC, Uroš Bizjak
Details
dump from stageprofile (53.28 KB, text/plain)
2010-11-24 23:03 UTC, Uroš Bizjak
Details
dump from stagefedback (64.61 KB, text/plain)
2010-11-24 23:05 UTC, Uroš Bizjak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Bosscher 2010-11-17 23:14:06 UTC
stevenb@iowa:~/devel/build$ ./prev-gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=./prev-gcc/xgcc
Target: ia64-unknown-linux-gnu
Configured with: ../trunk/configure --with-gmp=/home/stevenb --with-mpfr=/home/stevenb --enable-languages=c --disable-checking --disable-nls --disable-libmudflap --disable-libssp
Thread model: posix
gcc version 4.6.0 20101117 (experimental) [trunk revision 166881] (GCC) 
stevenb@iowa:~/devel/build$ 

/home/stevenb/devel/build/./prev-gcc/xgcc -B/home/stevenb/devel/build/./prev-gcc/ -B/usr/local/ia64-unknown-linux-gnu/bin/ -B/usr/local/ia64-unknown-linux-gnu/bin/ -B/usr/local/ia64-unknown-linux-gnu/lib/ -isystem /usr/local/ia64-unknown-linux-gnu/include -isystem /usr/local/ia64-unknown-linux-gnu/sys-include     -I../../trunk/libcpp -I. -I../../trunk/libcpp/../include -I../../trunk/libcpp/include  -g -O2 -fprofile-use -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wc++-compat -pedantic -Wno-long-long -Werror -I../../trunk/libcpp -I. -I../../trunk/libcpp/../include -I../../trunk/libcpp/include  -c -o macro.o -MT macro.o -MMD -MP -MF .deps/macro.Tpo ../../trunk/libcpp/macro.c
../../trunk/libcpp/macro.c: In function 'cpp_macro_definition':
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: profile data is not flow-consistent
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-59 thought to be -104
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-1 thought to be 104
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-56 thought to be 10
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-57 thought to be -5
make[3]: *** [macro.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/home/stevenb/devel/build/libcpp'
make[2]: *** [all-stagefeedback-libcpp] Error 2
make[2]: Leaving directory `/home/stevenb/devel/build' 
make[1]: *** [stagefeedback-bubble] Error 2
make[1]: Leaving directory `/home/stevenb/devel/build' 
make: *** [profiledbootstrap] Error 2


Configured with with --disable-checking, so may be related to PR32917. I have no idea how to reduce this to a test case for debugging. I will try with --enable-checking=release also.
Comment 1 Richard Biener 2010-11-18 10:09:44 UTC
What you do is look at the gimple before pass_ipa_tree_profile at profile-use
and profile-generate time, they should have matching CFGs.  If they don't
then that's the bug.
Comment 2 Maxim Kuvyrkov 2010-11-18 14:55:35 UTC
Also confirmed on x86_64-unknown-linux-gnu.  The execution numbers are exactly the same as on ia64.
Comment 3 Steven Bosscher 2010-11-18 21:43:15 UTC
Also happens with --enable-checking=release on ia64:


../../trunk/libcpp/macro.c: In function 'cpp_macro_definition':
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: profile data is not flow-consistent
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-59 thought to be -104
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-1 thought to be 104
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-56 thought to be 10
../../trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-57 thought to be -5
make[3]: *** [macro.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/home/stevenb/devel/build-test/libcpp'
make[2]: *** [all-stagefeedback-libcpp] Error 2
make[2]: Leaving directory `/home/stevenb/devel/build-test'
make[1]: *** [stagefeedback-bubble] Error 2
make[1]: Leaving directory `/home/stevenb/devel/build-test'
make: *** [profiledbootstrap] Error 2
stevenb@iowa:~/devel/build-test$ cat gcc/configargs.h 
/* Generated automatically. */
static const char configuration_arguments[] = "../trunk/configure --with-gmp=/home/stevenb --with-mpfr=/home/stevenb --enable-languages=c --enable-checking=release --disable-nls --disable-libmudflap --disable-libssp";
static const char thread_model[] = "posix";
Comment 4 Uroš Bizjak 2010-11-20 23:00:47 UTC
Also on alpha, you will need [1] to get this far.

Using built-in specs.
COLLECT_GCC=./prev-gcc/xgcc
Target: alphaev68-unknown-linux-gnu
Configured with: ../gcc-svn/trunk/configure --enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.6.0 20101120 (experimental) [trunk revision 166974] (GCC) 

Marked as 4.6 regression.

[1] http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02118.html
Comment 5 H.J. Lu 2010-11-21 20:00:33 UTC
It is caused by revision revision 164986:

http://gcc.gnu.org/ml/gcc-cvs/2010-10/msg00168.html
Comment 6 Uroš Bizjak 2010-11-24 21:00:02 UTC
Created attachment 22514 [details]
preprocessed file
Comment 7 Uroš Bizjak 2010-11-24 21:01:16 UTC
Created attachment 22516 [details]
corresponding profile

~/gcc-build/prev-gcc/cc1 -g -O2 -fprofile-use -quiet macro.i
../../gcc-svn/trunk/libcpp/macro.c: In function ‘cpp_macro_definition’:
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: profile data is not flow-consistent
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-59 thought to be -104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-1 thought to be 104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-56 thought to be 10
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-57 thought to be -5
Comment 8 Richard Biener 2010-11-24 21:18:43 UTC
I can't reproduce it on x86_64-unknown-linux-gnu with

./configure --disable-checking --enable-languages=c

or with

./configure --enable-languages=c,c++,fortran

I can reproduce it with the attached testcase and stage1 xgcc though:

> ./xgcc -B. -O2 -g -fprofile-use -c macro.i 
../../gcc-svn/trunk/libcpp/macro.c: In function 'cpp_macro_definition':
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: profile data is not flow-consistent
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-59 thought to be -104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-1 thought to be 104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-56 thought to be 10
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-57 thought to be -5

would be nice to know if

BOOT_CFLAGS="-O2 -g -fno-inline" ./configure --enable-languages=c
make profiledbootstrap BOOT_CFLAGS="-O2 -g -fno-inline"

also fails, alternatively s/-g -fno-inline/-g0/ or s/-fno-inline/-fno-partial-inlining.
Comment 9 Richard Biener 2010-11-24 21:50:55 UTC
The CFGs match, the spanning tree as well.  Instrumenting needs to split
two edges, but that shouldn't matter and happens elsewhere as well.

But we have in .optimized (of the -fprofile-generate case)

<bb 11>:
  pretmp.676_490 = (unsigned int) D.8874_415;
  pretmp.677_491 = macro_39->params;
  pretmp.681_496 = *.LPBX1[67];

<bb 12>:
  # len_429 = PHI <len_55(12), len_44(11)>
  # ivtmp.698_171 = PHI <ivtmp.698_92(12), 0(11)>
  D.8871_52 = MEM[base: pretmp.677_491, index: ivtmp.698_171, step: 8, offset: 0B];
  D.8872_53 = D.8871_52->ident.len;
  D.8873_54 = D.8872_53 + 1;
  len_55 = D.8873_54 + len_429;
  # DEBUG len => len_55
  # DEBUG i => D#11
  # DEBUG len => len_55
  # DEBUG i => D#11
  ivtmp.698_92 = ivtmp.698_171 + 1;
  i_64 = (unsigned int) ivtmp.698_92;
  if (i_64 < pretmp.676_490)
    goto <bb 12>;
  else
    goto <bb 13>;

<bb 13>:
  D.11695_474 = pretmp.681_496 + 1;
  D.11697_493 = pretmp.676_490 + 4294967295;
  D.11698_127 = (long int) D.11697_493;
  *.LPBX1_I_lsm.686_486 = D.11695_474 + D.11698_127;
  *.LPBX1[67] = *.LPBX1_I_lsm.686_486;

which at least looks odd to me and produced by SCCP (supposedly
*.LPBX1[67] + 1 + (long)(niter - 1), so not 100% invalid).

Soooo ... for those who can reproduce it, can you try with -fno-tree-scev-cprop?

I'll wrap my brain around that above computation tomorrow ;)
Comment 10 Uroš Bizjak 2010-11-24 22:10:11 UTC
Created attachment 22517 [details]
-fno-inline preprocessed source
Comment 11 Uroš Bizjak 2010-11-24 22:12:46 UTC
Created attachment 22518 [details]
corresponding -fno-inline profile

~/gcc-build/prev-gcc/cc1 -g -O2 -fno-inline -fprofile-use -quiet macro.i
../../gcc-svn/trunk/libcpp/macro.c: In function ‘cpp_macro_definition’:
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: profile data is not flow-consistent
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-59 thought to be -104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 45-1 thought to be 104
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-56 thought to be 10
../../gcc-svn/trunk/libcpp/macro.c:2123:1: error: corrupted profile info: number of executions for edge 55-57 thought to be -5
Comment 12 Uroš Bizjak 2010-11-24 22:17:13 UTC
glibc data form F14:

./libc.so.6 
GNU C Library development release version 2.12.90, by Roland McGrath et al.
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.5.1 20100924 (Red Hat 4.5.1-4).
Compiled on a Linux 2.6.35 system on 2010-11-12.
Available extensions:
	Support for some architectures added on, not maintained in glibc core.
	The C stubs add-on version 2.1.2.
	crypt add-on version 2.1 by Michael Glad and others
	GNU Libidn by Simon Josefsson
	Native POSIX Threads Library by Ulrich Drepper et al
	BIND-8.2.3-T5B
	RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
Comment 13 Uroš Bizjak 2010-11-24 22:32:15 UTC
(In reply to comment #9)

> Soooo ... for those who can reproduce it, can you try with
> -fno-tree-scev-cprop?

Bootstrap also fails with -fno-tree-scev-cprop :(

The configure/build commands were similar to ones in comment 8.
Comment 14 Uroš Bizjak 2010-11-24 23:03:30 UTC
Created attachment 22520 [details]
dump from stageprofile
Comment 15 Uroš Bizjak 2010-11-24 23:05:34 UTC
Created attachment 22521 [details]
dump from stagefedback
Comment 16 Richard Biener 2010-11-25 12:13:14 UTC
In your dump files there is a CFG inconsistency that I can't reproduce.  At
least basic block numbers are not consistent.

I also see DEBUG insns in stagefeedback but not stageprofile (my dumps
have DEBUG insns in both dump files).  Which hints at for example:

<bb 17>:
  PROF_edge_counter.65_257 = *.LPBX1[69];
  PROF_edge_counter.65_258 = PROF_edge_counter.65_257 + 1;
  *.LPBX1[69] = PROF_edge_counter.65_258;
  count_61 = macro_real_token_count (macro_39);

<bb 18>:
  PROF_edge_counter.65_259 = *.LPBX1[70];
  PROF_edge_counter.65_260 = PROF_edge_counter.65_259 + 1;
  *.LPBX1[70] = PROF_edge_counter.65_260;
  goto <bb 30>;

vs.

<bb 17>:
Invalid sum of outgoing probabilities 0.0%
Invalid sum of outgoing counts 0, should be 211
  count_61 = macro_real_token_count (macro_39);
  # DEBUG count => count_61
  # DEBUG i => 0
  goto <bb 29>;

it would be interesting to see when the CFGs start to differ.  Can you
also check logs if really -g0 is used at stageprofile and -g at
stagefeedback.  I'm trying to look why I have -g consistently.
Comment 17 Richard Biener 2010-11-25 12:40:32 UTC
Please try

Index: gcc/profile.c
===================================================================
--- gcc/profile.c       (revision 167127)
+++ gcc/profile.c       (working copy)
@@ -940,7 +943,8 @@ branch_prob (void)
          for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
            {
              last = gsi_stmt (gsi);
-             if (gimple_has_location (last))
+             if (!is_gimple_debug (last)
+                 && gimple_has_location (last))
                break;
            }
 
we do CFG manipulations based on debug stmts (verified with a later
assert that triggers on -O2 -g -fprofile-use).

It's of course unfortunate that we do this BB splitting at all when
not doing coverage test.
Comment 18 Jan Hubicka 2010-11-25 12:56:35 UTC
> we do CFG manipulations based on debug stmts (verified with a later
> assert that triggers on -O2 -g -fprofile-use).
> 
> It's of course unfortunate that we do this BB splitting at all when
> not doing coverage test.

The BB splitting is neccesary so the CFG can be solved (i.e. you have explicit edges to exit when program can terminate).

Honza
Comment 19 H.J. Lu 2010-11-25 17:43:35 UTC
I started profiledbootstrap tracking:

http://gcc.gnu.org/ml/gcc-regression/2010-11/msg00378.html
Comment 20 Uroš Bizjak 2010-11-25 19:34:03 UTC
(In reply to comment #17)
> Please try
> 
> Index: gcc/profile.c
> ===================================================================
> --- gcc/profile.c       (revision 167127)
> +++ gcc/profile.c       (working copy)
> @@ -940,7 +943,8 @@ branch_prob (void)
>           for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
>             {
>               last = gsi_stmt (gsi);
> -             if (gimple_has_location (last))
> +             if (!is_gimple_debug (last)
> +                 && gimple_has_location (last))
>                 break;
>             }

Great, this bootstrapped OK for -enable-languages=c.
Comment 21 Richard Biener 2010-11-26 09:50:06 UTC
Author: rguenth
Date: Fri Nov 26 09:49:47 2010
New Revision: 167171

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167171
Log:
2010-11-26  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/46528
	PR debug/46338
	* profile.c (branch_prob): Do not split blocks based on locations
	from debug statements.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/profile.c
Comment 22 Richard Biener 2010-11-26 09:51:50 UTC
Fixed.
Comment 23 Jakub Jelinek 2010-12-06 19:30:39 UTC
Author: jakub
Date: Mon Dec  6 19:30:31 2010
New Revision: 167515

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167515
Log:
	PR tree-optimization/46528
	PR debug/46338
	* profile.c (branch_prob): Make sure last is never set to a debug
	stmt.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/profile.c