Bug 46760 - LTO bootstrap doesn't work with FDO
Summary: LTO bootstrap doesn't work with FDO
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on: 42690
Blocks:
  Show dependency tree / graph
 
Reported: 2010-12-02 01:40 UTC by H.J. Lu
Modified: 2011-01-10 13:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-12-02 04:57:41


Attachments
extend pass-throughs (1.26 KB, patch)
2010-12-02 04:57 UTC, Dave Korn
Details | Diff
Patch I am testing to allow profile merging (3.54 KB, patch)
2010-12-02 15:57 UTC, Jan Hubicka
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2010-12-02 01:40:57 UTC
When gcc is configured with --with-build-config=bootstrap-lto,
I got

make profiledbootstrap -j8
...
/tmp/ccFYqcB1.ltrans0.ltrans.o: In function `pex_unix_exec_child.3021':
/export/gnu/import/git/gcc/libiberty/pex-unix.c:669: undefined reference to `__gcov_execvp'
/export/gnu/import/git/gcc/libiberty/pex-unix.c:674: undefined reference to `__gcov_execv'
collect2: ld returned 1 exit status
make[4]: *** [lto-wrapper] Error 1
make[4]: *** Waiting for unfinished jobs....
rm cpp.pod gcov.pod gfdl.pod gcc.pod fsf-funding.pod
make[4]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux/gcc'
make[3]: *** [all-stageprofile-gcc] Error 2
make[3]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'
make[2]: *** [stageprofile-bubble] Error 2
make[2]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'
make[1]: *** [profiledbootstrap] Error 2
make[1]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'
5005.95user 127.48system 12:19.47elapsed 694%CPU (0avgtext+0avgdata 1395712maxresident)k
109864inputs+6981752outputs (5major+52176484minor)pagefaults 0swaps
make: *** [profiledbootstrap] Error 2
Comment 1 Drea Pinski 2010-12-02 01:47:47 UTC
I think this is a bug in make file rather than anything else.  We are building libibity with -fprofile-generate but not lto-wrapper.
Comment 2 H.J. Lu 2010-12-02 01:58:17 UTC
(In reply to comment #1)
> I think this is a bug in make file rather than anything else.  We are building
> libibity with -fprofile-generate but not lto-wrapper.

It looks good to me:

/export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc -B/export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/bin/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/bin/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/lib/ -isystem /usr/gcc-4.6.0/x86_64-unknown-linux-gnu/include -isystem /usr/gcc-4.6.0/x86_64-unknown-linux-gnu/sys-include    -c -DHAVE_CONFIG_H -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-generate  -I. -I/export/gnu/import/git/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  /export/gnu/import/git/gcc/libiberty/pex-unix.c -o pex-unix.o
Comment 3 Dave Korn 2010-12-02 04:57:41 UTC
Created attachment 22600 [details]
extend pass-throughs

I'm testing this, which adds pass-thoughs for gcov and the endfiles (see also Bug 42690).
Comment 4 Dave Korn 2010-12-02 07:14:34 UTC
  With my patch we no longer get the undefined symbols building lto-wrapper, but instead later on we hit this problem:

------------------------------------------------------------------------------
       [ . . . ]
/home/davek/gcc/obj-gold/./prev-gcc/xgcc -B/home/davek/gcc/obj-gold/./prev-gcc/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/lib/ -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/include -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/sys-include      -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genchecksum \
	    build/genchecksum.o .././libiberty/libiberty.a
lto1: sorry, unimplemented: combining units with different profiles is not supported
lto1: internal compiler error: in lto_file_decl_data_get_fn_decl, at lto-streamer.h:1075
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /home/davek/gcc/obj-gold/./prev-gcc/xgcc returned 1 exit status
gold: fatal error: lto-wrapper failed
collect2: ld returned 1 exit status
make[3]: *** [build/genchecksum] Error 1
make[3]: *** Waiting for unfinished jobs....
rm gfdl.pod cpp.pod gfortran.pod gcov.pod fsf-funding.pod gcc.pod
make[3]: Leaving directory `/home/davek/gcc/obj-gold/gcc'
make[2]: *** [all-stagefeedback-gcc] Error 2
make[2]: Leaving directory `/home/davek/gcc/obj-gold'
make[1]: *** [stagefeedback-bubble] Error 2
make[1]: Leaving directory `/home/davek/gcc/obj-gold'
make: *** [profiledbootstrap] Error 2
------------------------------------------------------------------------------

