From patchwork Mon Jul 4 17:29:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 103143 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 6F739B6F57 for ; Tue, 5 Jul 2011 03:29:56 +1000 (EST) Received: (qmail 22084 invoked by alias); 4 Jul 2011 17:29:54 -0000 Received: (qmail 22076 invoked by uid 22791); 4 Jul 2011 17:29:54 -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; Mon, 04 Jul 2011 17:29:40 +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 p64HTevV017908 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Jul 2011 13:29:40 -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 p64HTdiV028163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 4 Jul 2011 13:29:40 -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 p64HTdGS001996 for ; Mon, 4 Jul 2011 19:29:39 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p64HTd50001994 for gcc-patches@gcc.gnu.org; Mon, 4 Jul 2011 19:29:39 +0200 Date: Mon, 4 Jul 2011 19:29:39 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522) Message-ID: <20110704172938.GT16443@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline 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 Hi! In dead_debug_* we don't immediately rescan insns, because that kills all the df links we need to use, only queue their rescanning. There are two kinds of changes we do on the debug insns without immediate rescanning: 1) reset the debug insn 2) replace a reg use with DEBUG_EXPR of the same mode or subreg of a larger DEBUG_EXPR with the same outer mode as the reg In the attached testcase on arm a debug insn is reset, because a multi-reg register has been used there and as the debug insn location was that multi-reg register before, it is now VOIDmode after the reset - (clobber (const_int 0)). Fixed by disregarding the reset debug insns. Changes of kind 2) that needed rescanning don't need this, as the mode doesn't change in that case. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.6? 2011-07-04 Jakub Jelinek PR debug/49522 * df-problems.c (dead_debug_insert_before): Ignore uses where the use debug insn has been reset. * gcc.dg/debug/pr49522.c: New test. Jakub --- gcc/df-problems.c.jj 2011-06-17 11:02:19.000000000 +0200 +++ gcc/df-problems.c 2011-07-04 10:46:42.000000000 +0200 @@ -3148,6 +3148,7 @@ dead_debug_insert_before (struct dead_de struct dead_debug_use *cur; struct dead_debug_use *uses = NULL; struct dead_debug_use **usesp = &uses; + bool no_reg_ok = false; rtx reg = NULL; rtx dval; rtx bind; @@ -3161,6 +3162,21 @@ dead_debug_insert_before (struct dead_de { if (DF_REF_REGNO (cur->use) == uregno) { + /* If cur->use insn has been meanwhile reset, but hasn't been + rescanned, just ignore that use. */ + if (DF_REF_REAL_LOC (cur->use) + == &INSN_VAR_LOCATION_LOC (DF_REF_INSN (cur->use)) + && VAR_LOC_UNKNOWN_P (*DF_REF_REAL_LOC (cur->use))) + { + gcc_assert (debug->to_rescan != NULL + && bitmap_bit_p (debug->to_rescan, + INSN_UID (DF_REF_INSN (cur->use)))); + *tailp = cur->next; + XDELETE (cur); + if (!reg) + no_reg_ok = true; + continue; + } *usesp = cur; usesp = &cur->next; *tailp = cur->next; @@ -3174,6 +3190,9 @@ dead_debug_insert_before (struct dead_de tailp = &(*tailp)->next; } + if (no_reg_ok && !reg) + return; + gcc_assert (reg); /* Create DEBUG_EXPR (and DEBUG_EXPR_DECL). */ --- gcc/testsuite/gcc.dg/debug/pr49522.c.jj 2011-07-04 10:54:23.000000000 +0200 +++ gcc/testsuite/gcc.dg/debug/pr49522.c 2011-07-04 10:54:02.000000000 +0200 @@ -0,0 +1,41 @@ +/* PR debug/49522 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug" } */ + +int val1 = 0L; +volatile int val2 = 7L; +long long val3; +int *ptr = &val1; + +static int +func1 () +{ + return 0; +} + +static short int +func2 (short int a, unsigned int b) +{ + return !b ? a : a >> b; +} + +static unsigned long long +func3 (unsigned long long a, unsigned long long b) +{ + return !b ? a : a % b; +} + +void +func4 (unsigned short arg1, int arg2) +{ + for (arg2 = 0; arg2 < 2; arg2++) + { + *ptr = func3 (func3 (10, func2 (val3, val2)), val3); + for (arg1 = -14; arg1 > 14; arg1 = func1 ()) + { + *ptr = -1; + if (foo ()) + ; + } + } +}