Bug 64636 - LTO PGO bootstrap fails on linux-sparc64 in stream_out_histogram_value
Summary: LTO PGO bootstrap fails on linux-sparc64 in stream_out_histogram_value
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 4.9.2
: P3 normal
Target Milestone: 9.4
Assignee: Martin Liška
URL:
Keywords: build, ice-on-valid-code
: 72848 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-01-16 21:57 UTC by Carson Gaspar
Modified: 2021-10-02 08:00 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.2.1, 10.3.0, 11.0, 9.4.0
Known to fail: 8.4.0, 9.3.0
Last reconfirmed: 2017-05-05 00:00:00


Attachments
preprocessed regex.i (18.20 KB, text/plain)
2015-01-17 00:44 UTC, Carson Gaspar
Details
preprocessed abstract.c produced by -S --save-temps gcc flag (63.52 KB, text/plain)
2020-06-16 20:06 UTC, George R. Goffe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carson Gaspar 2015-01-16 21:57:44 UTC
LTO bootstrap throws an error on libiberty/regex.c. Removing the LTO compile options results in a successful compilation of regex.o

gcc 4.9.2
Solaris 11.2
gcc configure command:
../gcc-4.9.2/configure --prefix=/Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu --with-local-prefix=/Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu --with-gnu-as --with-as=/usr/local/bin/gas --with-gnu-ld --with-ld=/usr/local/bin/gld --with-cpu=native --with-arch=native --enable-languages=c,c++ --with-gmp=/Tools/SunOS_5.11_i86pc_amd64/gmp-6.0.0a --with-mpfr=/Tools/SunOS_5.11_i86pc_amd64/mpfr-3.1.2 --with-mpc=/Tools/SunOS_5.11_i86pc_amd64/mpc-1.0.2 --with-isl=/Tools/SunOS_5.11_i86pc_amd64/isl-0.12.2 --with-cloog=/Tools/SunOS_5.11_i86pc_amd64/cloog-0.18.1 CC='gcc -m64' CXX='g++ -m64' LDFLAGS='-R/Tools/SunOS_5.11_i86pc_amd64/gmp-6.0.0a/lib -R/Tools/SunOS_5.11_i86pc_amd64/mpfr-3.1.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/mpc-1.0.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/isl-0.12.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/cloog-0.18.1/lib'

Bootstrap command:
gmake BOOT_LDFLAGS='-R/Tools/SunOS_5.11_i86pc_amd64/gmp-6.0.0a/lib -R/Tools/SunOS_5.11_i86pc_amd64/mpfr-3.1.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/mpc-1.0.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/isl-0.12.2/lib -R/Tools/SunOS_5.11_i86pc_amd64/cloog-0.18.1/lib' BUILD_CONFIG=bootstrap-lto profiledbootstrap

Failing command:

/export/data/build/gcc-4.9.2-obj/./prev-gcc/xgcc -B/export/data/build/gcc-4.9.2-obj/./prev-gcc/ -B/Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu/x86_64-pc-solaris2.11/bin/ -B/Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu/x86_64-pc-solaris2.11/bin/ -B/Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu/x86_64-pc-solaris2.11/lib/ -isystem /Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu/x86_64-pc-solaris2.11/include -isystem /Tools/SunOS_5.11_i86pc_amd64/gcc-4.9.2-allgnu/x86_64-pc-solaris2.11/sys-include    -c -DHAVE_CONFIG_H -g -O2 -flto=jobserver -frandom-seed=1 -ffat-lto-objects -fprofile-use  -I. -I../../gcc-4.9.2/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  ../../gcc-4.9.2/libiberty/regex.c -o regex.o
../../gcc-4.9.2/libiberty/regex.c: In function 'byte_re_match_2_internal':
../../gcc-4.9.2/libiberty/regex.c:8128:1: internal compiler error: in streamer_write_gcov_count_stream, at data-streamer-out.c:303
 }
 ^
0x136348a streamer_write_gcov_count_stream
        ../../gcc-4.9.2/gcc/data-streamer-out.c:303
0x136348a streamer_write_gcov_count(output_block*, long)
        ../../gcc-4.9.2/gcc/data-streamer-out.c:188
0xf4270d stream_out_histogram_value(output_block*, histogram_value_t*)
        ../../gcc-4.9.2/gcc/value-prof.c:388
0x138c4c4 output_gimple_stmt
        ../../gcc-4.9.2/gcc/gimple-streamer-out.c:185
0x138c4c4 output_bb(output_block*, basic_block_def*, function*)
        ../../gcc-4.9.2/gcc/gimple-streamer-out.c:215
0xa99095 output_function
        ../../gcc-4.9.2/gcc/lto-streamer-out.c:1892
