From patchwork Thu Oct 27 02:59:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 122057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 30FDFB6EE8 for ; Thu, 27 Oct 2011 14:00:25 +1100 (EST) Received: (qmail 3289 invoked by alias); 27 Oct 2011 03:00:21 -0000 Received: (qmail 3271 invoked by uid 22791); 27 Oct 2011 03:00:19 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Oct 2011 03:00:04 +0000 Received: by gyc15 with SMTP id 15so2507630gyc.20 for ; Wed, 26 Oct 2011 20:00:04 -0700 (PDT) Received: by 10.146.88.6 with SMTP id l6mr6239535yab.35.1319684403976; Wed, 26 Oct 2011 20:00:03 -0700 (PDT) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id r5sm10798389anl.13.2011.10.26.20.00.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 20:00:03 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id D0543170C2E4; Thu, 27 Oct 2011 13:29:56 +1030 (CST) Date: Thu, 27 Oct 2011 13:29:56 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: Reload related segfaults Message-ID: <20111027025956.GQ29439@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Some recent patch has exposed a reload bug. I'm seeing libtool: compile: /home/amodra/build/gcc-curr/./gcc/xgcc -B/home/amodra/build/gcc-curr/./gcc/ -B/home/amodra/gnu/powerpc-linux/bin/ -B/home/amodra/gnu/powerpc-linux/lib/ -isystem /home/amodra/gnu/powerpc-linux/include -isystem /home/amodra/gnu/powerpc-linux/sys-include -m64 -fPIC -mstrict-align -DHAVE_CONFIG_H -I. -I/home/amodra/src/gcc-current/libjava/classpath/native/fdlibm -I../../include -fexceptions -fasynchronous-unwind-tables -g -O2 -m64 -fPIC -mstrict-align -MT sf_fabs.lo -MD -MP -MF .deps/sf_fabs.Tpo -c /home/amodra/src/gcc-current/libjava/classpath/native/fdlibm/sf_fabs.c -fPIC -DPIC -o .libs/sf_fabs.o /home/amodra/src/gcc-current/libjava/classpath/native/fdlibm/sf_fabs.c: In function 'fabsf': /home/amodra/src/gcc-current/libjava/classpath/native/fdlibm/sf_fabs.c:33:1: internal compiler error: Segmentation fault (insn 11 9 15 2 (parallel [ (set (subreg:SI (reg:SF 123 [ ]) 0) (and:SI (subreg:SI (reg:SF 33 1 [ x ]) 0) (const_int 2147483647 [0x7fffffff]))) (clobber (scratch:CC)) ]) /home/amodra/src/gcc-current/libjava/classpath/native/fdlibm/sf_fabs.c:32 146 {andsi3_mc} (expr_list:REG_DEAD (reg:SF 33 1 [ x ]) (nil))) Reloads for insn # 11 Reload 0: GENERAL_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 0), can't combine, secondary_reload_p reload_reg_rtx: (reg:SF 8 8) Reload 1: GENERAL_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum = 0), can't combine, secondary_reload_p reload_reg_rtx: (reg:SF 8 8) Reload 2: reload_in (SF) = (reg:SF 33 1 [orig:123 ] [123]) reload_out (SF) = (reg:SF 33 1 [orig:123 ] [123]) NON_FLOAT_REGS, RELOAD_OTHER (opnum = 0) reload_in_reg: (reg:SF 33 1 [orig:123 ] [123]) reload_out_reg: (reg:SF 33 1 [orig:123 ] [123]) reload_reg_rtx: (reg:SF 10 10) secondary_in_reload = 0, secondary_out_reload = 1 Reload 3: reload_out (SI) = (subreg:SI (reg:SF 33 1 [orig:123 ] [123]) 0) GENERAL_REGS, RELOAD_FOR_OUTPUT (opnum = 0) reload_out_reg: (subreg:SI (reg:SF 33 1 [orig:123 ] [123]) 0) reload_reg_rtx: (reg:SI 9 9) Reload 4: reload_in (SF) = (reg:SF 33 1 [ x ]) GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1) reload_in_reg: (reg:SF 33 1 [ x ]) reload_reg_rtx: (reg:SF 8 8) Notice reload 3 has a subreg for reload_out. We wind up in the gen_reload code shown below, and try to use REGNO on a subreg, leading to (gdb) p debug_rtx(out) (reg:DI -166922608) Or at least, that's what you get after fixing print_rtx to not segfault.. Bootstrap and regression test powerpc-linux in progress. OK to apply, assuming no regressions? * reload1.c (gen_reload): Don't use REGNO on SUBREGs. * print-rtl.c (print_rtx): Don't segfault on negative regno. Note that s/REGNO (in_rtx)/value/ in print_rtx is reasonable given that REG in rtl.def has a format of "i00", so XINT (in_rtx, i) is always XINT (in_rtx, 0) for a reg, which is equivalent to REGNO apart from signedness. Index: gcc/reload1.c =================================================================== --- gcc/reload1.c (revision 180542) +++ gcc/reload1.c (working copy) @@ -8588,28 +8588,28 @@ gen_reload (rtx out, rtx in, int opnum, && reg_or_subregno (in) < FIRST_PSEUDO_REGISTER && (REG_P (out) || (GET_CODE (out) == SUBREG && REG_P (SUBREG_REG (out)))) && reg_or_subregno (out) < FIRST_PSEUDO_REGISTER && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (reg_or_subregno (in)), REGNO_REG_CLASS (reg_or_subregno (out)), GET_MODE (out))) { /* Get the memory to use and rewrite both registers to its mode. */ rtx loc = get_secondary_mem (in, GET_MODE (out), opnum, type); if (GET_MODE (loc) != GET_MODE (out)) - out = gen_rtx_REG (GET_MODE (loc), REGNO (out)); + out = gen_rtx_REG (GET_MODE (loc), reg_or_subregno (out)); if (GET_MODE (loc) != GET_MODE (in)) - in = gen_rtx_REG (GET_MODE (loc), REGNO (in)); + in = gen_rtx_REG (GET_MODE (loc), reg_or_subregno (in)); gen_reload (loc, in, opnum, type); gen_reload (out, loc, opnum, type); } #endif else if (REG_P (out) && UNARY_P (in)) { rtx insn; rtx op1; rtx out_moded; rtx set; Index: gcc/print-rtl.c =================================================================== --- gcc/print-rtl.c (revision 180542) +++ gcc/print-rtl.c (working copy) @@ -465,13 +465,12 @@ print_rtx (const_rtx in_rtx) int value = XINT (in_rtx, i); const char *name; #ifndef GENERATOR_FILE - if (REG_P (in_rtx) && value < FIRST_PSEUDO_REGISTER) - fprintf (outfile, " %d %s", REGNO (in_rtx), - reg_names[REGNO (in_rtx)]); + if (REG_P (in_rtx) && (unsigned) value < FIRST_PSEUDO_REGISTER) + fprintf (outfile, " %d %s", value, reg_names[value]); else if (REG_P (in_rtx) - && value <= LAST_VIRTUAL_REGISTER) + && (unsigned) value <= LAST_VIRTUAL_REGISTER) { if (value == VIRTUAL_INCOMING_ARGS_REGNUM) fprintf (outfile, " %d virtual-incoming-args", value); else if (value == VIRTUAL_STACK_VARS_REGNUM)