Bug 55717 - [4.8 Regression] ICE in form_sum, at reload.c:5400
Summary: [4.8 Regression] ICE in form_sum, at reload.c:5400
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jakub Jelinek
URL:
Keywords: ra
Depends on:
Blocks:
 
Reported: 2012-12-17 09:40 UTC by Richard Biener
Modified: 2012-12-18 11:37 UTC (History)
5 users (show)

See Also:
Host:
Target: s390x-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-12-17 00:00:00


Attachments
preprocessed source (202.74 KB, application/octet-stream)
2012-12-17 09:40 UTC, Richard Biener
Details
autoreduced testcase (1.86 KB, text/plain)
2012-12-17 15:06 UTC, Richard Biener
Details
gcc48-pr55717.patch (3.27 KB, patch)
2012-12-17 18:32 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2012-12-17 09:40:31 UTC
Created attachment 28980 [details]
preprocessed source

/usr/lib64/gcc/s390x-suse-linux/4.8/cc1plus -fpreprocessed jsinfer.ii -quiet -dumpbase jsinfer.cpp -march=z10 -mtune=z196 -m64 -mzarch -auxbase-strip jsinfer.o -g -g -O2 -Os -O3 -Wpedantic -Wpointer-arith -Woverloaded-virtual -Werror=return-type -Wtype-limits -Wempty-body -Wno-ctor-dtor-privacy -Wno-overlength-strings -Wno-invalid-offsetof -Wno-variadic-macros -Wcast-align -Wno-long-long -Wall -w -version -fvisibility=hidden -fPIC -fmessage-length=0 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -fno-strict-aliasing -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -freorder-blocks -fomit-frame-pointer -o jsinfer.s
GNU C++ (SUSE Linux) version 4.8.0 20121214 [trunk revision 194496] (s390x-suse-linux)
        compiled by GNU C version 4.8.0 20121214 [trunk revision 194496], GMP version 5.0.5, MPFR version 3.1.1, MPC version 1.0
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (SUSE Linux) version 4.8.0 20121214 [trunk revision 194496] (s390x-suse-linux)
        compiled by GNU C version 4.8.0 20121214 [trunk revision 194496], GMP version 5.0.5, MPFR version 3.1.1, MPC version 1.0
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: a8e31d0d1f1ec059729ba32c442af16c
/home/abuild/rpmbuild/BUILD/mozilla/js/src/jsinfer.cpp: In member function 'void js::types::TypeCompartment::sweep(js::FreeOp*)':
/home/abuild/rpmbuild/BUILD/mozilla/js/src/jsinfer.cpp:6008:1: internal compiler error: in form_sum, at reload.c:5400
 }
 ^
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.
Comment 1 Richard Biener 2012-12-17 11:03:28 UTC
Reducing...
Comment 2 Richard Biener 2012-12-17 15:06:45 UTC
Created attachment 28985 [details]
autoreduced testcase

Autoreduced testcase, fails with

> ./cc1plus -quiet -I /abuild/rguenther/obj-s390x-g/gcc/include -o /dev/null jsinfer.3.ii -O -g -w
jsinfer.3.ii: In member function 'void js::types::TypeCompartment::sweep(js::FreeOp*)':
jsinfer.3.ii:191:3: internal compiler error: in form_sum, at reload.c:5400
   }
   ^
0xc03eb7 form_sum(machine_mode, rtx_def*, rtx_def*)
        /space/rguenther/src/svn/trunk/gcc/reload.c:5400
0xc106b2 eliminate_regs_1
        /space/rguenther/src/svn/trunk/gcc/reload1.c:2684
0xc108bc eliminate_regs_1
        /space/rguenther/src/svn/trunk/gcc/reload1.c:2740
0xc111e9 eliminate_regs(rtx_def*, machine_mode, rtx_def*)
        /space/rguenther/src/svn/trunk/gcc/reload1.c:2960
0xc11b6c eliminate_regs_in_insn
        /space/rguenther/src/svn/trunk/gcc/reload1.c:3244
0xc0d4b0 calculate_needs_all_insns
        /space/rguenther/src/svn/trunk/gcc/reload1.c:1515
