GCC Bugzilla – Bug 17428
internal compiler error: in spill_failure, at reload1.c:1880 (-fspeculative-prefetching)
Last modified: 2005-07-29 09:42:05 UTC
error in gcc version 4.0.0 20040912 (experimental). Error occured when compiling gcc with itself (during Bootstrapping training compiler) using the following configure command: ../gcc/configure --prefix=/beta/ --enable-shared --enable-languages=c,c++,objc --enable-threads=posix --enable-__cxa_atexit --disable-libgcj --enable-libada and the following make command: export CFLAGS="-mmmx -msse -msse2 -march=pentium4 -mfpmath=sse -maccumulate-outgoing-args -O2 -fgcse-after-reload -fmodulo-sched -fweb -funroll-loops -fprefetch-loop-arrays -floop-optimize2 -fsched-spec-load -ftree-loop-linear -ftree-vectorize -fomit-frame-pointer -pipe -s" make BOOT_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STAGE1_CFLAGS="$CFLAGS" profiledbootstrap on gcc/gengtype.c, the compiler fails with: stage1/xgcc -Bstage1/ -B/beta//i686-pc-linux-gnu/bin/ -c -mmmx -msse -msse2 -march=pentium4 -mfpmath=sse -maccumulate-outgoing-args -O2 -fgcse-after-reload -fmodulo-sched -fweb -funroll-loops -fprefetch-loop-arrays -floop-optimize2 -fsched-spec-load -ftree-loop-linear -ftree-vectorize -fomit-frame-pointer -pipe -s -save-temps -fprofile-generate -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Werror -fno-common -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -I. -I../../gcc/gcc -I../../gcc/gcc/. -I../../gcc/gcc/../include -I../../gcc/gcc/../libcpp/include \ ../../gcc/gcc/gengtype.c -o gengtype.o ../../gcc/gcc/gengtype.c: In function `finish_root_table': ../../gcc/gcc/gengtype.c:2501: error: unable to find a register to spill in class `AD_REGS' ../../gcc/gcc/gengtype.c:2501: error: this is the insn: (insn:HI 987 82 988 113 (parallel [ (set (reg:DI 486 [ ivtmp.762 ]) (sign_extend:DI (reg/f:SI 60 [ ivtmp.762 ]))) (clobber (reg:CC 17 flags)) (clobber (scratch:SI)) ]) 85 {*extendsidi2_1} (nil) (expr_list:REG_UNUSED (scratch:SI) (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_UNUSED (scratch:SI) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil)))))) ../../gcc/gcc/gengtype.c:2501: internal compiler error: in spill_failure, at reload1.c:1880 Please submit a full bug report, with preprocessed source if appropriate. the gengtype.i was rather large, so instead of pasting it here it can be found at: http://linux-militia.net/kernel/stuff/gengtype.i
I should also note that it works with CFLAGS as -O2, but fails with -O2 -march=pentium4, so it looks like -march=pentium4 is the culprit..
*** Bug 17429 has been marked as a duplicate of this bug. ***
*** Bug 17430 has been marked as a duplicate of this bug. ***
Here's a reduced testcase. It crashes when compiled with "gcc -msse -O2 -fprofile-generate" ====================================== int a[2]; static void foo(int i, int j) { while (1) ; } void bar() { int i; for (i=0; i<2; ++i) foo(a[i],0); foo(0,0); } ====================================== Phil's regression hunter states: : Search converges between 2004-09-05-trunk (#534) and 2004-09-06-trunk (#535).
I would assume that this is caused by: 2004-09-05 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> * tree-ssa-loop-ivopts.c: New file. .... But then again this most likely can be produced ealier than that or maybe not. One thing I noticed though is that "&a[0] + 8B" not folded to &a[2] which might improve the issue.
Subject: Re: [4.0 Regression] internal compiler error: in spill_failure, at reload1.c:1880 Hello, > I would assume that this is caused by: > 2004-09-05 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> > > * tree-ssa-loop-ivopts.c: New file. > .... > > But then again this most likely can be produced ealier than that or maybe not. > > One thing I noticed though is that "&a[0] + 8B" not folded to &a[2] > which might improve the issue. I doubt this is the case; both &a[2] and "&a[0] + 8B" should produce identical rtl (and anyway, there is nothing wrong with &a[0] + 8B, so I guess the problem must be elsewhere). I will check tomorrow. Zdenek
This is caused by speculative prefetching. The problem is in code like this: (insn 14 12 15 1 (set (reg:SI 1 dx) (const_int 0 [0x0])) -1 (nil) (nil)) (insn 15 14 16 1 (set (reg:SI 0 ax) (mem/s:SI (reg/f:SI 62 [ ivtmp.5 ]) [2 a S4 A8])) -1 (nil) (nil)) (call_insn 16 15 17 1 (call (mem:QI (symbol_ref:SI ("foo") [flags 0x3] <function_decl 0x40206ae0 foo>) [0 S1 A8]) (const_int 0 [0x0])) -1 (nil) (expr_list:REG_EH_REGION (const_int 0 [0x0]) (nil)) (expr_list (use (reg:SI 0 ax)) (expr_list (use (reg:SI 1 dx)) (nil)))) Now we issue a profiling code for mem in insn 15. This causes life range of dx to be prolonged, and ICE follows. safe_insert_insn_on_edge needs to be extended to handle this, somehow.
This is related to PR 17491 then.
Patch: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02116.html
Patch fixes it, not yet submitted to cvs however.
Speculative prefetching is now disabled by default on mainline by David Edelsohn's patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg00928.html Therefore, one has to add -fspeculative-prefetching to the command line to trigger the bug on mainline.
Because of the patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01513.html that adds "-funroll-loops" to "-fprofile-generate" the testcase from comment #4 has to be compiled with "-msse -O2 -fspeculative-prefetching -fprofile-generate -fno-unroll-loops" to still trigger the bug. Alternatively one can increase the number of iterations of the loop from 2 to 20. The bug finally disappeared with Zdenek's patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01561.html which seems to address Andrew's suggestion from comment #5. Zdenek, is this a real fix or is this just papering over the problem? I.e. is your patch from comment #9 still needed or not? Alas, the original testcase still segfaults with mainline. Here's a testcase: ============================================================== int foo(int, int) __attribute__((pure)); void bar() { int i; if (foo(0,0)) for (i = 0; i < 2; i++) ; } ============================================================== Compile with "-O -march=pentium4 -fprofile-generate -fspeculative-prefetching -funroll-loops" to trigger the bug. Phils's regression tester about this bug: : Search converges between 2004-10-01-014001-trunk (#570) and 2004-10-01-161002-trunk (#571).
Zdenek, the failure in comment #12 appears with your patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg00030.html
Subject: Re: [4.0 Regression] internal compiler error: in spill_failure, at reload1.c:1880 Hello, > Because of the patch http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01513.html > that adds "-funroll-loops" to "-fprofile-generate" the testcase from > comment #4 has to be compiled with > "-msse -O2 -fspeculative-prefetching -fprofile-generate -fno-unroll-loops" > to still trigger the bug. Alternatively one can increase the number of > iterations of the loop from 2 to 20. > > The bug finally disappeared with Zdenek's patch > http://gcc.gnu.org/ml/gcc-cvs/2004-10/msg01561.html > which seems to address Andrew's suggestion from comment #5. > > Zdenek, is this a real fix or is this just papering over the problem? no, that patch cannot fix the problem; so it is just masked, and ... > I.e. is your patch from comment #9 still needed or not? ... this patch is still needed. Zdenek > > Alas, the original testcase still segfaults with mainline. Here's a testcase: > > ============================================================== > int foo(int, int) __attribute__((pure)); > > void bar() > { > int i; > > if (foo(0,0)) > for (i = 0; i < 2; i++) > ; > } > ============================================================== > > Compile with "-O -march=pentium4 -fprofile-generate -fspeculative-prefetching > -funroll-loops" > to trigger the bug. > > Phils's regression tester about this bug: > : Search converges between 2004-10-01-014001-trunk (#570) and > 2004-10-01-161002-trunk (#571). > > > -- > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17428 > > ------- You are receiving this mail because: ------- > You are on the CC list for the bug, or are watching someone who is.
Patch for the other problem: http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00260.html
Even though this huge failure, it is no longer a regression as -fspeculative-prefetching is not enabled wth -fprofile-generate/use but it still needs to be fixed but not necessarly for 4.0.0. Really someone should just approve Zdenek's fix for this.
Subject: Bug 17428 CVSROOT: /cvs/gcc Module name: gcc Changes by: rakdver@gcc.gnu.org 2005-02-14 11:37:53 Modified files: gcc : ChangeLog value-prof.c cfgrtl.c Log message: PR target/17428 * cfgrtl.c (safe_insert_insn_on_edge): Avoid extending life range of hard registers. * value-prof.c (insn_prefetch_values_to_profile): Only scan normal insns. * value-prof.c (rtl_find_values_to_profile): Do not look for values to profile in libcalls. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7467&r2=2.7468 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/value-prof.c.diff?cvsroot=gcc&r1=1.16&r2=1.17 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&r1=1.157&r2=1.158
Zdenek, are you going to add a testcase for the problem on mainline? Is this a latent problem on other branches? If not, can this PR be closed?
Zdenek, the ICE with the testcase from comment #12 reappeared on mainline. Could you please have a look?
The new failure (which is a segfault, btw) was caused by http://gcc.gnu.org/ml/gcc-cvs/2005-03/msg01363.html
Subject: Re: internal compiler error: in spill_failure, at reload1.c:1880 (-fspeculative-prefetching) Hello, > the ICE with the testcase from comment #12 reappeared on mainline. > Could you please have a look? it is because the patch you identified (http://gcc.gnu.org/ml/gcc-cvs/2005-03/msg01363.html) reverted the patch that fixed the problem (http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/value-prof.c.diff?cvsroot=gcc&r1=1.16&r2=1.17). Honza, could you please fix that? Zdenek
Any news on this one, Honza?
The testcases from comment #4 and comment #12 were fixed on the 4.0 branch. The problem persisted on mainline where -fspeculative-prefetching had to be added. Since -fspeculative-prefetching was removed yesterday (see http://gcc.gnu.org/ml/gcc-cvs/2005-07/msg01035.html ) the bug cannot be triggered on mainline anymore. So closing as fixed. Btw, the original testcase cannot be accessed anymore, so the testcases from comment #4 and #12 are all we've got.