As far as I can see though, everything relevant was compiled with -fprofile-use in effect:


------------------------------------------------------------------------------
Configuring stage feedback in ./libiberty
       [ . . . ]
/home/davek/gcc/obj-gold/./prev-gcc/xgcc -B/home/davek/gcc/obj-gold/./prev-gcc/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/lib/ -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/include -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/sys-include    -c -DHAVE_CONFIG_H -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use  -I. -I/n/10/davek/gcc/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  /n/10/davek/gcc/gcc/libiberty/md5.c -o md5.o
       [ . . . ]
/home/davek/gcc/obj-gold/./prev-gcc/xgcc -B/home/davek/gcc/obj-gold/./prev-gcc/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/lib/ -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/include -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/sys-include    -c -DHAVE_CONFIG_H -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use  -I. -I/n/10/davek/gcc/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  /n/10/davek/gcc/gcc/libiberty/fopen_unlocked.c -o fopen_unlocked.o
       [ . . . ]
/home/davek/gcc/obj-gold/./prev-gcc/xgcc -B/home/davek/gcc/obj-gold/./prev-gcc/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/lib/ -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/include -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/sys-include    -c -DHAVE_CONFIG_H -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use  -I. -I/n/10/davek/gcc/gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  /n/10/davek/gcc/gcc/libiberty/xstrerror.c -o xstrerror.o
       [ . . . ]
/home/davek/gcc/obj-gold/./prev-gcc/xgcc -B/home/davek/gcc/obj-gold/./prev-gcc/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/bin/ -B/n/10/davek/gcc/x86_64-unknown-linux-gnu/lib/ -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/include -isystem /n/10/davek/gcc/x86_64-unknown-linux-gnu/sys-include    -c   -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I/n/10/davek/gcc/gcc/gcc -I/n/10/davek/gcc/gcc/gcc/build -I/n/10/davek/gcc/gcc/gcc/../include -I/n/10/davek/gcc/gcc/gcc/../libcpp/include -I/opt/cfarm/gmp-4.2.4/include -I/opt/cfarm/mpfr-2.4.1/include -I/opt/cfarm/mpc-0.8/include  -I/n/10/davek/gcc/gcc/gcc/../libdecnumber -I/n/10/davek/gcc/gcc/gcc/../libdecnumber/bid -I../libdecnumber    \
		-o build/genchecksum.o /n/10/davek/gcc/gcc/gcc/genchecksum.c
       [ . . . ]
------------------------------------------------------------------------------

