From patchwork Sun Jul 8 09:27:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 940917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-481190-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="KdDErEYv"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41NjmN46Hyz9s1b for ; Sun, 8 Jul 2018 19:27:32 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=ZYkd86g/jbPFZIkY+ 8AKOr4SkWt6dRfLAz0wXdGQhSwHL7L2toMVAuJag5raebXvV7XgRaGCPLXeDdFlH Xh4XXeBes6bOZa5u5YbLepj9T6pxejUg+31hvTrjUoyLVCwV+6/YIapCWVjTWflQ BN6+vq3Oz3+BcUqa45U+7p+F4Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=xqE5vkY8QG1PEiBp4h2uvhR +h8E=; b=KdDErEYvOIGIFw1TPKYunnpFvLjd6Nq8z8bfqi5d/x4aTDt4N/1/zAv fze2GZKixNxNXz7w//6cZNVky9+cesy1nBvW4hQ6tOe9ghSmRLrtaO2bmUwUkeRt T/2zCV4LK8xEsjv7Uq/2lYxoQ2H9QBPXxb/hNEac04pNFSslmn4E= Received: (qmail 121082 invoked by alias); 8 Jul 2018 09:27:24 -0000 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 Received: (qmail 121065 invoked by uid 89); 8 Jul 2018 09:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=41AM, 41am X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Jul 2018 09:27:22 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 55CEFADB8; Sun, 8 Jul 2018 09:27:20 +0000 (UTC) Date: Sun, 8 Jul 2018 11:27:25 +0200 From: Tom de Vries To: Richard Biener Cc: Jakub Jelinek , GCC Patches Subject: [PATCH][debug] Reuse debug exprs generated in remap_ssa_name Message-ID: <20180708092725.c7ahp6ggfh6d3mqz@delia> References: <948b1fdd-9e53-2d65-7c72-99460a2fec1e@suse.de> <20180702081604.GR7166@tucnak> <2e0f12a5-803e-6f24-505e-574dd2ea4ba9@suse.de> <04c6e772-70f4-a786-13d9-7017382d7142@suse.de> <20180705112558.mphxe2sz7mozvcur@delia> <20180708092241.ysxxwnxk757uuspy@delia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180708092241.ysxxwnxk757uuspy@delia> User-Agent: NeoMutt/20170912 (1.9.0) X-IsSubscribed: yes On Sun, Jul 08, 2018 at 11:22:41AM +0200, Tom de Vries wrote: > On Fri, Jul 06, 2018 at 04:38:50PM +0200, Richard Biener wrote: > > On Fri, Jul 6, 2018 at 12:47 PM Tom de Vries wrote: > > > On 07/05/2018 01:39 PM, Richard Biener wrote: > > > > > I now also spotted the code in remap_ssa_name that is supposed to handle > > this it seems and for the testcase we only give up because the PARM_DECL is > > remapped to a VAR_DECL. So I suppose it is to be handled via the > > debug-args stuff > > which probably lacks in the area of versioning. > > > > Your patch feels like it adds stuff ontop of existing mechanisms that > > should "just work" > > with the correct setup at the correct places... > > > > Hmm, I realized that I may be complicating things, by trying to do an > optimal fix in a single patch, so I decided to write two patches, one > with a fix, and then one improving the fix to be more optimal. > > Also, I suspect that the "just work" approach is this: > ... > # DEBUG D#8 s=> iD.1900 > # DEBUG iD.1949 => D#8 > # DEBUG D#6 s=> iD.1949 > ... > whereas previously I tried to map 'D#6' on iD.1900 directly. > Second patch OK for trunk? Thanks, - Tom [debug] Reuse debug exprs generated in remap_ssa_name When compiling gcc.dg/vla-1.c with -O3 -g, vla a and b in f1 are optimized away, and f1 is cloned to a version f1.constprop with no parameters, eliminating parameter i. Debug info is generated to describe the sizes of a and b, but that process generates debug expressions that are not reused. Fix the duplication by saving and reusing the generated debug expressions in remap_ssa_name. Concretely: reuse D#7 here instead of generating D#8: ... __attribute__((noinline)) f1.constprop () { intD.6 iD.1935; # DEBUG D#10 s=> iD.1897 # DEBUG iD.1935 => D#10 - # DEBUG D#8 s=> iD.1935 # DEBUG D#7 s=> iD.1935 saved_stack.2_1 = __builtin_stack_save (); # DEBUG BEGIN_STMT # DEBUG D#6 => D#7 + 1 # DEBUG D#5 => (long intD.8) D#6 # DEBUG D#4 => D#5 + -1 # DEBUG D.1937 => (sizetype) D#4 # DEBUG a.0D.1942 => NULL # DEBUG BEGIN_STMT - # DEBUG D#3 => D#8 + 2 + # DEBUG D#3 => D#7 + 2 # DEBUG D#2 => (long intD.8) D#3 # DEBUG D#1 => D#2 + -1 # DEBUG D.1944 => (sizetype) D#1 # DEBUG b.1D.1949 => NULL ... Bootstrapped and reg-tested on x86_64. 2018-07-07 Tom de Vries * tree-inline.c (remap_ssa_name): Save and reuse debug exprs generated in remap_ssa_name. * gcc.dg/vla-1.c: Update. --- gcc/testsuite/gcc.dg/vla-1.c | 5 +++-- gcc/tree-inline.c | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vla-1.c b/gcc/testsuite/gcc.dg/vla-1.c index 0c19feffd2b..94db23d1336 100644 --- a/gcc/testsuite/gcc.dg/vla-1.c +++ b/gcc/testsuite/gcc.dg/vla-1.c @@ -20,6 +20,7 @@ main () return 0; } -/* One debug source bind is generated for the parameter, and two to describe the +/* One debug source bind is generated for the parameter, and one to describe the sizes of a and b. */ -/* { dg-final { scan-tree-dump-times " s=> i" 3 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " s=> i" 2 "optimized" } } */ + diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 6fbd8c3ca61..164c7fff710 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -215,12 +215,16 @@ remap_ssa_name (tree name, copy_body_data *id) processing_debug_stmt = -1; return name; } + n = id->decl_map->get (val); + if (n && TREE_CODE (*n) == DEBUG_EXPR_DECL) + return *n; def_temp = gimple_build_debug_source_bind (vexpr, val, NULL); DECL_ARTIFICIAL (vexpr) = 1; TREE_TYPE (vexpr) = TREE_TYPE (name); SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name))); gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun))); gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT); + insert_decl_map (id, val, vexpr); return vexpr; }