0xa99095 lto_output()
        ../../gcc-4.9.2/gcc/lto-streamer-out.c:2084
0xaf5b07 write_lto
        ../../gcc-4.9.2/gcc/passes.c:2298
0xaf806f ipa_write_summaries_1
        ../../gcc-4.9.2/gcc/passes.c:2360
0xaf806f ipa_write_summaries()
        ../../gcc-4.9.2/gcc/passes.c:2417
0x769323 ipa_passes
        ../../gcc-4.9.2/gcc/cgraphunit.c:2078
0x769323 compile()
        ../../gcc-4.9.2/gcc/cgraphunit.c:2174
0x76b3ac finalize_compilation_unit()
        ../../gcc-4.9.2/gcc/cgraphunit.c:2329
0x5a4bc3 c_write_global_declarations()
        ../../gcc-4.9.2/gcc/c/c-decl.c:10401
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Carson Gaspar 2015-01-17 00:44:20 UTC
Created attachment 34467 [details]
preprocessed regex.i
Comment 2 Carson Gaspar 2015-01-17 00:46:03 UTC
Removing -fprofile-use also makes the compilation work, so it appears to be a problem with profile feedback combined with LTO. Either works individually, but error out if used together.
Comment 3 Martin Liška 2017-05-05 10:50:38 UTC
Hi. Can you please test it with a new release of GCC? If yes, then please attach the pre-processed file and regex.gcda file that's needed for -fprofile-use.
Comment 4 John Paul Adrian Glaubitz 2019-08-17 16:11:44 UTC
This looks very similar to the failure on linux-sparc64 with LTO enabled:

../../src/libiberty/strerror.c: In function 'strtoerrno':
../../src/libiberty/strerror.c:773:1: warning: '/<<PKGBUILDDIR>>/build/libiberty/strerror.gcda' profile count data file not found [-Wmissing-profile]
  773 | }
      | ^
../../src/libiberty/strsignal.c: In function 'strtosigno':
../../src/libiberty/strsignal.c:536:1: warning: '/<<PKGBUILDDIR>>/build/libiberty/strsignal.gcda' profile count data file not found [-Wmissing-profile]
  536 | }
      | ^
during IPA pass: pure-const
../../src/libiberty/simple-object.c: In function 'simple_object_write_add_data':
../../src/libiberty/simple-object.c:565:1: internal compiler error: in stream_out_histogram_value, at value-prof.c:369
  565 | }
      | ^
if [ x"" != x ]; then \
  /<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/lib/ -isystem /usr/sparc64-linux-gnu/include -isystem /usr/sparc64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include    -c -DHAVE_CONFIG_H -g -O2 -fprofile-use -flto=jobserver  -I. -I../../src/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE -fPIC  ../../src/libiberty/simple-object-elf.c -o noasan/simple-object-elf.o; \
else true; fi
/<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/lib/ -isystem /usr/sparc64-linux-gnu/include -isystem /usr/sparc64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include    -c -DHAVE_CONFIG_H -g -O2 -fprofile-use -flto=jobserver  -I. -I../../src/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE ../../src/libiberty/simple-object-elf.c -o simple-object-elf.o
../../src/libiberty/cp-demangle.c: In function 'd_print_cast.isra.0':
../../src/libiberty/cp-demangle.c:6648:1: warning: '/<<PKGBUILDDIR>>/build/libiberty/pic/cp-demangle.gcda' profile count data file not found [-Wmissing-profile]
 6648 | }
      | ^
../../src/libiberty/regex.c: In function 'xregfree':
../../src/libiberty/regex.c:8131:1: warning: '/<<PKGBUILDDIR>>/build/libiberty/pic/regex.gcda' profile count data file not found [-Wmissing-profile]
 8131 | }
      | ^
configure: creating cache ./config.cache
checking build system type... sparc64-unknown-linux-gnu
checking host system type... sparc64-unknown-linux-gnu
checking target system type... sparc64-unknown-linux-gnu
checking whether /usr/bin/make sets $(MAKE)... if [ x"" != x ]; then \
  /<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/lib/ -isystem /usr/sparc64-linux-gnu/include -isystem /usr/sparc64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include    -c -DHAVE_CONFIG_H -g -O2 -fprofile-use -flto=jobserver  -I. -I../../src/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE -fPIC  ../../src/libiberty/regex.c -o noasan/regex.o; \
