From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 86923 invoked by alias); 15 May 2017 12:43:49 -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 86228 invoked by uid 89); 15 May 2017 12:43:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Mon, 15 May 2017 12:43:46 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 732E1AB43; Mon, 15 May 2017 12:43:45 +0000 (UTC) Date: Mon, 15 May 2017 12:47:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] Two DW_OP_GNU_variable_value fixes / tweaks Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2017-05/txt/msg01176.txt.bz2 While bringing early LTO debug up-to-speed I noticed the following two issues. The first patch avoids useless work in note_variable_value_in_expr and actually makes use of the DIE we eventually create in resolve_variable_value_in_expr. The second avoids generating a DW_OP_GNU_variable_value for a decl we'll never have a DIE for -- this might be less obvious than the other patch but I think we'll also never have any other debug info we can resolve the decl with(?) Bootstrapped and tested the first patch sofar on x86_64-unknown-linux-gnu, 2nd is pending. Ok? Thanks, Richard. 2017-05-15 Richard Biener * dwarf2out.c (resolve_variable_value_in_expr): Lookup DIE just generated. (note_variable_value_in_expr): If we resolved the decl ref do not push to the stack. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 248055) +++ gcc/dwarf2out.c (working copy) @@ -30109,8 +30109,9 @@ resolve_variable_value_in_expr (dw_attr_ break; } /* Create DW_TAG_variable that we can refer to. */ - ref = gen_decl_die (decl, NULL_TREE, NULL, - lookup_decl_die (current_function_decl)); + gen_decl_die (decl, NULL_TREE, NULL, + lookup_decl_die (current_function_decl)); + ref = lookup_decl_die (decl); if (ref) { loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; @@ -30203,6 +30204,7 @@ note_variable_value_in_expr (dw_die_ref loc->dw_loc_oprnd1.val_class = dw_val_class_die_ref; loc->dw_loc_oprnd1.v.val_die_ref.die = ref; loc->dw_loc_oprnd1.v.val_die_ref.external = 0; + continue; } if (VAR_P (decl) && DECL_CONTEXT (decl) 2017-05-15 Richard Biener * dwarf2out.c (loc_list_from_tree_1): Do not create DW_OP_GNU_variable_value for DECL_IGNORED_P decls. Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 248054) +++ gcc/dwarf2out.c (working copy) @@ -17373,6 +17685,7 @@ loc_list_from_tree_1 (tree loc, int want && early_dwarf && current_function_decl && want_address != 1 + && ! DECL_IGNORED_P (loc) && (INTEGRAL_TYPE_P (TREE_TYPE (loc)) || POINTER_TYPE_P (TREE_TYPE (loc))) && DECL_CONTEXT (loc) == current_function_decl