From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31326 invoked by alias); 7 Jul 2011 10:20:25 -0000 Received: (qmail 31318 invoked by uid 22791); 7 Jul 2011 10:20:24 -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; Thu, 07 Jul 2011 10:20:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p67AJcwt025941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Jul 2011 06:19:38 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p67AJak3031598 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 7 Jul 2011 06:19:37 -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 p67AJaUa008312; Thu, 7 Jul 2011 12:19:36 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p67AJZNu008310; Thu, 7 Jul 2011 12:19:35 +0200 Date: Thu, 07 Jul 2011 10:27:00 -0000 From: Jakub Jelinek To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix dead_debug_insert_before ICE (PR debug/49522, take 3) Message-ID: <20110707101935.GM2687@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110704172938.GT16443@tyan-ft48-01.lab.bos.redhat.com> <20110705200651.GG2687@tyan-ft48-01.lab.bos.redhat.com> <20110706194252.GJ2687@tyan-ft48-01.lab.bos.redhat.com> <201107062236.03157.ebotcazou@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201107062236.03157.ebotcazou@adacore.com> 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00446.txt.bz2 On Wed, Jul 06, 2011 at 10:36:02PM +0200, Eric Botcazou wrote: > > And here is a version that passed bootstrap/regtest on x86_64-linux and > > i686-linux: > > > > 2011-07-06 Jakub Jelinek > > > > PR debug/49522 > > * df-problems.c (dead_debug_reset): Remove dead_debug_uses > > referencing debug insns that have been reset. > > (dead_debug_insert_before): Don't assert reg is non-NULL, > > instead return immediately if it is NULL. > > > > * gcc.dg/debug/pr49522.c: New test. > > Sorry, our messages crossed. I'd set a flag in the first loop. In the end, > it's up to you. Actually, looking at it some more, dead_debug_use structs referencing the same insn are always adjacent due to the way how they are added using dead_debug_add. While some of the dead_debug_use records might preceede the record because of which it is reset, it isn't hard to remember a pointer pointing to the pointer to the first entry for the current insn. So, here is a new patch which doesn't need two loops, just might go a little bit backwards to unchain dead_debug_use for the reset insn. It still needs the change of the gcc_assert (reg) into if (reg == NULL) return;, because the dead->used bitmap is with this sometimes a false positive (saying that a regno is referenced even when it isn't). But here it is IMHO better to occassionaly live with the false positives, which just means we'll sometimes once walk the chain in dead_debug_reset or dead_debug_insert_before before resetting it, than to recompute the bitmap (we'd need a second loop for that, bitmap_clear (debug->used) and populate it again). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2011-07-07 Jakub Jelinek PR debug/49522 * df-problems.c (dead_debug_reset): Remove dead_debug_uses referencing debug insns that have been reset. (dead_debug_insert_before): Don't assert reg is non-NULL, instead return immediately if it is NULL. * gcc.dg/debug/pr49522.c: New test. --- gcc/df-problems.c.jj 2011-07-07 02:32:45.928547053 +0200 +++ gcc/df-problems.c 2011-07-07 09:57:34.846464573 +0200 @@ -3096,6 +3096,7 @@ static void dead_debug_reset (struct dead_debug *debug, unsigned int dregno) { struct dead_debug_use **tailp = &debug->head; + struct dead_debug_use **insnp = &debug->head; struct dead_debug_use *cur; rtx insn; @@ -3113,9 +3114,21 @@ dead_debug_reset (struct dead_debug *deb debug->to_rescan = BITMAP_ALLOC (NULL); bitmap_set_bit (debug->to_rescan, INSN_UID (insn)); XDELETE (cur); + if (tailp != insnp && DF_REF_INSN ((*insnp)->use) == insn) + tailp = insnp; + while ((cur = *tailp) && DF_REF_INSN (cur->use) == insn) + { + *tailp = cur->next; + XDELETE (cur); + } + insnp = tailp; } else - tailp = &(*tailp)->next; + { + if (DF_REF_INSN ((*insnp)->use) != DF_REF_INSN (cur->use)) + insnp = tailp; + tailp = &(*tailp)->next; + } } } @@ -3174,7 +3187,8 @@ dead_debug_insert_before (struct dead_de tailp = &(*tailp)->next; } - gcc_assert (reg); + if (reg == NULL) + return; /* Create DEBUG_EXPR (and DEBUG_EXPR_DECL). */ dval = make_debug_expr_from_rtl (reg); --- 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 ()) + ; + } + } +} Jakub