Stage 1 compiler from revision 133835 failed to compile binutils: [hjl@dad binutils]$ /export/build/gnu/tools/build-x86_64-linux/./prev-gcc/xgcc -B/export/build/gnu/tools/build-x86_64-linux/./prev-gcc/ -B/usr/gcc-4.4/x86_64-unknown-linux-gnu/bin/ -DHAVE_CONFIG_H -I. -I/export/gnu/src/tools/tools/binutils -I. -I. -I/export/gnu/src/tools/tools/binutils -I../bfd -I/export/gnu/src/tools/tools/binutils/../bfd -I/export/gnu/src/tools/tools/binutils/../include -DLOCALEDIR="\"/usr/gcc-4.4/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Werror -g -O2 -c /export/gnu/src/tools/tools/binutils/stabs.c /export/gnu/src/tools/tools/binutils/stabs.c: In function ‘stab_find_type’: /export/gnu/src/tools/tools/binutils/stabs.c:3318: 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. Program received signal SIGSEGV, Segmentation fault. 0x00000000005c3b09 in mark_jump_label_1 (x=0x0, insn=0x0, in_mem=0 '\0', is_target=1 '\001') at /export/gnu/src/tools/tools/gcc/jump.c:989 989 RTX_CODE code = GET_CODE (x); Missing separate debuginfos, use: debuginfo-install glibc.x86_64 (gdb) bt #0 0x00000000005c3b09 in mark_jump_label_1 (x=0x0, insn=0x0, in_mem=0 '\0', is_target=1 '\001') at /export/gnu/src/tools/tools/gcc/jump.c:989 #1 0x00000000005c3db0 in mark_jump_label_1 (x=0x2aaaab86d6b0, insn=0x2aaaab8a1cd0, in_mem=0 '\0', is_target=1 '\001') at /export/gnu/src/tools/tools/gcc/jump.c:1087 #2 0x00000000005c3aea in mark_jump_label (x=0x2aaaab86d6b0, insn=0x2aaaab8a1cd0, in_mem=0) at /export/gnu/src/tools/tools/gcc/jump.c:976 #3 0x00000000005c27a3 in mark_all_labels (f=0x2aaaab4330c0) at /export/gnu/src/tools/tools/gcc/jump.c:196 #4 0x00000000005c2587 in rebuild_jump_labels (f=0x2aaaab4330c0) at /export/gnu/src/tools/tools/gcc/jump.c:86 #5 0x0000000000a65513 in tree_expand_cfg () at /export/gnu/src/tools/tools/gcc/cfgexpand.c:1923 #6 0x00000000006060f1 in execute_one_pass (pass=0x102a260) at /export/gnu/src/tools/tools/gcc/passes.c:1127 #7 0x0000000000606249 in execute_pass_list (pass=0x102a260) at /export/gnu/src/tools/tools/gcc/passes.c:1180 #8 0x00000000006fcbd8 in tree_rest_of_compilation (fndecl=0x2aaaaaf87820) at /export/gnu/src/tools/tools/gcc/tree-optimize.c:420 #9 0x000000000085c758 in cgraph_expand_function (node=0x2aaaab0d3d00) at /export/gnu/src/tools/tools/gcc/cgraphunit.c:1157 #10 0x000000000085c908 in cgraph_expand_all_functions () ---Type <return> to continue, or q <return> to quit--- q at /export/gnu/src/toolQuit Revision 133718 is OK.
Created attachment 15410 [details] A testcase [hjl@dad binutils]$ /export/build/gnu/tools/build-x86_64-linux/./prev-gcc/xgcc -B/export/build/gnu/tools/build-x86_64-linux/./prev-gcc/ -O2 -S stabs.i /export/gnu/src/tools/tools/binutils/stabs.c: In function ‘stab_find_type’: /export/gnu/src/tools/tools/binutils/stabs.c:3318: 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. [hjl@dad binutils]$
This is likely caused by http://gcc.gnu.org/ml/gcc-cvs/2008-04/msg00059.html. Reducing.
(In reply to comment #2) > This is likely caused by http://gcc.gnu.org/ml/gcc-cvs/2008-04/msg00059.html. > > Reducing. > http://gcc.gnu.org/ml/gcc-cvs/2008-04/msg00059.html is revision 133835. Revision 133834 passed the failed point.
Created attachment 15414 [details] reduced testcase Reduced testcase, fails with -O -ftree-vrp -fno-inline. Program received signal SIGSEGV, Segmentation fault. 0x000000000075e3e4 in mark_jump_label_1 (x=0x0, insn=0x0, in_mem=0 '\0', is_target=1 '\001') at /space/rguenther/src/svn/trunk/gcc/jump.c:989 989 RTX_CODE code = GET_CODE (x); #0 0x000000000075e3e4 in mark_jump_label_1 (x=0x0, insn=0x0, in_mem=0 '\0', is_target=1 '\001') at /space/rguenther/src/svn/trunk/gcc/jump.c:989 #1 0x000000000075e7f7 in mark_jump_label_1 (x=0x2b658e3e1f10, insn=0x2b658eccd960, in_mem=0 '\0', is_target=1 '\001') at /space/rguenther/src/svn/trunk/gcc/jump.c:1087 #2 0x000000000075e3c5 in mark_jump_label (x=0x2b658e3e1f10, insn=0x2b658eccd960, in_mem=0) at /space/rguenther/src/svn/trunk/gcc/jump.c:976 #3 0x000000000075cf52 in mark_all_labels (f=0x2b658ecd6600) at /space/rguenther/src/svn/trunk/gcc/jump.c:196 #4 0x000000000075ccf3 in rebuild_jump_labels (f=0x2b658ecd6600) at /space/rguenther/src/svn/trunk/gcc/jump.c:86 #5 0x0000000000de7232 in tree_expand_cfg () (I have to run now.)
So we have (addr_vec:DI [ (nil) (label_ref:DI 26) (label_ref:DI 26) (label_ref:DI 26) (label_ref:DI 26) ...
Created attachment 15415 [details] another reduced testcase, -O2 I see attachment #2 [details] there, but as long as I did a reduction too, here's another, a wee bit smaller and no extra warnings at -W -Wall -Wextra. This fails at -O2 both for native x86_64 as well as cris-elf, just like the original stabs.i testcase. FWIW, the same bug causes failure to build newlib/libc/stdlib/dtoa.c for cris-elf, but that .i doesn't trig the bug for x86_64.
It's not just about creating a properly filled (or handling the NULLs in the) addr_vec after generating the tablejump or casesi: for machines with casesi, passing a NULL default_label (operand[4]; fifth operand) is...unexpected. While this could be pushed from the middle-end to the target domain by defining the NULL default label as a valid case that the target casesi pattern must handle (hard to do without casesi being a define_expand), I think it'd be better to just pass any label as default_label any at the try_casesi call. Here's a related minor optimization opportunity for casesi: if default_label is set to the last case label, the max index / the range and the table size, can be shrunk by one.
Hm, yeah. The trick of course is to not emit the jump to the default label. For the tablejump case it may be easiest to just use any other label. I'll see if that works.
(In reply to comment #8) > Hm, yeah. The trick of course is to not emit the jump to the default label. > For > the tablejump case it may be easiest to just use any other label. I'll see if > that works. > Can we add a run-time testcase to make sure that the result is correct?
Ah, the following /* Index jumptables from zero for suitable values of minval to avoid a subtraction. */ if (! optimize_size && compare_tree_int (minval, 0) > 0 && compare_tree_int (minval, 3) < 0) { minval = build_int_cst (index_type, 0); range = maxval; } relies on the created hole be filled by the default_label - but that is NULL here. So, the following looks like the right fix here: Index: stmt.c =================================================================== --- stmt.c (revision 133848) +++ stmt.c (working copy) @@ -2566,11 +2566,15 @@ expand_case (tree exp) = gen_rtx_LABEL_REF (Pmode, label_rtx (n->code_label)); } - /* Fill in the gaps with the default. */ - if (default_label) - for (i = 0; i < ncases; i++) - if (labelvec[i] == 0) - labelvec[i] = gen_rtx_LABEL_REF (Pmode, default_label); + /* Fill in the gaps with the default. We may have gaps at + the beginning if we tried to avoid the minval subtraction, + so substitute some label even if the default label was + deemed unreachable. */ + if (!default_label) + default_label = label_rtx (case_list->code_label); + for (i = 0; i < ncases; i++) + if (labelvec[i] == 0) + labelvec[i] = gen_rtx_LABEL_REF (Pmode, default_label); /* Output the table. */ emit_label (table_label);
For now I have a compile-time testcase - I'll try to transform it into a runtime one.
In reply to comment #10) > relies on the created hole be filled by the default_label - but that is > NULL here. So, the following looks like the right fix here: > > Index: stmt.c That's too late; it's not enough for casesi targets for the reason I outline in comment #7.
Created attachment 15416 [details] patch Patch in comment #10 passed bootstrap & regtest on x86_64-unknown-linux-gnu, the attached patch should also fix comment #7, testing is in progess. If anyone beats me on it the patch is ok for trunk.
The fallback_label parm of try_casesi needs ATTRIBUTE_UNUSED for ! HAVE_casesi targets.
*** Bug 35808 has been marked as a duplicate of this bug. ***
Subject: Bug 35800 Author: hp Date: Thu Apr 3 02:08:13 2008 New Revision: 133856 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133856 Log: PR middle-end/35800 * gcc.c-torture/execute/pr35800.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr35800.c Modified: trunk/gcc/testsuite/ChangeLog
Subject: Bug 35800 Author: hp Date: Thu Apr 3 02:09:20 2008 New Revision: 133857 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133857 Log: PR middle-end/35800 * expr.h (try_casesi): Adjust prototype. * expr.c (try_casesi): Take fallback label as extra parameter. Use that for gen_casesi if default_label is NULL. * stmt.c (expand_case): Pass fallback label to try_casesi, make sure to fill gaps with a fallback label if default_label is not present. Modified: trunk/gcc/ChangeLog trunk/gcc/expr.c trunk/gcc/expr.h trunk/gcc/stmt.c
I presume we can close this one as <http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00240.html> (comment #13 and comment #13) has been committed.
s/13 and 13/13 and 14/ in comment #18