I compiled ACE 5.4.2 with the actual snapshot and got a segfault. GCC was compiled with CFLAGS="-pipe -g -O3 -mcpu=G5 -maltivec -mabi=altivec - fmessage-length=0 -falign-loops=16 -falign-jumps=16 -falign-functions=32 - fstrict-aliasing -fsched-interblock -ffast-math -funroll-all-loops -funit-at-a- time -fpeel-loops -ftracer -funswitch-loops -floop-optimize2 -fmove-loop- invariants -fgcse-after-reload -frename-registers -fmodulo-sched --param max- gcse-passes=5 --param max-unrolled-insns=600 --param inline-unit-growth=300 -- param large-function-growth=400" Michael Cieslinski g++40 -pipe -O2 -funroll-all-loops -ftracer -c -o SAXPrint_Handler.o SAXPrint_Handler.ii -v Reading specs from /usr/local/gcc40b/lib/gcc/powerpc-unknown-linux- gnu/4.0.0/specs Configured with: ../gcc40/configure --prefix=/usr/local/gcc40b --program- suffix=40b --with-cpu=G5 --enable-altivec --enable-languages=c,c++ --enable- checking Thread model: posix gcc version 4.0.0 20041128 (experimental) /usr/local/gcc40b/libexec/gcc/powerpc-unknown-linux-gnu/4.0.0/cc1plus - fpreprocessed SAXPrint_Handler.ii -quiet -dumpbase SAXPrint_Handler.ii - mcpu=G5 -auxbase-strip SAXPrint_Handler.o -O2 -version -funroll-all-loops - ftracer -o - | as -mpower4 -maltivec -many -V -Qy -o SAXPrint_Handler.o - GNU assembler version 2.15.90 (ppc-redhat-linux) using BFD version 2.15.90 20040225 GNU C++ version 4.0.0 20041128 (experimental) (powerpc-unknown-linux-gnu) compiled by GNU C version 4.0.0 20041128 (experimental). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 SAXPrint_Handler.cpp: In member function 'void ACEXML_SAXPrint_Handler::print_indent()': SAXPrint_Handler.cpp:244: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. Running cc1plus in GDB: Program received signal SIGSEGV, Segmentation fault. 0x105218b0 in schedule_region (rgn=0) at ../../gcc40/gcc/sched-rgn.c:2325 2325 for (note = REG_NOTES (head); note; note = XEXP (note, 1)) (gdb) bt #0 0x105218b0 in schedule_region (rgn=0) at ../../gcc40/gcc/sched-rgn.c:2325 #1 0x105236fc in schedule_insns (dump_file=Variable "dump_file" is not available. ) at ../../gcc40/gcc/sched-rgn.c:2493 #2 0x1046dac4 in rest_of_compilation () at ../../gcc40/gcc/passes.c:651 #3 0x1018460c in execute_pass_list (pass=0x106fce80) at ../../gcc40/gcc/tree- optimize.c:511 #4 0x101849f8 in tree_rest_of_compilation (fndecl=0x30b99000) at ../../gcc40/gcc/tree-optimize.c:647 #5 0x100f72fc in expand_body (fn=0x30b99000) at ../../gcc40/gcc/cp/semantics.c:2895 #6 0x104995e0 in cgraph_expand_function (node=0x30ba8200) at ../../gcc40/gcc/cgraphunit.c:822 #7 0x1049a684 in cgraph_optimize () at ../../gcc40/gcc/cgraphunit.c:1689 #8 0x10092af0 in cp_finish_file () at ../../gcc40/gcc/cp/decl2.c:3070 #9 0x100017a0 in finish_file () at ../../gcc40/gcc/cp/cp-lang.c:113 #10 0x101547f4 in c_common_parse_file (set_yydebug=Variable "set_yydebug" is not available. ) at ../../gcc40/gcc/c-opts.c:1093 #11 0x1043a4f8 in toplev_main (argc=Variable "argc" is not available. ) at ../../gcc40/gcc/toplev.c:992 #12 0x10160be0 in main (argc=Variable "argc" is not available. ) at ../../gcc40/gcc/main.c:35
Created attachment 7632 [details] preprocessed source
Reduced to: typedef long unsigned int size_t; struct ACEXML_SAXPrint_Handler { void print_indent (); size_t indent_; }; int f(); void ACEXML_SAXPrint_Handler::print_indent (void) { for (size_t i = 0; i < this->indent_; ++i) f (); }
g++ pr18718.cc -O3 -funroll-all-loops -ftracer Confirmed.
hmm, the loop looks right: for (note = REG_NOTES (head); note; note = XEXP (note, 1)) if (REG_NOTE_KIND (note) == REG_SAVE_NOTE) Maybe we are miscompiling sched-regn.c.
No we get this even when the compiler is compiled with -O0. There is only one reg note which is causing this seg fault: (expr_list:REG_SAVE_NOTE (const_int -94 [0xffffffffffffffa2]) (nil))
Obviously, the loop expects REG_SAVE_NOTEs in pairs, which it isn't getting, hence the segfault. This is because the function that adds these notes, sched_analyze, is being called on basic blocks, and the NOTE_INSN_LOOP_BEG/END pair isn't in the same basic block. Smell like bit rot. ;; End of basic block 2, registers live: 1 [1] 31 [31] 67 [ap] 123 124 (note:HI 48 22 23 NOTE_INSN_LOOP_BEG) ;; Start of basic block 3, registers live: 1 [1] 31 [31] 67 [ap] 123 124 (code_label:HI 23 48 24 3 4 "" [1 uses]) [snip] ;; Start of basic block 4, registers live: 1 [1] 31 [31] 67 [ap] 122 124 [snip] (note:HI 49 34 63 4 NOTE_INSN_LOOP_END) [snip]
Hmm, no, that's not quite right. It's nothing to do with the loop begin/end note needing to be recognized in the same analysis pass, but rather that older code emitted two REG_SAVE_NOTEs on each occurence of various other notes. See the corresponding code in gcc-3.4.
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-11/msg02654.html>.
My bad, I guess. See http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01357.html.
The same problem exists in sched-ebb.c, see http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00260.html
Fixed both sched-ebb.c and sched-rgn.c
Um, middle-end spelled wrongly in the log, so adding this by hand CVSROOT: /cvs/gcc Module name: gcc Changes by: amodra@gcc.gnu.org 2004-12-03 23:02:33 Modified files: gcc : ChangeLog sched-rgn.c sched-ebb.c Log message: PR middle end/18718 * sched-rgn.c (schedule_region): Don't assume REG_SAVE_NOTEs are in pairs. * sched-ebb.c (schedule_ebb): Likewise. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6705&r2=2.6706 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&r1=1.87&r2=1.88 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-ebb.c.diff?cvsroot=gcc&r1=1.41&r2=1.42