From patchwork Tue Mar 24 18:00:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 453972 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 6EA5F140119 for ; Wed, 25 Mar 2015 05:00:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Nc1RCod3; 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:subject:content-type; q= dns; s=default; b=RqR7qrdPLbLTFuQDV59/Qnugyrm8eIAc8z4DX1djgP8xKs id58qdqdGiBDyB2yRPQIHczj07l4NKBXlf12H7UIHXJj8HWf+vjz3v2nxt19b4dY 7CzatwdGFPRfX25wcEBLy/ED9ahW8Fl8lUrCamZNUozSkyRFiZo3W34a2OZmg= 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:subject:content-type; s= default; bh=FlWyBJVKMjoAcmWeBTfMVXcAmJA=; b=Nc1RCod3L+dP+GuGay5o 6fXQ0StToBLrSi+uQWdfSKApDGg6qIp7zcMRdqde6hLjzuGCr65xESRrgslIFyhz z8O+BAQqN2Hu3IGNaD40Al4GWw6I9gasrPpznwVqLWZ0pcP/E2ORGj+CbX+Vgnbb AGCPmPr4dk7C4VoDr9jhgtw= Received: (qmail 8436 invoked by alias); 24 Mar 2015 18:00:11 -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 8410 invoked by uid 89); 24 Mar 2015 18:00:10 -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; Tue, 24 Mar 2015 18:00:09 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2OI08p7007897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 24 Mar 2015 14:00:08 -0400 Received: from reynosa.quesejoda.com (vpn-55-16.rdu2.redhat.com [10.10.55.16]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2OI078V001975; Tue, 24 Mar 2015 14:00:07 -0400 Message-ID: <5511A626.8070708@redhat.com> Date: Tue, 24 Mar 2015 11:00:06 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: jason merrill , gcc-patches Subject: [debug-early] emit early dwarf for locally scoped functions Hi Jason. I found that for locally scoped functions we were not emitting early dwarf. I've removed the restriction that only emitted non function-context functions to handle the case below. BTW, this shouldn't be a (bloat) problem, as we are going to clean up unused DIEs later (well, next week :)). void foobar () { class Object { public: char Object_method () { return 5; } }; Object local; local.Object_method(); } There was also a GDB regression with the above test (distilled from gdb.cp/local.cc) where Object_method's type was being generated as char Object_method (const Object *) (or something like it). The problem was that gen_formal_types_die was creating nameless DIEs for the formal parameters when generating an object's members, but mainline was removing these nameless DIEs and I had mistakenly removed that bit. I'm putting the code back in, but guarding it with early_dwarf_dumping, since by the time we get to late debug, we should have the correct named parameters which should then be augmented with location information. This patch fixes the gdb.cp/local.cc regressions, while generating early dwarf for Object_method and associates. I'm committing to the branch. Let me know if you have a problem with this. Tested with the guality.exp suite as well as the GDB testsuite. Aldy commit 8673cbf8204fcd7099507293a859b173343a0f9a Author: Aldy Hernandez Date: Tue Mar 24 10:47:30 2015 -0700 Emit early dwarf for locally scoped functions. Only remove cached DW_TAG_formal_parameter's when early dwarf dumping. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index e60acd5..4a7b14d 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2444,8 +2444,7 @@ symbol_table::finalize_compilation_unit (void) locally scoped symbols. */ struct cgraph_node *cnode; FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode) - if (!decl_function_context (cnode->decl)) - (*debug_hooks->early_global_decl) (cnode->decl); + (*debug_hooks->early_global_decl) (cnode->decl); /* Clean up anything that needs cleaning up after initial debug generation. */ diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 48e2eed..bcc1111 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -18792,6 +18792,18 @@ gen_subprogram_die (tree decl, dw_die_ref context_die) parameters so they can be augmented with location information later. */ remove_AT (subr_die, DW_AT_declaration); + + /* gen_formal_types_die could have created nameless DIEs for + the formal parameters when generating an object's + members. Remove if early dumping; they will be shortly + recreated correctly. If we're not early dumping, we + should've already removed them and should have actual + named parameters. */ + if (early_dwarf_dumping) + { + remove_AT (subr_die, DW_AT_object_pointer); + remove_child_TAG (subr_die, DW_TAG_formal_parameter); + } } /* Make a specification pointing to the previously built declaration. */