From patchwork Tue Jun 7 12:24:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 99116 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 C7A8AB6F92 for ; Tue, 7 Jun 2011 22:25:25 +1000 (EST) Received: (qmail 31938 invoked by alias); 7 Jun 2011 12:25:23 -0000 Received: (qmail 31926 invoked by uid 22791); 7 Jun 2011 12:25:22 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jun 2011 12:25:04 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p57COp64017168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 Jun 2011 08:24:51 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p57COoiH008003 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 7 Jun 2011 08:24:51 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p57COng3022090; Tue, 7 Jun 2011 14:24:49 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p57COnHX022089; Tue, 7 Jun 2011 14:24:49 +0200 Date: Tue, 7 Jun 2011 14:24:49 +0200 From: Jakub Jelinek To: Eric Botcazou , Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix ICE in reset_unmarked_insns_debug_uses (PR middle-end/49308) Message-ID: <20110607122448.GA17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <201106031258.13095.ebotcazou@adacore.com> <201106060952.12507.ebotcazou@adacore.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Mon, Jun 06, 2011 at 10:27:51AM -0300, Alexandre Oliva wrote: > On Jun 6, 2011, Eric Botcazou wrote: > > >> It might be too late for DF to do anything sensible to preserve the > >> debug info rather than just throw it away, as your partial approval > >> suggests. > > > OK, let me think about this a little more. > > >> Indeed, sorry, I misread it. > > > Mind installing these bits separately? My understanding is that they are > > independent correctness fixes. > > Tested, installed. This broke e.g. the attached testcase. The problem is that after resetting+rescanning a debug insn reset_unmarked_insns_debug_uses continued walking the DF chains for that debug insn, but those were all invalidated by the df_insn_rescan_debug_internal call. Fixed thusly. Additionally I've renamed a variable that was shadowing a variable of the same name, which confused me quite a bit when debugging it - I was expecting insn to be a DEBUG_INSN, while it was something completely different. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-06-07 Jakub Jelinek PR middle-end/49308 * dce.c (reset_unmarked_insns_debug_uses): Avoid shadowing insn variable. After resetting and rescanning insn continue with previous statement. * gfortran.dg/pr49308.f90: New test. Jakub --- gcc/dce.c.jj 2011-06-06 19:07:08.000000000 +0200 +++ gcc/dce.c 2011-06-07 11:08:12.000000000 +0200 @@ -514,11 +514,11 @@ reset_unmarked_insns_debug_uses (void) struct df_link *defs; for (defs = DF_REF_CHAIN (use); defs; defs = defs->next) { - rtx insn; + rtx ref_insn; if (DF_REF_IS_ARTIFICIAL (defs->ref)) continue; - insn = DF_REF_INSN (defs->ref); - if (!marked_insn_p (insn)) + ref_insn = DF_REF_INSN (defs->ref); + if (!marked_insn_p (ref_insn)) break; } if (!defs) @@ -527,6 +527,7 @@ reset_unmarked_insns_debug_uses (void) each of the DEFs? */ INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC (); df_insn_rescan_debug_internal (insn); + break; } } } --- gcc/testsuite/gfortran.dg/pr49308.f90.jj 2011-06-07 11:39:39.000000000 +0200 +++ gcc/testsuite/gfortran.dg/pr49308.f90 2011-06-07 11:30:25.000000000 +0200 @@ -0,0 +1,28 @@ +! PR middle-end/49308 +! { dg-do compile } +! { dg-options "-O2 -funroll-loops -g" } + +subroutine foo(n, b, d, e) + type t + integer :: f + end type t + type s + type(t), pointer :: g + end type s + type u + type(s), dimension(:), pointer :: h + end type + integer :: i, k, n + type(u), pointer :: a, e + character(len=250) :: b, c, d + logical :: l + do i = 1, n + j = i - 1 + if (j/=0) c = trim(b) // adjustl(d(j)) + end do + a => e + do k = 1, size(a%h) + l = (a%h(k)%g%f == a%h(1)%g%f) + if (.not.(l)) call bar() + enddo +end subroutine foo