Bug 12965 - [3.3 regression] SEGV+ICE in cc1plus on alpha-linux with -O2
Summary: [3.3 regression] SEGV+ICE in cc1plus on alpha-linux with -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.2
: P3 normal
Target Milestone: 3.3.3
Assignee: Eric Botcazou
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2003-11-08 16:49 UTC by Jakub Bogusz
Modified: 2003-12-11 07:50 UTC (History)
1 user (show)

See Also:
Host: alpha-pld-linux-gnu
Target: alpha-pld-linux-gnu
Build: alpha-pld-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-12-06 11:55:30


Attachments
Preprocessed source that triggers SEGV+ICE on alpha-linux (44.67 KB, application/octet-stream)
2003-11-08 16:57 UTC, Jakub Bogusz
Details
Reduced test case (77 lines) (704 bytes, text/plain)
2003-11-08 19:28 UTC, Falk Hueffner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Bogusz 2003-11-08 16:49:47 UTC
g++ (actually cc1plus process) reports segmentation fault and internal
compiler error when building "dar" package with -O2 optimization on
alpha-linux. tst.ii is the preprocessed source of simplified source
file which triggers problem (.cpp is ~80 lines long, most of .ii
file lines are STL headers; original classes structure was much more
complicated).

This file compiles correctly using gcc 3.3.2 with -O2 on i*86 (with
-march=i386/i586/i686/athlon), sparc and ppc machines.
On alpha gcc 2.95.3 works too with -O2 optimization.

When running g++ on alpha I get:

$ g++ -O2 -c tst.ii
tst.cpp: In constructor `inode::inode()':
tst.cpp:87: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

I tried to run cc1plus under gdb and got:

[...]
[with _Tp = char] inode::inode()
Program received signal SIGSEGV, Segmentation fault.
insert_insn_on_edge (pattern=0x20001c0d340, e=0x0) at ../../gcc/cfgrtl.c:1345
1345      if ((e->flags & EDGE_ABNORMAL) && EDGE_CRITICAL_P (e))
(gdb) bt
#0  insert_insn_on_edge (pattern=0x20001c0d340, e=0x0) at ../../gcc/cfgrtl.c:1345
#1  0x000000012025251c in fixup_abnormal_edges () at ../../gcc/reload1.c:9524
#2  0x000000012023f840 in reload (first=0x200015b87e8, global=1) at ../../gcc/reload1.c:1287
#3  0x00000001202eeabc in global_alloc (file=0x0) at ../../gcc/global.c:583
#4  0x000000012027b77c in rest_of_compilation (decl=0x200013a5008) at ../../gcc/toplev.c:3305
#5  0x00000001200a6720 in genrtl_finish_function (fn=0x200013a5008)
    at ../../gcc/cp/semantics.c:2589
#6  0x00000001200a627c in expand_body (fn=0x200013a5008) at ../../gcc/cp/semantics.c:2412
#7  0x00000001200adc40 in maybe_clone_body (fn=0x200013955f0) at ../../gcc/cp/optimize.c:274
#8  0x00000001200a6038 in expand_body (fn=0x200013955f0) at ../../gcc/cp/semantics.c:2328
#9  0x000000012006d310 in yyparse () at parse.y:815
#10 0x00000001200cc094 in c_common_parse_file (set_yydebug=29414208) at ../../gcc/c-lex.c:159
#11 0x0000000120279638 in compile_file () at ../../gcc/toplev.c:2130
#12 0x0000000120280ee4 in do_compile () at ../../gcc/toplev.c:5402
#13 0x0000000120280fc4 in toplev_main (argc=5, argv=0x11ffffc38) at ../../gcc/toplev.c:5432
#14 0x00000001200d5188 in main (argc=29414208, argv=0x0) at ../../gcc/main.c:35

insert_insn_on_edge() is called with e=NULL, but the function doesn't
expect this.
In fixup_abnormal_edges() before the call bb->succ is not NULL,
bb->succ->flags == 14, bb->succ->succ_next == NULL.

Environment:
System: Linux alpha 2.4.22 #5 Fri Oct 3 11:20:04 CEST 2003 alpha EV6 unknown PLD Linux
Architecture: alpha
host: alpha-pld-linux-gnu
build: alpha-pld-linux-gnu
target: alpha-pld-linux-gnu
configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++,f77,objc,ada,java,ksi --enable-c99 --enable-long-long --enable-multilib --enable-nls --with-gnu-as --with-gnu-ld --with-system-zlib --with-slibdir=/lib --without-x alpha-pld-linux

How-To-Repeat:
Compile attached preprocessed file (tst.ii) with one of:
-O2  (adding just -fno-inline-functions doesn't help)
-O3
Comment 1 Jakub Bogusz 2003-11-08 16:49:47 UTC
Fix:
Workaround is to compile with one of:
-O1
-O2 -fno-inline
-O2 -fno-default-inline
Comment 2 Jakub Bogusz 2003-11-08 16:57:37 UTC
Created attachment 5101 [details]
Preprocessed source that triggers SEGV+ICE on alpha-linux
Comment 3 Falk Hueffner 2003-11-08 19:27:42 UTC
Confirmed with 3.3.2. Not present on mainline.
Comment 4 Falk Hueffner 2003-11-08 19:28:29 UTC
Created attachment 5102 [details]
Reduced test case (77 lines)
Comment 5 Eric Botcazou 2003-12-05 13:17:35 UTC
Investigating.
Comment 6 Andrew Pinski 2003-12-06 11:55:29 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00630.html>.
Comment 7 CVS Commits 2003-12-07 13:05:49 UTC
Subject: Bug 12965

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2003-12-07 13:05:43

Modified files:
	gcc            : ChangeLog caller-save.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: noreturn-1.C 

Log message:
	PR optimization/12965
	* caller-save.c (save_call_clobbered_regs): Do not save/restore
	registers around no-return calls.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1946&r2=2.1947
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/caller-save.c.diff?cvsroot=gcc&r1=1.56&r2=1.57
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3237&r2=1.3238
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/noreturn-1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 8 Jakub Bogusz 2003-12-08 18:59:18 UTC
I can confirm: gcc 3.3.2 with this patch is able to compile "dar" with -O2 on
alpha-linux.
Thanks.
Comment 9 CVS Commits 2003-12-11 07:48:17 UTC
Subject: Bug 12965

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	ebotcazou@gcc.gnu.org	2003-12-11 07:48:07

Modified files:
	gcc            : ChangeLog caller-save.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: noreturn-1.C 

Log message:
	Backport from mainline:
	
	2003-12-07  Eric Botcazou  <ebotcazou@libertysurf.fr>
	
	PR optimization/12965
	* caller-save.c (save_call_clobbered_regs): Do not save/restore
	registers around no-return calls.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.836&r2=1.16114.2.837
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/caller-save.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.53&r2=1.53.20.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.328&r2=1.2261.2.329
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/noreturn-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 10 Eric Botcazou 2003-12-11 07:50:08 UTC
Thanks for the confirmation.