From patchwork Fri Apr 10 21:10:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 460232 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DB0881401F6 for ; Sat, 11 Apr 2015 07:10:53 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=jaHahuQu; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=O2acyDNPrdXgEn9Z7 iL2NZzg+1kwoSSCf4/ktYkS/Y8AKU51b75WGd9+7qiNLeBmsQrs1wbdaqfsoBEYX Nx70qf1gZB6hSr9XSZKOzaebYSBoMkyjHzIDX3b0PBGvWF/5zXZsayYtQBSuRNSm mJD7xE6N2JlRyWdHEVe7rVCbSc= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=UEW5cQ09Te9ahy2o/qXAaEZ b7Mg=; b=jaHahuQuKRAIXkaAQH6SW1uRcLCFeqIkGZ6Gt0j88tHilG062ZnJ2MC OsPl2f46WLMmyfsJirdLryWWsB8bO1hw1XmZaOJbssyxi0D7P9WSk5jIYVFCQX0M PW0hCZp6HM7AWJQILlhexoi7sX2YRyiRmASf5rWtcNqc+F4Odc4c= Received: (qmail 111222 invoked by alias); 10 Apr 2015 21:10:46 -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 111198 invoked by uid 89); 10 Apr 2015 21:10:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Apr 2015 21:10:44 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3ALAgst010785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 10 Apr 2015 17:10:42 -0400 Received: from reynosa.quesejoda.com (vpn-61-146.rdu2.redhat.com [10.10.61.146]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3ALAfDF004108; Fri, 10 Apr 2015 17:10:42 -0400 Message-ID: <55283C51.40204@redhat.com> Date: Fri, 10 Apr 2015 14:10:41 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jason Merrill CC: gcc-patches Subject: Re: [debug-early] equate new DIE with DW_AT_specificationto a previous declaration References: <5508874D.70008@redhat.com> <5508DF27.9060607@redhat.com> <55099EEB.70402@redhat.com> <551EA684.8090600@redhat.com> In-Reply-To: <551EA684.8090600@redhat.com> On 04/03/2015 07:41 AM, Jason Merrill wrote: > On 03/18/2015 11:51 AM, Aldy Hernandez wrote: >> On 03/17/2015 07:12 PM, Jason Merrill wrote: >>> Why are we outlining a DECL_EXTERNAL function? >> >> SRA has no restrictions on whether a function is DECL_EXTERNAL. > > Aha. > > So it seems that DECL_EXTERNAL is the wrong gate for > equate_decl_number_to_die here. I think the rule we want is that if we > don't already have a non-declaration DIE for a function, we should > equate the new DIE. Let's remove the existing calls and replace them > with a single conditional call before the if (declaration). Nice. Done. > Incidentally, > >> /* A declaration that has been previously dumped needs no >> additional information. */ >> if (dumped_early && declaration) >> return; > > Do we need to check dumped_early here? I would think that any > declaration that has an old_die needs no additional information. Indeed, good catch. Fixed. The attached patch fixes the original regression, and introduces none in either gdb or the guality tests on gcc. OK for branch? Aldy diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 0976415..d7c367e 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18743,13 +18743,13 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) much as possible. */ else if (old_die) { - dumped_early = old_die->dumped_early; - /* A declaration that has been previously dumped needs no additional information. */ - if (dumped_early && declaration) + if (declaration) return; + dumped_early = old_die->dumped_early; + if (!get_AT_flag (old_die, DW_AT_declaration) /* We can have a normal definition following an inline one in the case of redefinition of GNU C extern inlines. @@ -18829,8 +18829,6 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) add_type_attribute (subr_die, TREE_TYPE (TREE_TYPE (decl)), TYPE_UNQUALIFIED, context_die); } - if (early_dwarf_dumping) - equate_decl_number_to_die (decl, subr_die); } } /* Anything else... create a brand new DIE. */ @@ -18860,6 +18858,11 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) add_accessibility_attribute (subr_die, decl); } + /* Unless we have an existing non-declaration DIE, eqaute the new + DIE. */ + if (!old_die || is_declaration_die (old_die)) + equate_decl_number_to_die (decl, subr_die); + if (declaration) { if (!old_die || !get_AT (old_die, DW_AT_inline)) @@ -18877,15 +18880,6 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) if (lang_hooks.decls.function_decl_deleted_p (decl) && (! dwarf_strict)) add_AT_flag (subr_die, DW_AT_GNU_deleted, 1); - - /* The first time we see a member function, it is in the context of - the class to which it belongs. We make sure of this by emitting - the class first. The next time is the definition, which is - handled above. The two may come from the same source text. - - Note that force_decl_die() forces function declaration die. It is - later reused to represent definition. */ - equate_decl_number_to_die (decl, subr_die); } } /* Tag abstract instances with DW_AT_inline. */ @@ -18909,8 +18903,6 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) if (DECL_DECLARED_INLINE_P (decl) && lookup_attribute ("artificial", DECL_ATTRIBUTES (decl))) add_AT_flag (subr_die, DW_AT_artificial, 1); - - equate_decl_number_to_die (decl, subr_die); } /* For non DECL_EXTERNALs, if range information is available, fill the DIE with it. */ @@ -18920,9 +18912,6 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) struct function *fun = DECL_STRUCT_FUNCTION (decl); - if (!old_die || !get_AT (old_die, DW_AT_inline)) - equate_decl_number_to_die (decl, subr_die); - /* If we have no fun->fde, we have no range information. Skip over and fill in range information in the second dwarf pass. */ @@ -19090,14 +19079,9 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) } /* Generate child dies for template paramaters. */ - if (debug_info_level > DINFO_LEVEL_TERSE) - { - /* XXX */ - if (!lookup_decl_die (decl)) - equate_decl_number_to_die (decl, subr_die); - if (early_dwarf_dumping) - gen_generic_params_dies (decl); - } + if (debug_info_level > DINFO_LEVEL_TERSE + && early_dwarf_dumping) + gen_generic_params_dies (decl); /* Now output descriptions of the arguments for this function. This gets (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list