From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65879 invoked by alias); 26 Sep 2016 07:33:50 -0000 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 Received: (qmail 65846 invoked by uid 89); 26 Sep 2016 07:33:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Felix, HRB, felix, hrb X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Sep 2016 07:33:40 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B0471AC29 for ; Mon, 26 Sep 2016 07:33:37 +0000 (UTC) Date: Mon, 26 Sep 2016 07:42:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix missed debug PR77692 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-09/txt/msg01785.txt.bz2 On Fri, 23 Sep 2016, Richard Biener wrote: > > I am testing the following patch which re-instantiates behavior > to emit DW_AT_const_value attributes for optimized out non-readonly > global statics. Those are readonly by means of the ability to > remove them early (before any optimization such as removing stores > to write-only global vars). Before my change to make the > late_global_decl debug hook not go via > add_location_or_const_value_attribute but only > tree_add_const_value_attribute_for_decl during the early debug phase > the former function ran into rtl_for_decl_location doing > > /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time > constant, > and will have been substituted directly into all expressions that use > it. > C does not have such a concept, but C++ and other languages do. */ > if (!rtl && TREE_CODE (decl) == VAR_DECL && DECL_INITIAL (decl)) > rtl = rtl_for_decl_init (DECL_INITIAL (decl), TREE_TYPE (decl)); > > where obviously at this point of the compilation no DECL_RTL was > created yet (the above code looks fishy to me -- > tree_add_const_value_attribute_for_decl checks for TREE_READONLY on > the decl). > > Anyway, bootstrapping and regtesting the following on > x86_64-unknown-linux-gnu (it makes gcc.dg/debug/dwarf2/const-2b.c PASS > again). > > Comments welcome. Applied as r240483. Richard. > Richard. > > 2016-09-23 Richard Biener > > PR debug/77692 > * cgraphunit.c (analyze_functions): Before early removing > global vars calls the late_global_decl debug handler mark > the variable as readonly. > > Index: gcc/cgraphunit.c > =================================================================== > --- gcc/cgraphunit.c (revision 240388) > +++ gcc/cgraphunit.c (working copy) > @@ -1194,8 +1194,15 @@ analyze_functions (bool first_time) > at looking at optimized away DECLs, since > late_global_decl will subsequently be called from the > contents of the now pruned symbol table. */ > - if (!decl_function_context (node->decl)) > - (*debug_hooks->late_global_decl) (node->decl); > + if (TREE_CODE (node->decl) == VAR_DECL > + && !decl_function_context (node->decl)) > + { > + /* We are reclaiming totally unreachable code and variables > + so they effectively appear as readonly. Show that to > + the debug machinery. */ > + TREE_READONLY (node->decl) = 1; > + (*debug_hooks->late_global_decl) (node->decl); > + } > > node->remove (); > continue; > > -- Richard Biener SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)