else true; fi
/<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/lib/ -isystem /usr/sparc64-linux-gnu/include -isystem /usr/sparc64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include    -c -DHAVE_CONFIG_H -g -O2 -fprofile-use -flto=jobserver  -I. -I../../src/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE ../../src/libiberty/regex.c -o regex.o
if [ x"" != x ]; then \
  /<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/bin/ -B/usr/sparc64-linux-gnu/lib/ -isystem /usr/sparc64-linux-gnu/include -isystem /usr/sparc64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include    -c -DHAVE_CONFIG_H -g -O2 -fprofile-use -flto=jobserver  -I. -I../../src/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE -fPIC  ../../src/libiberty/cp-demangle.c -o noasan/cp-demangle.o; \
else true; fi
yes
checking for a BSD-compatible install... 0x9ab447 stream_out_histogram_value(output_block*, histogram_value_t*)
	../../src/gcc/value-prof.c:369
/usr/bin/install -c

Full log in: https://buildd.debian.org/status/fetch.php?pkg=gcc-9&arch=sparc64&ver=9.2.1-1&stamp=1565961822&raw=0
Comment 5 John Paul Adrian Glaubitz 2019-08-18 18:00:53 UTC
I can confirm that disabling LTO on sparc64 makes gcc build fine.
Comment 6 Martin Liška 2019-08-23 07:37:39 UTC
Can you please debug the internal compiler error?
I'm interested in how 'hist' struct looks like?
Comment 7 John Paul Adrian Glaubitz 2019-08-23 07:41:51 UTC
(In reply to Martin Liška from comment #6)
> Can you please debug the internal compiler error?
> I'm interested in how 'hist' struct looks like?

The gcc compile farm has a fast sparc64 porterbox running Debian unstable, so if you want, you can try it yourself.
Comment 8 Martin Liška 2019-08-23 08:56:34 UTC
(In reply to John Paul Adrian Glaubitz from comment #7)
> (In reply to Martin Liška from comment #6)
> > Can you please debug the internal compiler error?
> > I'm interested in how 'hist' struct looks like?
> 
> The gcc compile farm has a fast sparc64 porterbox running Debian unstable,
> so if you want, you can try it yourself.

Good, I have access to the compile farm machine. So let me take a look..
Comment 9 Martin Liška 2019-08-26 10:05:53 UTC
Sorry, but I can't reproduce that. I'll only need to be send the problematic *.gcda file for which you see ICE in stream_out_histogram_value.
Thanks.
Comment 10 Viktor Ostashevskyi 2020-05-13 20:21:19 UTC
Hello,

During GCC 10.1.0 bootstrap in LTO+PGO mode, configured as:

Configured with: ../gcc-10.1.0/configure --disable-multiarch --disable-libquadmath --disable-libquadmath-support --disable-libssp --disable-libstdcxx-pch --disable-multilib --disable-nls --enable-checking=release --enable-__cxa_atexit --enable-languages=c,c++ --enable-libstdcxx-debug --enable-lto --enable-plugin --enable-threads=posix --enable-tls --with-build-config=bootstrap-lto --with-default-libstdcxx-abi=gcc4-compatible --with-linker-hash-style=gnu --with-system-zlib --with-zstd=no --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu

I got following ICE:

/ostash/buildtc10/gcc-10.1.0-build/./prev-gcc/xgcc -B/ostash/buildtc10/gcc-10.1.0-build/./prev-gcc/ -B/ostash/tc10/x86_64-pc-linux-gnu/bin/ -B/ostash/tc10/x86_64-pc-linux-gnu/bin/ -B/ostash/tc10/x86_64-pc-linux-gnu/lib/ -isystem /ostash/tc10/x86_64-pc-linux-gnu/include -isystem /ostash/tc10/x86_64-pc-linux-gnu/sys-include    -c -DHAVE_CONFIG_H -fprofile-use -flto=jobserver -frandom-seed=1  -I. -I../../gcc-10.1.0/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE -fcf-protection ../../gcc-10.1.0/libiberty/hashtab.c -o hashtab.o
during IPA pass: fnsummary
../../gcc-10.1.0/libiberty/hashtab.c:997:1: internal compiler error: in stream_out_histogram_value, at value-prof.c:338
  997 | }
      | ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
make[3]: *** [hashtab.o] Error 1
make[3]: Leaving directory `/ostash/buildtc10/gcc-10.1.0-build/libiberty'
make[2]: *** [all-stagefeedback-libiberty] Error 2
make[2]: Leaving directory `/ostash/buildtc10/gcc-10.1.0-build'
make[1]: *** [stagefeedback-bubble] Error 2
make[1]: Leaving directory `/ostash/buildtc10/gcc-10.1.0-build'
make: *** [profiledbootstrap] Error 2


I can provide gcda files if needed.
Comment 11 George R. Goffe 2020-06-16 20:06:20 UTC
Created attachment 48747 [details]
preprocessed abstract.c produced by -S --save-temps gcc flag
Comment 12 George R. Goffe 2020-06-16 20:09:19 UTC
Hi,

I am seeing a failure in stream_out_histogram_value building the last release of python 2.x ( 2.7.18).

I just posted the preprocessed c code for this problem.

Here is the failing command and following output:

/tools/python/Python-2.7.18# gcc -S --save-temps  -pthread -c -fno-strict-aliasing -g -O2 -g -O0 -Wall -Wstrict-prototypes  -fprofile-use -fprofile-correction -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -g -I. -IInclude -I./Include  -fPIC -DPy_BUILD_CORE -o Objects/abstract.o Objects/abstract.c
during IPA pass: fnsummary
Objects/abstract.c:3124:1: internal compiler error: in stream_out_histogram_value, at value-prof.c:336
 3124 | }
      | ^
0x70b9a4 stream_out_histogram_value(output_block*, histogram_value_t*)
        ../../gcc/gcc/value-prof.c:336
0x16170b0 output_gimple_stmt
        ../../gcc/gcc/gimple-streamer-out.c:196
0x16170b0 output_bb(output_block*, basic_block_def*, function*)
        ../../gcc/gcc/gimple-streamer-out.c:231
0xbfa9b4 output_function
        ../../gcc/gcc/lto-streamer-out.c:2198
0xbfa9b4 lto_output()
        ../../gcc/gcc/lto-streamer-out.c:2530
0xc91241 write_lto
        ../../gcc/gcc/passes.c:2612
0xc91241 ipa_write_summaries_1
        ../../gcc/gcc/passes.c:2676
0xc91241 ipa_write_summaries()
        ../../gcc/gcc/passes.c:2731
0x9230ab ipa_passes
        ../../gcc/gcc/cgraphunit.c:2650
0x9230ab symbol_table::compile()
        ../../gcc/gcc/cgraphunit.c:2737
0x924d3c symbol_table::compile()
        ../../gcc/gcc/cgraphunit.c:2717
0x924d3c symbol_table::finalize_compilation_unit()
        ../../gcc/gcc/cgraphunit.c:2984
Comment 13 George R. Goffe 2020-06-16 20:13:31 UTC
Hi,

I see that I forgot to mention that the failure generated above was made with the "latest" gcc in the repo. revision at 280157
Comment 14 Martin Liška 2020-09-25 14:21:20 UTC
Confirmed.
Comment 15 GCC Commits 2020-09-25 14:26:36 UTC
The master branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:1921ebcaf6467996aede69e1bbe32400d8a20fe7

commit r11-3463-g1921ebcaf6467996aede69e1bbe32400d8a20fe7
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Sep 25 16:21:34 2020 +0200

    gcov: fix streaming of HIST_TYPE_IOR histogram type.
    
    gcc/ChangeLog:
    
            PR gcov-profile/64636
            * value-prof.c (stream_out_histogram_value): Allow negative
            values for HIST_TYPE_IOR.
Comment 16 Martin Liška 2020-09-25 14:27:58 UTC
Fixed on master so far.
Comment 17 GCC Commits 2020-10-01 19:20:00 UTC
The releases/gcc-10 branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:84dc3879f377ddaecb4054a7bf7671114dfb7228

commit r10-8840-g84dc3879f377ddaecb4054a7bf7671114dfb7228
Author: Martin Liska <mliska@suse.cz>
Date:   Fri Sep 25 16:21:34 2020 +0200

    gcov: fix streaming of HIST_TYPE_IOR histogram type.
    
    gcc/ChangeLog:
    
            PR gcov-profile/64636
            * value-prof.c (stream_out_histogram_value): Allow negative
            values for HIST_TYPE_IOR.
    
    (cherry picked from commit 1921ebcaf6467996aede69e1bbe32400d8a20fe7)
Comment 18 GCC Commits 2020-10-02 10:06:13 UTC
The releases/gcc-9 branch has been updated by Martin Liska <marxin@gcc.gnu.org>:

https://gcc.gnu.org/g:7c55364eaaf5f882e80e8943e702081f9648f582

commit r9-8968-g7c55364eaaf5f882e80e8943e702081f9648f582
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Oct 1 21:28:30 2020 +0200

    gcov: fix streaming of HIST_TYPE_IOR histogram type.
    
    gcc/ChangeLog:
    
            PR gcov-profile/64636
            * value-prof.c (stream_out_histogram_value): Allow negative
            values for HIST_TYPE_IOR.
    
    (cherry picked from commit 1921ebcaf6467996aede69e1bbe32400d8a20fe7)
Comment 19 Martin Liška 2020-10-02 10:07:41 UTC
Resolved.
Comment 20 Andrew Pinski 2021-10-02 07:59:51 UTC
*** Bug 72848 has been marked as a duplicate of this bug. ***