From patchwork Thu Nov 1 09:27:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 196101 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 48EAB2C00C1 for ; Thu, 1 Nov 2012 20:28:15 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352366896; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To: References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=siCsZKZfwpelZnL0MCAK+CpSrHE=; b=JqzbKoqwRUEz3zd mlwCeU/tWO+BZZgWt8Kq56OyyGYo+Qs5vM96IM061eAU9TjPVuPhK1VO+t+krZOR 49jh9PxxjAsMRV8o9QKWmLNtC2q3Eokoto9q9M3JLmMNZI6kIH+y8CU/RfwUL9CR lEQir2mQTaudmrp22FYsp0tCQRDc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=lghXX7AFXWKzFkQ8SRUNw+WmT3wIJFTaL6NI/lM4FF6TiU4Q41L8C2JKsNOB/j oO5Niemh+Mk63sRvM2wiy7guGeQg6a2Th/dz+rwAalnvEExkzeg+RZeZx93yoo12 lmE5ZbqpMTZZG+QU/XgyTU30wKh3t0McSuKdkUuibUYOI=; Received: (qmail 3655 invoked by alias); 1 Nov 2012 09:28:12 -0000 Received: (qmail 3641 invoked by uid 22791); 1 Nov 2012 09:28:11 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM 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, 01 Nov 2012 09:28:00 +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 qA19Rx3h026963 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Nov 2012 05:27:59 -0400 Received: from zalov.redhat.com (vpn1-7-182.ams2.redhat.com [10.36.7.182]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qA19Rwvf005486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 Nov 2012 05:27:59 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.redhat.com (8.14.5/8.14.5) with ESMTP id qA19RvSb005739; Thu, 1 Nov 2012 10:27:57 +0100 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id qA19RvYR005738; Thu, 1 Nov 2012 10:27:57 +0100 Date: Thu, 1 Nov 2012 10:27:57 +0100 From: Jakub Jelinek To: Alexandre Oliva Cc: gcc-patches@gcc.gnu.org Subject: Re: [PR54693] loss of debug info in jump threading and loop ivopts Message-ID: <20121101092756.GF1891@tucnak.redhat.com> Reply-To: Jakub Jelinek References: 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 Fri, Oct 26, 2012 at 04:30:41AM -0200, Alexandre Oliva wrote: > From: Alexandre Oliva > > for gcc/ChangeLog > > PR debug/54693 > * tree-ssa-threadedge.c (thread_around_empty_block): Copy > debug temps from predecessor before threading. As can be seen on test-tgmath2.i, unfortunately many failed attempts to thread can lead into big DEBUG stmt duplication this way. The following patch avoids that by avoiding to copy debug stmts for vars that already have a debug stmt at the beginning of the successor bb. That can happen either from earlier thread_around_empty_block calls, or just happen by accident, or even if the predecessor bb has several debug stmts for the same var like DEBUG i => i_7 i_8 = i_7 + 1 DEBUG i => i_8 i_9 = i_9 + 1 DEBUG i => i_9 We'd needlessly copy over all debug stmts DEBUG i => i_7 DEBUG i => i_8 DEBUG i => i_9 to the succ bb. Even for stmt frontiers it is IMHO undesirable to duplicate (perhaps many times) the whole sequence, as one would then reply the var changing sequence in the debugger perhaps once in the original bb, then once or many times again in the successor bb. The patch unfortunately doesn't speed test-tgmath2.i compilation significantly, but decreases number of debug stmts from ~ 36000 to ~ 16000, the 20000+ were clearly redundant. 2012-11-01 Jakub Jelinek PR debug/54402 * tree-ssa-threadedge.c (thread_around_empty_block): Don't copy over debug stmts if the successor bb already starts with a debug stmt for the same var. Jakub --- gcc/tree-ssa-threadedge.c.jj 2012-10-30 09:01:15.000000000 +0100 +++ gcc/tree-ssa-threadedge.c 2012-11-01 10:07:29.114499218 +0100 @@ -1,5 +1,5 @@ /* SSA Jump Threading - Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. Contributed by Jeff Law @@ -641,18 +641,61 @@ thread_around_empty_block (edge taken_ed we don't lose the bindings as we redirect the edges. */ if (MAY_HAVE_DEBUG_STMTS) { + struct pointer_set_t *vars = NULL; + gsi = gsi_after_labels (bb); for (gimple_stmt_iterator si = gsi_last_bb (taken_edge->src); !gsi_end_p (si); gsi_prev (&si)) { + tree var; + stmt = gsi_stmt (si); if (!is_gimple_debug (stmt)) continue; + var = NULL_TREE; + if (gimple_debug_bind_p (stmt)) + var = gimple_debug_bind_get_var (stmt); + else if (gimple_debug_source_bind_p (stmt)) + var = gimple_debug_source_bind_get_var (stmt); + + /* Don't insert debug stmts for vars which will be immediately + overridden by debug stmts at the start of bb (either preexisting + or from earlier thread_around_empty_block attempt), without + any intervening real stmts. */ + if (var != NULL_TREE + && is_gimple_debug (gsi_stmt (gsi))) + { + if (vars == NULL) + { + gimple_stmt_iterator gsi2; + vars = pointer_set_create (); + for (gsi2 = gsi; !gsi_end_p (gsi2); gsi_next (&gsi2)) + { + gimple stmt2 = gsi_stmt (gsi2); + tree var2; + if (!is_gimple_debug (stmt2)) + break; + if (gimple_debug_bind_p (stmt2)) + var2 = gimple_debug_bind_get_var (stmt2); + else if (gimple_debug_source_bind_p (stmt2)) + var2 = gimple_debug_source_bind_get_var (stmt2); + else + continue; + pointer_set_insert (vars, var2); + } + } + if (pointer_set_insert (vars, var)) + continue; + } + stmt = gimple_copy (stmt); /* ??? Should we drop the location of the copy? */ gsi_insert_before (&gsi, stmt, GSI_NEW_STMT); } + + if (vars != NULL) + pointer_set_destroy (vars); } /* This block must have more than one successor. */