From patchwork Wed Aug 1 10:03:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 174427 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 03FBC2C007E for ; Wed, 1 Aug 2012 20:04:06 +1000 (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=1344420247; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=YNje/j5McIWdEqjyPS5HWae9tIM=; b=xCSQvExZdDlbaK1XRCrntfYFzvX4JdU8v7EbrisPkagZjaZiBIfqgvKP34e012 uK/EDE6r6eZNDXUIlDl6Rxo4Bkv1/Hnx2IWCS7mhhyDAwvU/F6xWZaxHVUFvaRKO tpHytPgJtn5MTvQb9z3tX9TrIlOT3qOb0kSLuVgqKNaNk= 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:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=etrMO4PUZGjd89HNl5qHgZZh0QAcbkSf5K+EIABZcQmupti37Yjbd+WMa6YEWq zjNDqF8iz4TPgGZFHU3mfOXNNaPxYCxD3dqEExDjlNqFoG/IlgzcHBO8jNkWQOhk 7ufZn+Snnjh5eYDDXVxLyn9ZSYZYNYcYXV4Jswd+MREz8=; Received: (qmail 8580 invoked by alias); 1 Aug 2012 10:04:03 -0000 Received: (qmail 8571 invoked by uid 22791); 1 Aug 2012 10:04:02 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Aug 2012 10:03:49 +0000 Received: by yhjj56 with SMTP id j56so7126047yhj.20 for ; Wed, 01 Aug 2012 03:03:49 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.24.7 with SMTP id q7mr27854308oef.54.1343815428930; Wed, 01 Aug 2012 03:03:48 -0700 (PDT) Received: by 10.76.90.71 with HTTP; Wed, 1 Aug 2012 03:03:48 -0700 (PDT) In-Reply-To: <20111202192848.GH27242@tyan-ft48-01.lab.bos.redhat.com> References: <20111201164906.GZ27242@tyan-ft48-01.lab.bos.redhat.com> <20111202192848.GH27242@tyan-ft48-01.lab.bos.redhat.com> Date: Wed, 1 Aug 2012 12:03:48 +0200 Message-ID: Subject: Re: [PATCH] Improve debug info if tree DCE removes stores (PR debug/50317, fallout) From: Richard Guenther To: Jakub Jelinek Cc: Richard Guenther , Alexandre Oliva , Michael Matz , gcc-patches@gcc.gnu.org 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, Dec 2, 2011 at 8:28 PM, Jakub Jelinek wrote: > On Fri, Dec 02, 2011 at 02:27:40PM +0100, Richard Guenther wrote: >> This change seems wrong. We are turning valid gimple >> >> # DEBUG D#2 => transfer.0 [with addres taken] >> >> into invalid one >> >> # DEBUG D#2 => transfer.0 [without address taken] >> >> once you update that stmt with update_stmt you'll get an SSA operand >> for transfer.0 which is not in SSA form because you fail to rewrite it >> into. >> >> Why do this in remove_unused_locals and not in update_address_taken? >> Or, why do it at all? >> >> I have a SSA operand checking patch that catches this now ... > > Here is a fix for that. Instead of clearing TREE_ADDRESSABLE for > unreferenced vars we allow them in target_for_debug_bind if they aren't > referenced vars (thus we don't risk mixing VALUE tracking with the > old style REG_EXPR/MEM_EXPR tracking of these variables). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2011-12-02 Jakub Jelinek > > PR debug/50317 > * tree-ssa.c (target_for_debug_bind): Also allow is_gimple_reg_type > vars that aren't referenced. > (tree-ssa-live.c (remove_unused_locals): Don't clear TREE_ADDRESSABLE > of unreferenced local vars. > * cfgexpand.c (expand_debug_expr): For DEBUG_IMPLICIT_PTR allow also > TREE_ADDRESSABLE vars that satisfy target_for_debug_bind. > > --- gcc/tree-ssa.c.jj 2011-11-29 08:58:52.000000000 +0100 > +++ gcc/tree-ssa.c 2011-12-02 15:04:03.494148642 +0100 > @@ -264,7 +264,12 @@ target_for_debug_bind (tree var) > return NULL_TREE; > > if (!is_gimple_reg (var)) > - return NULL_TREE; > + { > + if (is_gimple_reg_type (TREE_TYPE (var)) > + && referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE) > + return var; > + return NULL_TREE; > + } With referenced-vars going away now I am running into the above use of referenced-vars again. So the above tries to increase the set of tracked "registers" by noting that unused non-registers that might have become registers are supposed to be tracked anyway. But we do _not_ want to have used non-register (but register type) variables tracked because we do not track aliases? Or because that would be prohibitively expensive? That is, why is not what we want (minus dealing with fallout of having mixed SSA / non-SSA after something makes var suitable for renaming into SSA form)? Richard. > return var; > } > --- gcc/tree-ssa-live.c.jj 2011-12-02 01:52:27.000000000 +0100 > +++ gcc/tree-ssa-live.c 2011-12-02 15:04:59.601816335 +0100 > @@ -814,15 +814,7 @@ remove_unused_locals (void) > bitmap_set_bit (global_unused_vars, DECL_UID (var)); > } > else > - { > - /* For unreferenced local vars drop TREE_ADDRESSABLE > - bit in case it is referenced from debug stmts. */ > - if (DECL_CONTEXT (var) == current_function_decl > - && TREE_ADDRESSABLE (var) > - && is_gimple_reg_type (TREE_TYPE (var))) > - TREE_ADDRESSABLE (var) = 0; > - continue; > - } > + continue; > } > else if (TREE_CODE (var) == VAR_DECL > && DECL_HARD_REGISTER (var) > --- gcc/cfgexpand.c.jj 2011-12-02 01:52:27.000000000 +0100 > +++ gcc/cfgexpand.c 2011-12-02 15:24:37.982327507 +0100 > @@ -3325,7 +3325,8 @@ expand_debug_expr (tree exp) > if ((TREE_CODE (TREE_OPERAND (exp, 0)) == VAR_DECL > || TREE_CODE (TREE_OPERAND (exp, 0)) == PARM_DECL > || TREE_CODE (TREE_OPERAND (exp, 0)) == RESULT_DECL) > - && !TREE_ADDRESSABLE (TREE_OPERAND (exp, 0))) > + && (!TREE_ADDRESSABLE (TREE_OPERAND (exp, 0)) > + || target_for_debug_bind (TREE_OPERAND (exp, 0)))) > return gen_rtx_DEBUG_IMPLICIT_PTR (mode, TREE_OPERAND (exp, 0)); > > if (handled_component_p (TREE_OPERAND (exp, 0))) > @@ -3337,7 +3338,8 @@ expand_debug_expr (tree exp) > if ((TREE_CODE (decl) == VAR_DECL > || TREE_CODE (decl) == PARM_DECL > || TREE_CODE (decl) == RESULT_DECL) > - && !TREE_ADDRESSABLE (decl) > + && (!TREE_ADDRESSABLE (decl) > + || target_for_debug_bind (decl)) > && (bitoffset % BITS_PER_UNIT) == 0 > && bitsize > 0 > && bitsize == maxsize) > > > Jakub Index: tree-ssa.c =================================================================== --- tree-ssa.c (revision 190031) +++ tree-ssa.c (working copy) @@ -259,13 +259,9 @@ target_for_debug_bind (tree var) if (DECL_IGNORED_P (var)) return NULL_TREE; - if (!is_gimple_reg (var)) - { - if (is_gimple_reg_type (TREE_TYPE (var)) - && referenced_var_lookup (cfun, DECL_UID (var)) == NULL_TREE) - return var; - return NULL_TREE; - } + /* var-tracking only tracks registers. */ + if (!is_gimple_reg_type (TREE_TYPE (var))) + return NULL_TREE; return var; }