0xc0b9f8 reload(rtx_def*, int)
        /space/rguenther/src/svn/trunk/gcc/reload1.c:940
0xaf7489 do_reload
        /space/rguenther/src/svn/trunk/gcc/ira.c:4636
0xaf7654 rest_of_handle_reload
        /space/rguenther/src/svn/trunk/gcc/ira.c:4737
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Richard Biener 2012-12-17 15:38:04 UTC
(gdb) up
#1  0x0000000000c03eb8 in form_sum (mode=SImode, x=0x7ffff02a5e88, 
    y=0x7ffff02a5eb8) at /space/rguenther/src/svn/trunk/gcc/reload.c:5400
5400      gcc_assert (GET_MODE (x) == mode || GET_MODE (x) == VOIDmode);
(gdb) call debug_rtx (x)
(mem/f/j:DI (plus:DI (mem/f/c:DI (plus:DI (reg/f:DI 15 %r15)
                (const_int 168 [0xa8])) [0 MEM[(const struct AllocationSiteKey &)&key]+0 S8 A64])
        (const_int 24 [0x18])) [0 key$script_268->code+0 S8 A64])

similar for the reduced testcase
Comment 4 Jakub Jelinek 2012-12-17 16:36:47 UTC
Ugh, this is a mess.  simplify-rtx.c (and fwprop.c in one spot) calls
rtl_hooks.gen_lowpart_no_emit
in various places, but
gen_lowpart_no_emit_general
happily returns a non-lowpart rtx if gen_lowpart_if_possible returned NULL.
I guess for normal insns that is in the hope that whatever pass uses it will reject such pattern as invalid, but as in DEBUG_INSNs no such checking is performed, it happily emits sucgh bogus RTL into the RTL stream.
For expand_debug_expr, I guess cfgexpand.c (expand_call_stmt and expand_debug_locations) could easily switch rtl_hooks to debug_rtl_hooks, which would simply create a SUBREG if gen_lowpart_if_possible returned NULL, all SUBREGs are valid in DEBUG_INSNs.  But wonder about all the other passes that call simplify_* functions on DEBUG_INSN content, guess we want to switch the rtl_hooks in that case too.
Comment 5 Jakub Jelinek 2012-12-17 18:32:55 UTC
Created attachment 28987 [details]
gcc48-pr55717.patch

Untested fix.  Instead of returning very likely bogus value x this patch returns NULL and let the callers deal with that as error (so they don't try that simplification, instead try some other or just punt at simplifying).
Comment 6 Jakub Jelinek 2012-12-18 10:50:51 UTC
Author: jakub
Date: Tue Dec 18 10:50:47 2012
New Revision: 194575

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194575
Log:
	PR debug/55717
	* rtlhooks-def.h (RTL_HOOKS_GEN_LOWPART_NO_EMIT): Define to
	gen_lowpart_if_possible.
	(gen_lowpart_no_emit_general): Remove prototype.
	* rtlhooks.c (gen_lowpart_no_emit_general): Removed.
	* simplify-rtx.c (simplify_unary_operation_1, 
	simplify_binary_operation_1): Continue simplifying if
	rtl_hooks.gen_lowpart_no_emit returns NULL_RTX.
	* dwarf2out.c (mem_loc_descriptor) <case TRUNCATE>: Handle
	truncation like lowpart SUBREG.

	* testsuite/g++.dg/opt/pr55717.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr55717.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/rtlhooks-def.h
    trunk/gcc/rtlhooks.c
    trunk/gcc/simplify-rtx.c
    trunk/gcc/testsuite/ChangeLog
Comment 7 Andreas Krebbel 2012-12-18 11:35:33 UTC
(In reply to comment #5)
> Created attachment 28987 [details]
> gcc48-pr55717.patch
> 
> Untested fix.  Instead of returning very likely bogus value x this patch
> returns NULL and let the callers deal with that as error (so they don't try
> that simplification, instead try some other or just punt at simplifying).

Thanks. I've tested your patch on s390 and s390x. No regressions.
Comment 8 Jakub Jelinek 2012-12-18 11:37:48 UTC
Fixed.