From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4391 invoked by alias); 23 Mar 2018 09:58:23 -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 4368 invoked by uid 89); 23 Mar 2018 09:58:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_NUMSUBJECT,KAM_SHORT,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=preserving X-Spam-User: qpsmtpd, 2 recipients 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; Fri, 23 Mar 2018 09:58:20 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B6DEEAC81; Fri, 23 Mar 2018 09:58:16 +0000 (UTC) Date: Fri, 23 Mar 2018 10:13:00 -0000 From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org, jakub@gcc.gnu.org, ebotcazou@adacore.com Subject: Re: [PATCH] Fix PR85020 In-Reply-To: <20180322143937.GR8577@tucnak> Message-ID: References: <20180322143937.GR8577@tucnak> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2018-03/txt/msg01279.txt.bz2 On Thu, 22 Mar 2018, Jakub Jelinek wrote: > On Thu, Mar 22, 2018 at 03:16:22PM +0100, Richard Biener wrote: > > the upper bound decl is global as well). Jakub, do you remember > > a reason for having any constraints here? I've reworked the > > I don't, but it has been added in the > https://gcc.gnu.org/ml/gcc-patches/2017-02/msg01499.html > patch. It matches what we were using before: > - if (loc == NULL > - && early_dwarf > - && current_function_decl > - && DECL_CONTEXT (rszdecl) == current_function_decl) > when emitting the DW_OP_call4 stuff. > > But more importantly, it seems that resolve_variable_value_in_expr > will not change anything if > tree decl = loc->dw_loc_oprnd1.v.val_decl_ref; > if (DECL_CONTEXT (decl) != current_function_decl) > continue; > Which means resolve_variable_values would never process those > DW_OP_GNU_variable_value you've added, Ah, ok. I guess this check can be simply removed. > and I believe later on > note_variable_value_in_expr will just ICE on it: > if (loc->dw_loc_opc == DW_OP_GNU_variable_value > && loc->dw_loc_oprnd1.val_class == dw_val_class_decl_ref) > ... > if (! ref && (flag_generate_lto || flag_generate_offload)) > { > /* ??? This is somewhat a hack because we do not create DIEs > for variables not in BLOCK trees early but when generating > early LTO output we need the dw_val_class_decl_ref to be > fully resolved. For fat LTO objects we'd also like to > undo this after LTO dwarf output. */ > gcc_assert (DECL_CONTEXT (decl)); > Because DECL_CONTEXT (decl) is NULL, right? It's TRANSLATION_UNIT_DECL for the Ada case (we do have FEs where decls may have NULL context which then means file-scope). > Or is DECL_CONTEXT never NULL in LTO, just TRANSLATION_UNIT_DECL? > If so, perhaps note_variable_value_in_expr will handle those fine, > but for these we really don't want to force any DIEs, but rather just give > up if lookup_decl fails by the time we've processed the whole TU. Yeah, I guess the whole ! ref case should go and instead drop the location expression. Is there some convenient "NULL" OP we can use for or do we really have to prune the attribute refering to it? As the comment says for the FAT part we'd like to keep the decl and defer for later fixup so if there's a way to emit DWARF for a val_decl_ref we should maybe simply fix it up at emission time? I see there's DW_OP_nop but I guess a nop in random places of a DWARF location expression isn't a good way to say for that part. That said, the second hunk of my patch fixes the bootstrap issue with Ada (will double-check), the first hunk is only to try preserving some debug info for the Ada case where the variable parts are not necessarily function-local. Let's delay that for now. I suppose the 2nd hunk is ok. For reference that was Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 258684) +++ gcc/dwarf2out.c (working copy) @@ -19878,6 +19878,7 @@ rtl_for_decl_location (tree decl) in the current CU, resolve_addr will remove the expression referencing it. */ if (rtl == NULL_RTX + && !(early_dwarf && (flag_generate_lto || flag_generate_offload)) && VAR_P (decl) && !DECL_EXTERNAL (decl) && TREE_STATIC (decl) Richard.