Bug 1305391

Summary: profiledbootstrap ICE in reg_save_code at ../../gcc/caller-save.c:141
Product: [Fedora] Fedora Reporter: Martin Sebor <msebor>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 24CC: davejohansen, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: ppc64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-27 08:42:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test case reduced from libgcc2.c. none

Description Martin Sebor 2016-02-07 23:08:17 UTC
Created attachment 1122043 [details]
Test case reduced from libgcc2.c.

The following build of GCC 6.0 failed while building libgcc with the error below
http://ppc.koji.fedoraproject.org/koji/taskinfo?taskID=3121923

../../../libgcc/libgcc2.c: In function '__multc3':
../../../libgcc/libgcc2.c:1992:1: internal compiler error: Segmentation fault
 }
 ^
0x10324b07 crash_signal
        ../../gcc/toplev.c:335
0x10ea4c14 reg_save_code
        ../../gcc/caller-save.c:141
0x1064c76f insert_save
        ../../gcc/caller-save.c:1316
0x1064c76f save_call_clobbered_regs()
        ../../gcc/caller-save.c:863
0x1096843f reload(rtx_insn*, int)
        ../../gcc/reload1.c:990
0x10867447 do_reload
        ../../gcc/ira.c:5407
0x10867447 execute
        ../../gcc/ira.c:5566
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugzilla.redhat.com/bugzilla> for instructions.

The affected file can be reduced the attached test case.  The full stack trace with the test case is below

% /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/./gcc/xgcc -B/builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/./gcc -O2 -mlong-double-128 -c libgcc2.c -wrapper gdb,-q,--args
Reading symbols from /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/./gcc/cc1...done.
(gdb) r
Starting program: /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/gcc/cc1 -quiet -iprefix /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/gcc/../lib/gcc/ppc64-redhat-linux/6.0.0/ -isystem /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/./gcc/include -isystem /builddir/build/BUILD/gcc-6.0.0-20160205/obj-ppc64-redhat-linux/./gcc/include-fixed -D__unix__ -D__gnu_linux__ -D__linux__ -Dunix -D__unix -Dlinux -D__linux -Asystem=linux -Asystem=unix -Asystem=posix libgcc2.c -msecure-plt -quiet -dumpbase libgcc2.c -mlong-double-128 -auxbase libgcc2 -O2 -o /tmp/ccc9M8r8.s
Missing separate debuginfos, use: dnf debuginfo-install glibc-2.22.90-31.fc24.ppc64p7

Program received signal SIGSEGV, Segmentation fault.
0x0000000010ea4c14 in reg_save_code (reg=<optimized out>, mode=<optimized out>)
    at ../../gcc/caller-save.c:141
141		&& cached_reg_restore_code[reg][mode] != -1);
Missing separate debuginfos, use: dnf debuginfo-install gmp-6.1.0-1.fc24.ppc64 libmpc-1.0.2-4.fc23.ppc64 mpfr-3.1.3-3.fc24.ppc64 zlib-1.2.8-9.fc24.ppc64
(gdb) bt
#0  0x0000000010ea4c14 in reg_save_code (reg=<optimized out>, 
    mode=<optimized out>) at ../../gcc/caller-save.c:141
#1  0x000000001064c770 in insert_save (before_p=1, save_mode=0x3fffffffe1b4, 
    to_save=0x3fffffffe180, regno=44, chain=<optimized out>)
    at ../../gcc/caller-save.c:1316
#2  save_call_clobbered_regs () at ../../gcc/caller-save.c:863
#3  0x0000000010968440 in reload (first=0x3fffaf182e28, global=<optimized out>)
    at ../../gcc/reload1.c:990
#4  0x0000000010867448 in do_reload () at ../../gcc/ira.c:5407
#5  (anonymous namespace)::pass_reload::execute (this=<optimized out>)
    at ../../gcc/ira.c:5566
#6  0x00000000108d9bfc in execute_one_pass (pass=0x11793590)
    at ../../gcc/passes.c:2336
#7  0x00000000108de1fc in execute_pass_list_1 (pass=0x11793590)
    at ../../gcc/passes.c:2410
#8  execute_pass_list_1 (pass=0x11792510) at ../../gcc/passes.c:2411
#9  execute_pass_list (fn=0x3fffaf03a4b8, pass=<optimized out>)
    at ../../gcc/passes.c:2421
#10 0x0000000010eb3f78 in cgraph_node::expand (this=0x3fffaefe1700)
    at ../../gcc/cgraphunit.c:1974
#11 expand_all_functions () at ../../gcc/cgraphunit.c:2110
#12 symbol_table::compile (this=this@entry=0x3fffaef80000)
    at ../../gcc/cgraphunit.c:2466
#13 0x00000000106b09c0 in symbol_table::finalize_compilation_unit (
    this=0x3fffaef80000) at ../../gcc/cgraphunit.c:2556
#14 0x0000000010f4c028 in compile_file () at ../../gcc/toplev.c:490
#15 0x00000000105974a8 in do_compile () at ../../gcc/toplev.c:1988
#16 toplev::main (this=<optimized out>, argc=<optimized out>, 
    argv=<optimized out>) at ../../gcc/toplev.c:2096
#17 0x000000001059973c in main (argc=<optimized out>, argv=0x3ffffffff198)
    at ../../gcc/main.c:39

Comment 1 Martin Sebor 2016-02-07 23:21:00 UTC
I haven't been able to reproduce it on trunk because of the problems mentioned in upstream bug 65313 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65313) but a search through Bugzilla returns bug 68404 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68404) which describes an ICE similar to this one seen on powerpc64le.

Comment 2 Martin Sebor 2016-02-08 22:20:09 UTC
A few additional details after initial investigation:

1) Based on the -fprofile-generate command line option and the contents of the stage_current file in the build director y the ICE occurs during the stagefeedback stage.  Stage 1 gcc doesn't ICE on the test case.
2) According to Jakub, the 6.0.0-0.9 version of GCC builds fine, so problem was introduced among the changes brought over from trunk in 6.0.0-0.10 (i.e., in one of the patches or between r233052, last working revision of trunk, and r233185, the first broken revision).
3) After reviewing the changes referenced in the changelog entry corresponding to 6.0.0-0.10, the patch committed in to fix tl-optimization/69567 - PowerPC64: cstore optimisation produces bad code seemed like it could be responsible.  However, the ICE can still be reproduced even with that patched backed out, so the problem must be somewhere else.

As an aside, the successful 6.0.0-0.10 build subsequent to the failed task mentioned in the Description was that of an ordinary bootstrap, not profiledbootstrap:
http://ppc.koji.fedoraproject.org/koji/buildinfo?buildID=368892.

Comment 3 Martin Sebor 2016-02-09 05:01:32 UTC
Reproduced on trunk and raised bootstrap/69727:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69727

Comment 4 Jan Kurik 2016-02-24 14:26:07 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 5 Jakub Jelinek 2016-02-27 08:42:19 UTC
Should be fixed in gcc-6.0.0-0.12.fc24.