From patchwork Fri May 20 16:14:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 96643 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 821F9B7190 for ; Sat, 21 May 2011 02:15:14 +1000 (EST) Received: (qmail 25867 invoked by alias); 20 May 2011 16:15:10 -0000 Received: (qmail 25851 invoked by uid 22791); 20 May 2011 16:15:07 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate1.uk.ibm.com (HELO mtagate1.uk.ibm.com) (194.196.100.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 May 2011 16:14:53 +0000 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p4KGEpqD025809 for ; Fri, 20 May 2011 16:14:51 GMT Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4KGEoZ62547754 for ; Fri, 20 May 2011 17:14:51 +0100 Received: from d06av12.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4KGEo2H010770 for ; Fri, 20 May 2011 10:14:50 -0600 Received: from d12mc102.megacenter.de.ibm.com (d12mc102.megacenter.de.ibm.com [9.149.167.114]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4KGEoNB010765; Fri, 20 May 2011 10:14:50 -0600 In-Reply-To: References: <4DD67554.5050904@qnx.com> Subject: Re: Fix crash in vect_is_slp_reduction X-KeepSent: A36EAB66:8EDE7242-C2257896:00582632; type=4; name=$KeepSent To: Richard Guenther Cc: gcc-patches@gcc.gnu.org, Ryan Mansfield Message-ID: From: Ira Rosen Date: Fri, 20 May 2011 19:14:46 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: quoted-printable 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 gcc-patches-owner@gcc.gnu.org wrote on 20/05/2011 05:17:47 PM: > > On Fri, May 20, 2011 at 4:06 PM, Ryan Mansfield wrote: > > There is a crash in vect_is_slp_reduction where use_stmt doesn't get > > initialized in the FOR_EACH_IMM_USE_FAST loop. > > > > 1718          FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) > > (gdb) call debug_tree(lhs) > >   >    type >        size > >        unit size > >        align 32 symtab 0 alias set -1 canonical type 0x7ffff7ecb498 > > precision 32 min max > 0x7ffff7ec47a0 2147483647> context > D.1314> > >        pointer_to_this > > >    var def_stmt g_29_lsm.18_137 = PHI > > > > > >    version 137> > > (gdb) n > > 1742          if (found) > > (gdb) > > 1746          if (gimple_code (use_stmt) == GIMPLE_PHI) > > (gdb) > > > > Program received signal SIGSEGV, Segmentation fault. > > 0x0000000000980f22 in gimple_code (g=0x0) at ../../gcc/gimple.h:1098 > > 1098      return g->gsbase.code; > > > > Is the following sufficient? > > No, we shouldn't arrive with a NULL use_stmt here. I think a proper fix will be to fail if there are no uses. I'll prepare a patch on Sunday. Ira > > Richard. > > > Index: tree-vect-loop.c > > =================================================================== > > --- tree-vect-loop.c    (revision 173945) > > +++ tree-vect-loop.c    (working copy) > > @@ -1743,7 +1743,7 @@ > >         break; > > > >       /* This is a loop exit phi, and we haven't reached the reduction phi. > >  */ > > -      if (gimple_code (use_stmt) == GIMPLE_PHI) > > +      if (!use_stmt || gimple_code (use_stmt) == GIMPLE_PHI) > >         return false; > > > >       if (!is_gimple_assign (use_stmt) > > > > Regards, > > > > Ryan Mansfield > > Index: tree-vect-loop.c =================================================================== --- tree-vect-loop.c (revision 173856) +++ tree-vect-loop.c (working copy) @@ -1704,7 +1704,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi tree lhs; imm_use_iterator imm_iter; use_operand_p use_p; - int nloop_uses, size = 0; + int nloop_uses, size = 0, nuses; bool found = false; if (loop != vect_loop) @@ -1715,9 +1715,11 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi while (1) { nloop_uses = 0; + nuses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) { use_stmt = USE_STMT (use_p); + nuses++; if (is_gimple_debug (use_stmt)) continue; @@ -1739,6 +1741,10 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi return false; } + /* The statement has no uses. */ + if (nuses == 0) + return false; + if (found) break;