... but none the less input_profile_summary complains when it gets to the first libiberty input IR object file.
Comment 5 Dave Korn 2010-12-02 07:47:13 UTC
(In reply to comment #4)

>  -DHAVE_CONFIG_H -DGENERATOR_FILE  -o build/genchecksum \
>         build/genchecksum.o .././libiberty/libiberty.a
> lto1: sorry, unimplemented: combining units with different profiles is not
> supported
> lto1: internal compiler error: in lto_file_decl_data_get_fn_decl, at
> lto-streamer.h:1075


  This sorry comes from input_profile_summary() in lto-cgraph.c, in fact:


static struct gcov_ctr_summary lto_gcov_summary;

/* Input profile_info from IB.  */
static void
input_profile_summary (struct lto_input_block *ib)
{
  unsigned int runs = lto_input_uleb128 (ib);
  if (runs)
    {
      if (!profile_info)
        {
	  profile_info = &lto_gcov_summary;
	  lto_gcov_summary.runs = runs;
	  lto_gcov_summary.sum_all = lto_input_sleb128 (ib);
	  lto_gcov_summary.run_max = lto_input_sleb128 (ib);
	  lto_gcov_summary.sum_max = lto_input_sleb128 (ib);
	}
      /* We can support this by scaling all counts to nearest common multiple
         of all different runs, but it is perhaps not worth the effort.  */
      else if (profile_info->runs != runs
	       || profile_info->sum_all != lto_input_sleb128 (ib)
	       || profile_info->run_max != lto_input_sleb128 (ib)
	       || profile_info->sum_max != lto_input_sleb128 (ib))
	sorry ("combining units with different profiles is not supported");
      /* We allow some units to have profile and other to not have one.  This will
         just make unprofiled units to be size optimized that is sane.  */
    }

}

This is the start of the cgraph data from build/genchecksum.o:

(gdb) c
Continuing.

Breakpoint 5, lto_create_simple_input_block (file_data=0x7ffff7267000,
    section_type=LTO_section_cgraph, datar=0x7fffffffd858, len=0x7fffffffd860)
    at /n/10/davek/gcc/gcc/gcc/lto-section-in.c:294
294     {
$17 = {current_decl_state = 0x7ffff7275000,
  global_decl_state = 0x7ffff7275000, cgraph_node_encoder = 0x0,
  varpool_node_encoder = 0x0, function_decl_states = 0x7ffff735dcb0,
  file_name = 0x1bde940 "build/genchecksum.o", section_hash_table = 0x1bfa560,
  renaming_hash_table = 0x1bfb4a0, next = 0x0, id = 3807079657,
  resolutions = 0x1bfab30}
(gdb) fin
Run till exit from #0  lto_create_simple_input_block (
    file_data=0x7ffff7267000, section_type=LTO_section_cgraph,
    datar=0x7fffffffd858, len=0x7fffffffd860)
    at /n/10/davek/gcc/gcc/gcc/lto-section-in.c:294
input_cgraph () at /n/10/davek/gcc/gcc/gcc/lto-cgraph.c:1475
1475          if (!ib)
Value returned is $18 = (struct lto_input_block *) 0x1bfa250
(gdb) p $18[0]
$19 = {data = 0x1bfa020 "\004\201?\225\r??\237\003?\233\f\002\177", p = 0,
  len = 551}
(gdb) x/551xb $18->data
0x1bfa020:      0x04    0x81    0xf1    0x95    0x0d    0xc0    0xdc    0x9f
0x1bfa028:      0x03    0xda    0xb9    0x9b    0x0c    0x02    0x7f    0x00
0x1bfa030:      0x00    0x00    0x06    0x07    0x05    0x0f    0x7f    0x7f
0x1bfa038:      0xbc    0xa0    0x0a    0x00    0x00    0x02    0x7f    0x01
0x1bfa040:      0xbd    0x01    0xc8    0x20    0xe4    0x00    0x06    0xe2

and here is how it gets read into lto_gcov_summary first time input_profile_summary is called:

(gdb) p &'lto_gcov_summary.170684.49820'
$27 = (<data variable, no debug info> *) 0x1777280
(gdb) p (struct gcov_ctr_summary *)&'lto_gcov_summary.170684.49820'
$28 = (struct gcov_ctr_summary *) 0x1777280
(gdb) p $28[0]
$29 = {num = 0, runs = 4, sum_all = 27621505, run_max = 6811200,
  sum_max = 25615578}
(gdb) p/x $28[0]
$30 = {num = 0x0, runs = 0x4, sum_all = 0x1a57881, run_max = 0x67ee40,
  sum_max = 0x186dcda}
(gdb)

But here's the start of the ../libiberty/md5.o cgraph section data:

(gdb) c
Continuing.

Breakpoint 5, lto_create_simple_input_block (file_data=0x7ffff72670b0,
    section_type=LTO_section_cgraph, datar=0x7fffffffd858, len=0x7fffffffd860)
    at /n/10/davek/gcc/gcc/gcc/lto-section-in.c:294
294     {
$22 = {current_decl_state = 0x7ffff7275870,
  global_decl_state = 0x7ffff7275870, cgraph_node_encoder = 0x0,
  varpool_node_encoder = 0x0, function_decl_states = 0x7ffff735dd20,
  file_name = 0x1bfb480 "../libiberty/md5.o", section_hash_table = 0x1bfcdd0,
  renaming_hash_table = 0x1bfae30, next = 0x0, id = 3807079657,
  resolutions = 0x1bfb770}
(gdb) fin
Run till exit from #0  lto_create_simple_input_block (
    file_data=0x7ffff72670b0, section_type=LTO_section_cgraph,
    datar=0x7fffffffd858, len=0x7fffffffd860)
    at /n/10/davek/gcc/gcc/gcc/lto-section-in.c:294
input_cgraph () at /n/10/davek/gcc/gcc/gcc/lto-cgraph.c:1475
1475          if (!ib)
Value returned is $23 = (struct lto_input_block *) 0x1bfbb50
(gdb) p $23[0]
$24 = {
  data = 0x1bfc0e0 "?\016??\212?\212\002\220?\204\017??\204?\002\002\177",
  p = 0, len = 352}
(gdb) x/352xb $23->data
0x1bfc0e0:      0xc0    0x0e    0xaf    0xbc    0x8a    0xed    0x8a    0x02
0x1bfc0e8:      0x90    0xcf    0x84    0x0f    0xa3    0xa1    0x84    0xb4
0x1bfc0f0:      0x02    0x02    0x7f    0x00    0x08    0x00    0x0b    0x09
0x1bfc0f8:      0x0a    0x11    0x7f    0x7f    0x9e    0xa0    0x0a    0x00
0x1bfc100:      0x00    0x02    0x7f    0x01    0x00    0x00    0x0b    0x0b
0x1bfc108:      0x0a    0x13    0x7f    0x7f    0x9e    0xa0    0x0a    0x00

which gives me { runs = 0x740, sum_all = 0x10ada29e2f, run_max = 0x1e12790, sum_max = 0x268110a3 }, none of which remotely matches up with the gcov summary from genchecksum.o
Comment 6 Jan Hubicka 2010-12-02 09:00:51 UTC
Hi,
at one point I tried profiledbootstrap and problem is that we can not merge multiple LTO files
that has been profiled different amount of times.  This happens during our build because lto1
and cc1 share libbackend.  We probably need to add code rescaling corresponding events...

Honza
Comment 7 Dave Korn 2010-12-02 09:08:42 UTC
(In reply to comment #6)
> Hi,
> at one point I tried profiledbootstrap and problem is that we can not merge
> multiple LTO files
> that has been profiled different amount of times.  This happens during our
> build because lto1
> and cc1 share libbackend.  We probably need to add code rescaling corresponding
> events...
> 
> Honza

  Rather than open a second bug for this part of the problem, let's leave this PR to handle it; the first part of the problem that HJ originally reported can be considered a part of bug 42690, which I'm in the course of testing the attached patch as part of.

  So, de-assigning myself from this PR.  Possibly we should consider this a build system bug and the makefile should be responsible for swapping sets of gcda files in and out?  Otherwise the component should be changed to lto.
Comment 8 Jan Hubicka 2010-12-02 09:22:38 UTC
Hi,
you can still test bootstrap with simply commenting out that sorry.  It should give, sort-of, sane results.
I will implement counter rescaling once I get some time for it - it is not too hard.
Also not too many setups actually train library built into multiple binaries, so it is not that critical
outside GCC itself.
Comment 9 Jan Hubicka 2010-12-02 15:57:00 UTC
Created attachment 22604 [details]
Patch I am testing to allow profile merging

This patch should allow merging of LTO units with different number of executions.  I am testing how far I can get with lto bootstrap with this one and the pass-through
Comment 10 H.J. Lu 2010-12-04 17:04:34 UTC
(In reply to comment #9)
> Created attachment 22604 [details]
> Patch I am testing to allow profile merging
> 
> This patch should allow merging of LTO units with different number of
> executions.  I am testing how far I can get with lto bootstrap with this one
> and the pass-through

I got

lto1: internal compiler error: Floating point exception
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Do we have a divide by zero bug?
Comment 11 H.J. Lu 2010-12-04 17:13:57 UTC
Program received signal SIGFPE, Arithmetic exception.
0x0000000000f6e670 in merge_profile_summaries ()
    at /export/gnu/import/git/gcc/gcc/lto-cgraph.c:1513
1513		    / node->local.lto_file_data->profile_info.run_max);
Comment 12 H.J. Lu 2010-12-04 17:24:28 UTC
(gdb) p cgraph_nodes->local.lto_file_data->profile_info
$4 = {num = 0, runs = 9409, sum_all = 0, run_max = 0, sum_max = 1302797449}
(gdb)
Comment 13 Jan Hubicka 2010-12-04 17:33:02 UTC
I fixed that division bug (it is wrong way) and I can bootstrap C only, C++ still fails, this time on profile mismatches.
I will commit the fixed patch.

Honza
Comment 14 Jan Hubicka 2010-12-04 19:35:27 UTC
Author: hubicka
Date: Sat Dec  4 19:35:23 2010
New Revision: 167458

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167458
Log:

	PR tree-optimization/46760
	* cgraph.c (cgraph_create_node): Initialize count_materialization_scale.
	* cgraph.h (struct cgraph_node): Add count_materialization_scale.
	* lto-cgraph.c (lto_output_edge): Fix assert.
	(lto_output_node): Output count_materialization_scale.
	(output_profile_summary): Output only runs and sum_max.
	(input_node): Input count_materialization_scale.
	(input_profile_summary): Read data into file specific gcov summary.
	(merge_profile_summaries): New function.
	(input_cgraph): Update call of input_profile_summary;
	call merge_profile_summaries.
	* lto-streamer-in.c (input_cfg): Add count_materialization_scale arg;
	rescale counts at read in.
	(intput_bb): Likewise.
	(input_function): Update call of input_bb.
	(lto_read_body): Update call of input_cfg.
	* lto-streamer.h: Inlclude gcov-io.h
	(lto_file_decl_data): Add gcov_ctr_summary.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/cgraph.h
    trunk/gcc/lto-cgraph.c
    trunk/gcc/lto-streamer-in.c
    trunk/gcc/lto-streamer.h
Comment 15 H.J. Lu 2010-12-05 00:51:39 UTC
With revision 167460, I got

[hjl@gnu-18 gcc]$ /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc -B/export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/bin/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/bin/ -B/usr/gcc-4.6.0/x86_64-unknown-linux-gnu/lib/ -isystem /usr/gcc-4.6.0/x86_64-unknown-linux-gnu/include -isystem /usr/gcc-4.6.0/x86_64-unknown-linux-gnu/sys-include      -g -O2 -flto=jobserver -fuse-linker-plugin -frandom-seed=1 -fprofile-use -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc  -o build/genchecksum build/genchecksum.o .././libiberty/libiberty.a
In function \u2018md5_process_block\u2019:
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make: *** [/tmp/cc1Nc0QJ.ltrans0.ltrans.o] Error 1
lto-wrapper: make returned 2 exit status
lto-wrapper failedcollect2: ld returned 1 exit status
[hjl@gnu-18 gcc]$
Comment 16 Jan Hubicka 2010-12-05 14:28:29 UTC
Bootstrap works for me with current mainline with release checking as well as default checking, configured as:

../configure --enable-stage1-languages=c,lto --with-ld=/abuild/jh/trunk-install/bin/ld --with-build-config=bootstrap-lto --enable-checking=release --disable-plugin

Can you, please, re-confirm the bug or close the PR?
Comment 17 H.J. Lu 2010-12-05 17:16:53 UTC
(In reply to comment #16)
> Bootstrap works for me with current mainline with release checking as well as
> default checking, configured as:
> 
> ../configure --enable-stage1-languages=c,lto
> --with-ld=/abuild/jh/trunk-install/bin/ld --with-build-config=bootstrap-lto
> --enable-checking=release --disable-plugin
                            ^^^^^^^^^^^^^^^^^
Can you try without disabling plugin?

I am using.

--enable-clocale=gnu --with-system-zlib --with-demangler-in-ld --enable-langua
ges=c,lto  --prefix=/usr/gcc-4.6.0 --with-local-prefix=/usr/local --with-fpmath=
sse --with-build-config=bootstrap-lto
Comment 18 Jan Hubicka 2010-12-05 19:04:38 UTC
I tried with the default checking earlier (this is not LTO plugin, just the plugin support that does not cause that much of difference).  I will try tonight or after I return from trip.
Comment 19 Jan Hubicka 2011-01-09 18:27:52 UTC
it works for me now.
Comment 20 H.J. Lu 2011-01-09 22:02:10 UTC
On my Intel64 machine with 6GB RAM and 12GB swap, revision 168617
failed at final link:

lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [lto1] Error 1
make[5]: *** Waiting for unfinished jobs....
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [cc1obj] Error 1
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [jc1] Error 1
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [cc1] Error 1
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [cc1plus] Error 1
lto1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc returned 1 exit status
/usr/local/bin/ld: lto-wrapper failed
collect2: ld returned 1 exit status
make[5]: *** [f951] Error 1
rm gcj-dbtool.pod jcf-dump.pod cpp.pod jv-convert.pod grmic.pod gcov.pod gcj.pod gc-analyze.pod gfdl.pod gij.pod gcc.pod gfortran.pod fsf-funding.pod
make[5]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux/gcc'
make[4]: *** [all-stagefeedback-gcc] Error 2
make[4]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'
make[3]: *** [stagefeedback-bubble] Error 2
make[3]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'
make[2]: *** [profiledbootstrap] Error 2
make[2]: Leaving directory `/export/build/gnu/gcc-lto/build-x86_64-linux'

GCC configured with

/export/gnu/import/git/gcc/configure --enable-clocale=gnu --with-system-zlib --with-demangler-in-ld   --prefix=/usr/gcc-4.6.0 --with-local-prefix=/usr/local --with-fpmath=sse --with-build-config=bootstrap-lto
Comment 21 Jan Hubicka 2011-01-09 22:07:59 UTC
> lto1: internal compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> lto-wrapper: /export/build/gnu/gcc-lto/build-x86_64-linux/./prev-gcc/xgcc

What is the backtrace here?  I built working profiledbootsrap LTO compiler with various cofigurations
already (both GNU ld and gold) w/o problems....  I will try with current tree.

Honza
Comment 22 H.J. Lu 2011-01-10 00:01:45 UTC
Program received signal SIGSEGV, Segmentation fault.
tree_can_inline_p (e=0x7fffdaf9fd68)
    at /export/gnu/import/git/gcc/gcc/tree-inline.c:5391
5391	      gimple_call_set_cannot_inline (e->call_stmt, true);
Missing separate debuginfos, use: debuginfo-install cloog-ppl-0.15.8-1.0.f12.x86_64 glibc-2.12.90-21.2.f14.x86_64 gmp-4.3.2-0.0.f13.x86_64 libgcc-4.5.1-4.fc14.x86_64 libmpc-0.8.1-1.0.f12.x86_64 libstdc++-4.5.1-4.fc14.x86_64 mpfr-2.4.2-1.0.f12.x86_64 ppl-0.10.2-10.fc12.x86_64 zlib-1.2.5-2.fc14.x86_64
(gdb) bt
#0  tree_can_inline_p (e=0x7fffdaf9fd68)
    at /export/gnu/import/git/gcc/gcc/tree-inline.c:5391
#1  0x0000000000a5653a in cgraph_decide_inlining_of_small_functions ()
    at /export/gnu/import/git/gcc/gcc/ipa-inline.c:1177
#2  0x0000000000a585b7 in cgraph_decide_inlining ()
    at /export/gnu/import/git/gcc/gcc/ipa-inline.c:1479
#3  0x0000000000e65b52 in execute_one_pass (pass=0x1947960)
    at /export/gnu/import/git/gcc/gcc/passes.c:1553
#4  0x0000000000e6626a in execute_ipa_pass_list (pass=0x1947960)
    at /export/gnu/import/git/gcc/gcc/passes.c:1920
#5  0x0000000000e665e6 in do_whole_program_analysis ()
    at /export/gnu/import/git/gcc/gcc/lto/lto.c:2334
#6  0x0000000000ebab88 in lto_main ()
    at /export/gnu/import/git/gcc/gcc/lto/lto.c:2446
#7  0x000000000071730d in compile_file ()
    at /export/gnu/import/git/gcc/gcc/toplev.c:579
#8  do_compile () at /export/gnu/import/git/gcc/gcc/toplev.c:1874
#9  0x00000000007189e5 in toplev_main (argc=405, argv=0x1e44a00)
    at /export/gnu/import/git/gcc/gcc/toplev.c:1937
#10 0x00000000004a5040 in main (argc=35, argv=0x7fffffffdc08)
    at /export/gnu/import/git/gcc/gcc/main.c:36
(gdb) list
5386	
5387	  /* Allow the backend to decide if inlining is ok.  */
5388	  if (!targetm.target_option.can_inline_p (caller, callee))
5389	    {
5390	      e->inline_failed = CIF_TARGET_OPTION_MISMATCH;
5391	      gimple_call_set_cannot_inline (e->call_stmt, true);
5392	      e->call_stmt_cannot_inline_p = true;
5393	      return false;
5394	    }
5395	
(gdb) p e
$1 = (struct cgraph_edge *) 0x7fffdaf9fd68
(gdb) p e->call_stmt
$2 = (union gimple_statement_d *) 0x0
(gdb)
Comment 23 Jan Hubicka 2011-01-10 00:21:35 UTC
> 5386    
> 5387      /* Allow the backend to decide if inlining is ok.  */
> 5388      if (!targetm.target_option.can_inline_p (caller, callee))
> 5389        {
> 5390          e->inline_failed = CIF_TARGET_OPTION_MISMATCH;
> 5391          gimple_call_set_cannot_inline (e->call_stmt, true);
> 5392          e->call_stmt_cannot_inline_p = true;
> 5393          return false;
> 5394        }
> 5395    
> (gdb) p e
> $1 = (struct cgraph_edge *) 0x7fffdaf9fd68
> (gdb) p e->call_stmt
> $2 = (union gimple_statement_d *) 0x0
> (gdb)
Obviously we can not set gimple_call_set_cannot_inline when call_stmt is missing.
I guess just guardining the set with
if (e->call_stmt)
  gimple_call_set_cannot_inline (e->call_stmt, true);
in all occurences in the function should fix the issue. Consider it preaproved
if it helps.  In 4.7 we probably should drop the gimple_call_set_cannot_inline
calls completely, I don't see any value in them.

Can you do dump_cgraph_node (stderr, e->caller) and dump_cgraph_node (stderr,
e->callee)??  I think we should decide function to be uninlinable only in
presence of target optimization attributes and I can not think of any during
the bootstrap....

Honza
Comment 24 H.J. Lu 2011-01-10 01:24:13 UTC
(gdb) call dump_cgraph_node (stderr, e->caller)
_cpp_clean_line/47583(-1) @0x7fffdaf97b00 (asm: _cpp_clean_line) availability:available analyzed executed 136036096x 107 time, 14 benefit 186 size, 7 benefit (204 after inlining) needed reachable externally_visible prevailing_def finalized inlinable
  called by: cpp_pop_definition/47256 (1.00 per call) destringize_and_run/47257 (1.00 per call) run_directive/47259 (2130530x) (1.00 per call) builtin_macro/47693 (97x) (1.00 per call) paste_tokens/47699 (450825x) (1.00 per call) cpp_read_state/47816 (1.00 per call) _cpp_skip_block_comment/47586 (19682217x) (0.93 per call) _cpp_get_fresh_line.part.5/47584 (113774079x) (1.00 per call) 
  calls: add_line_note/38510 (inlined) (136036096x) (1.00 per call) add_line_note/47567 (nested in 1 loops) add_line_note/47567 (8317015x) (0.06 per call) (nested in 1 loops) add_line_note/47567 (2018574x) (0.01 per call) __builtin_expect/2426 (133456296x) (0.98 per call) __builtin_expect/2426 (133456296x) (0.98 per call) __builtin_expect/2426 (133456296x) (0.98 per call) add_line_note/47567 (nested in 1 loops) __builtin_expect/2426 (319549x) (0.00 per call) (nested in 1 loops) __builtin_expect/2426 (133775845x) (0.98 per call) (nested in 1 loops) search_line_sse42/47576 (136174844x) (1.00 per call) (nested in 1 loops) 
  References:  var:search_line_fast (read) fn:search_line_sse42/47576 (addr) var:_cpp_trigraph_map (read) var:_cpp_trigraph_map (read) var:_sch_istable (read) var:_sch_istable (read) var:_cpp_trigraph_map (read) var:_cpp_trigraph_map (read)
  Refering this function: 
  has 1 outgoing edges for indirect calls.
(gdb) call dump_cgraph_node (stderr, e->callee)
search_line_sse42/47576(-1) @0x7fffdaf97160 (asm: search_line_sse42.762190) availability:available analyzed executed 136174844x 18 time, 15 benefit 30 size, 7 benefit address_taken prevailing_def_ironly finalized inlinable
  called by: _cpp_clean_line/47583 (136174844x) (1.00 per call) 
  calls: __builtin_expect/2426 (127407932x) (0.94 per call) search_line_sse2/47575 (1039x) __builtin_expect/2426 (142096x) (0.00 per call) __builtin_expect/2426 (127408971x) (0.94 per call) 
  References: 
  Refering this function:  fn:init_vectorized_lexer/47582 (addr) fn:_cpp_clean_line/47583 (addr)
(gdb)
Comment 25 H.J. Lu 2011-01-10 01:25:00 UTC
My machine supports SSE4.
Comment 26 Jan Hubicka 2011-01-10 01:42:06 UTC
> call) (nested in 1 loops) search_line_sse42/47576 (136174844x) (1.00 per call)
Ahh, that is the Andi's vectorized preprocessor code. That is fine then....

Honza
Comment 27 hjl@gcc.gnu.org 2011-01-10 13:24:30 UTC
Author: hjl
Date: Mon Jan 10 13:24:27 2011
New Revision: 168631

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168631
Log:
Check e->call_stmt before calling gimple_call_set_cannot_inline.

2011-01-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR lto/46760
	* tree-inline.c (tree_can_inline_p): Check e->call_stmt before
	calling gimple_call_set_cannot_inline.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-inline.c
Comment 28 H.J. Lu 2011-01-10 13:27:11 UTC
Fixed.
Comment 29 Jan Hubicka 2011-01-10 13:44:00 UTC
H.J., since you run regular testing, do you think you could switch one of tester into lto-bootstrap (or ideally lto-bootstrap with FDO) so we keep those in good condition?
Thanks!
Honza
Comment 30 H.J. Lu 2011-01-10 13:48:27 UTC
(In reply to comment #29)
> H.J., since you run regular testing, do you think you could switch one of
> tester into lto-bootstrap (or ideally lto-bootstrap with FDO) so we keep those
> in good condition?
> Thanks!

I have been testing lto-bootstrap:

http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00750.html

I will try to start lto-bootstrap with FDO.
Comment 31 Jan Hubicka 2011-01-10 13:51:02 UTC
> I have been testing lto-bootstrap:
> 
> http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00750.html
> 
> I will try to start lto-bootstrap with FDO.
Great, thanks!
The FDO bootstrap always suffered from lack of testing, so this should help.
Honza
Comment 32 H.J. Lu 2011-01-10 13:59:32 UTC
(In reply to comment #31)
> > I have been testing lto-bootstrap:
> > 
> > http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00750.html
> > 
> > I will try to start lto-bootstrap with FDO.
> Great, thanks!
> The FDO bootstrap always suffered from lack of testing, so this should help.
> Honza

I have been testing FDO bootstrap:

http://gcc.gnu.org/ml/gcc-testresults/2011-01/msg00765.html

I just need to start lto-bootstrap with FDO.