/usr/lib/gcc/i586-suse-linux/4.1.0/cc1 -fpreprocessed builtin.i -quiet -dumpbase builtin.c -march=i586 -mtune=i686 -auxbase-strip builtin.o -O2 -Wall -Wall -version -fmessage-length=0 -fno-strict-aliasing -fprofile-arcs -o builtin.s builtin.c: In function ‘execbuiltin’: builtin.c:5173: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://www.suse.de/feedback> for instructions. (gdb) bt #0 0x0846db4d in branch_prob () at profile.c:815 #1 0x0852f803 in tree_profiling () at tree-profile.c:246 #2 0x0852f0cd in execute_one_pass (pass=0x8777060) at passes.c:827 #3 0x0852f18c in execute_pass_list (pass=0x8777060) at passes.c:859 #4 0x0852f260 in execute_ipa_pass_list (pass=0x8774a60) at passes.c:881 #5 0x085911d1 in ipa_passes () at cgraphunit.c:1221 #6 0x0859127c in cgraph_optimize () at cgraphunit.c:1255 #7 0x08068379 in c_write_global_declarations () at c-decl.c:7644 #8 0x084df96f in compile_file () at toplev.c:1003 #9 0x084e103c in do_compile () at toplev.c:1933 #10 0x084e10a4 in toplev_main (argc=19, argv=0xbf9bf844) at toplev.c:1965 #11 0x080d9b90 in main (argc=19, argv=0xbf9bf844) at main.c:35
Created attachment 9900 [details] testcase Preprocessed testcase
Reducing.
Reduced testcase: typedef struct linklist *LinkList; typedef struct options *Options; typedef struct builtin *Builtin; struct options { }; typedef int (*HandlerFunc) (char *, char **, Options, int); struct builtin { HandlerFunc handlerfunc; int funcid; }; enum { XTRACE, OPT_SIZE }; extern char opts[OPT_SIZE]; int execbuiltin(LinkList args, Builtin bn) { char *pp, *name, *optstr; int flags, sense, argc, execop, xtr = (opts[XTRACE]); struct options ops; if (!bn->handlerfunc) { return 1; } { char * (argarr)[argc + 1]; char **argv; return (*(bn->handlerfunc)) (name, argv, &ops, bn->funcid); } }
// smaller testcase, compile with -O1 -fprofile-arcs int f (int a, int b) { if (a) return 1; { int s [b]; return 0; } }
saved_stack.3 = __builtin_stack_save (); [t.c : 6] b.0 = b; For last, we don't have a line number associated with it.
A regression hunt on powerpc-linux using the testcase from comment #4 identified this patch from hubicka@gcc.gnu.org: http://gcc.gnu.org/ml/gcc-cvs/2005-08/msg00101.html
Honza, can you have a look at this (now that you appear to be back)?
Created attachment 10035 [details] Hack that makes the test case work. Needs testing.
Created attachment 10036 [details] Alternate fix As suggested by Andrew Pinski... Put loci on the stack save and restore operations. This gives: f (a, b) { intD.0 sD.1611[0:D.1616]; voidD.35 * saved_stack.2D.1623; voidD.35 * D.1622; intD.0[0:D.1616] * s.1D.1621; long unsigned intD.4 D.1620; bit_size_type D.1619; bit_size_type D.1618; long unsigned intD.4 D.1617; long unsigned intD.4 D.1616; long intD.2 D.1615; long intD.2 D.1614; intD.0 b.0D.1613; intD.0 D.1612; # BLOCK 0, starting at line 5 # PRED: ENTRY [t.c : 5] if ([t.c : 5] aD.1607 != 0) goto <L0>; else goto <L1>; # SUCC: 1 2 # BLOCK 1, starting at line 6 # PRED: 0 <L0>:; [t.c : 6] D.1612 = 1; [t.c : 6] goto <bb 3> (<L3>); # SUCC: 3 # BLOCK 2, starting at line 8 # PRED: 0 <L1>:; [t.c : 8] saved_stack.2D.1623 = __builtin_stack_save (); [t.c : 8] b.0D.1613 = bD.1608; [t.c : 8] D.1614 = (long intD.2) b.0D.1613; [t.c : 8] D.1615 = D.1614 - 1; [t.c : 8] D.1616 = (long unsigned intD.4) D.1615; [t.c : 8] D.1617 = (long unsigned intD.4) b.0D.1613; [t.c : 8] D.1618 = (bit_size_type) D.1617; [t.c : 8] D.1619 = D.1618 * 32; [t.c : 8] D.1617 = (long unsigned intD.4) b.0D.1613; [t.c : 8] D.1620 = D.1617 * 4; [t.c : 8] D.1617 = (long unsigned intD.4) b.0D.1613; [t.c : 8] D.1618 = (bit_size_type) D.1617; [t.c : 8] D.1619 = D.1618 * 32; [t.c : 8] D.1617 = (long unsigned intD.4) b.0D.1613; [t.c : 8] D.1620 = D.1617 * 4; [t.c : 8] D.1622 = [t.c : 8] __builtin_alloca (D.1620); [t.c : 8] s.1D.1621 = (intD.0[0:D.1616] *) D.1622; [t.c : 9] D.1612 = 0; [t.c : 9] __builtin_stack_restore (saved_stack.2D.1623); # SUCC: 3 # BLOCK 3 # PRED: 1 2 <L3>:; return D.1612; # SUCC: EXIT }
The second fix boostraps the compiler proper and it builds libstdc++ and libgfortran without problems. But it fails on cp-demangle.c for some reason. That's probably another case where we don't put a locus on statements in a gimplified statement list. Fixing that, who knows where else we'll discover similar problems... Therefore, at least for GCC 4.1 I'm more comfortable with my first patch. I'll bootstrap+test and profilebootstrap that patch and post it for comment if it doesn't cause any regressions.
Subject: Bug 24225 CVSROOT: /cvs/gcc Module name: gcc Changes by: steven@gcc.gnu.org 2005-10-24 19:20:38 Modified files: gcc/testsuite : ChangeLog gcc : ChangeLog profile.c Added files: gcc/testsuite/gcc.dg: pr24225.c Log message: PR tree-optimization/24225 gcc/ * profile.c (branch_prob): Look from end to start through a basic block when looking for a locus. testsuite/ * gcc.dg/pr24225.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr24225.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.6242&r2=1.6243 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10210&r2=2.10211 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/profile.c.diff?cvsroot=gcc&r1=1.164&r2=1.165
.