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.
Reducing...
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.
(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
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.
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).
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
(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.
Fixed.