From patchwork Tue Dec 14 04:18:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 75466 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 AFA3DB6F2B for ; Tue, 14 Dec 2010 15:18:39 +1100 (EST) Received: (qmail 19254 invoked by alias); 14 Dec 2010 04:18:35 -0000 Received: (qmail 19238 invoked by uid 22791); 14 Dec 2010 04:18:31 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS 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, 14 Dec 2010 04:18:26 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBE4IP9U031421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Dec 2010 23:18:25 -0500 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oBE4IN7T019084 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Dec 2010 23:18:24 -0500 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id oBE4IMD1009123; Tue, 14 Dec 2010 02:18:22 -0200 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oBE4IKrq022573; Tue, 14 Dec 2010 02:18:20 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id oBE4IJYX022571; Tue, 14 Dec 2010 02:18:19 -0200 From: Alexandre Oliva To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [PR debug/46782] Skip debug insns in try_forward_edges References: Date: Tue, 14 Dec 2010 02:18:18 -0200 In-Reply-To: (Richard Guenther's message of "Wed, 8 Dec 2010 10:56:17 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 Dec 8, 2010, Richard Guenther wrote: > On Wed, Dec 8, 2010 at 5:06 AM, Alexandre Oliva wrote: >> At -O0, we merge blocks or not depending on locus information present at >> the last insn in a block and the entry locus of the subsequent block. >> We shouldn't use the locus of a debug insn for this compare, lest we may >> end up not merging blocks that, with -g0, we would. >> >> This seldom occurs in practice, since this patch is only active at -O0, >> and -fvar-tracking is disabled by default at -O0, even if -g is enabled. >> However, since it's possible to explicitly activate -fvar-tracking (and >> -fvar-tracking-assignments), even at -O0, we shouldn't generate >> different executable code if the user does this. >> >> The patch below was regstrapped on x86_64-linux-gnu.  Ok to install? > Ok. A few tweaks were needed for 4.5. Regstrapped on x86_64-linux-gnu, along with the patch for PR 46576 (unchanged). I'll apply both in the 4.5 branch if there aren't objections within 20 hours or so, so that the bug reports can be closed. for gcc/ChangeLog from Alexandre Oliva PR debug/46782 * cfgcleanup.c (try_forward_edges): Skip debug insns. for gcc/testsuite/ChangeLog from Alexandre Oliva PR debug/46782 * gcc.dg/debug/pr46782.c: New. Index: gcc/cfgcleanup.c =================================================================== --- gcc/cfgcleanup.c.orig 2010-06-10 13:56:42.000000000 -0300 +++ gcc/cfgcleanup.c 2010-12-13 01:24:08.015744331 -0200 @@ -482,15 +482,20 @@ try_forward_edges (int mode, basic_block /* When not optimizing, ensure that edges or forwarder blocks with different locus are not optimized out. */ int locus = single_succ_edge (target)->goto_locus; + rtx last ; if (locus && goto_locus && !locator_eq (locus, goto_locus)) counter = n_basic_blocks; else if (locus) goto_locus = locus; - if (INSN_P (BB_END (target))) + last = BB_END (target); + if (DEBUG_INSN_P (last)) + last = prev_nondebug_insn (last); + + if (last && INSN_P (last)) { - locus = INSN_LOCATOR (BB_END (target)); + locus = INSN_LOCATOR (last); if (locus && goto_locus && !locator_eq (locus, goto_locus)) Index: gcc/testsuite/gcc.dg/debug/pr46782.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ gcc/testsuite/gcc.dg/debug/pr46782.c 2010-12-13 01:21:44.334901591 -0200 @@ -0,0 +1,11 @@ +/* PR debug/46782 */ +/* { dg-do compile } */ +/* { dg-options "-w -O0 -fvar-tracking -fcompare-debug" } */ + +void foo (int i) +{ + if (i) + i++; + while (i) + ; +}