From patchwork Fri Jul 14 16:48:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 788630 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 3x8JYf3cmVz9s7m for ; Sat, 15 Jul 2017 02:49:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mZvF2VqG"; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=MvglbBoUWX7qmVF0z 5z021VOuy48uiFXrLFw/hBPJfc3p3rsoEwUTuqwMURJQewxGyJ/SF+xYrEh5bXzt ceGivNxyMtOIyhO+5YIeVKcLelkPsWVm510F8WoAOkIANhFXjZnDqBf7KjBrsm2L O84c6IFkBmo8hKXj/ovXMJsG3Y= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=I9sEDGduqJ3uRR1TqJUdbVP wmqA=; b=mZvF2VqGjGSuZmQLOsKbK1ghhzpfELyezOzq35kWMPu4WdPI+fzUQBm DyDatx7YMoLoIA/ohpzv5wN+wYqOmDcUKz/RWRoczgTDqT0n2hxnpyms3t2RxbFf sQjF+yOjnJfv44TRgL19vStApgfjr9oRHb0ZOoNbX1P/SuYvWvIs= Received: (qmail 58056 invoked by alias); 14 Jul 2017 16:49:01 -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 58044 invoked by uid 89); 14 Jul 2017 16:49:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-14.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-it0-f43.google.com Received: from mail-it0-f43.google.com (HELO mail-it0-f43.google.com) (209.85.214.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jul 2017 16:48:58 +0000 Received: by mail-it0-f43.google.com with SMTP id m84so28155239ita.0 for ; Fri, 14 Jul 2017 09:48:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to; bh=DeQ9+y9B+5pJ2CGui/oPCq2PIgfIORTRLUhGQIL12hM=; b=pjtxZF26qEgGm92cKj0TnPpl9dk/1azlJR2yvVxs8ahTFC0MAI9XLqGuZSZqqE65xl V/XsCdzd/ZalaFxreJkyAtKyxZXqTMCtyvvTRH9HAua1GAsS7kpnmhZq4xkXvfqZB1Wr fHBjmHvrxWAAEQDdYGYqHo0v6HbqbhhT43C9Lx033A1RPq/uCPf6LjcYNanSaVOE9FsY BwRJ+q/16oY6BOIpVIDGmrzL4MF4mvWt8kCNAVlYWz8/jDna48eARO5g269YTzqJ+kTz aRElNpu4UsQ8kowZGJu+DLG1ccKYY6S2KxnqufUUI0F0HBmN89jyGB+856u5fO6ezExn 0v5Q== X-Gm-Message-State: AIVw111aRdMV0vpRP/7KypxXFOurm2ou8QZlDkpk3037AZymOFukyLpz 7Ed9P0X7AwS5UA== X-Received: by 10.36.57.86 with SMTP id l83mr4643887ita.34.1500050937239; Fri, 14 Jul 2017 09:48:57 -0700 (PDT) Received: from [100.64.209.104] (public-120-7.nat.utoronto.ca. [138.51.120.7]) by smtp.googlemail.com with ESMTPSA id i202sm349443itb.5.2017.07.14.09.48.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 09:48:56 -0700 (PDT) Subject: Re: [PATCH] Kill TYPE_METHODS debug 1/9 To: GCC Patches References: <8377f2cd-577c-60b2-63ac-f2619ebe63aa@acm.org> Cc: Jason Merrill , Richard Guenther , Jim Wilson , Jan Hubicka From: Nathan Sidwell Message-ID: Date: Fri, 14 Jul 2017 12:48:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <8377f2cd-577c-60b2-63ac-f2619ebe63aa@acm.org> This changes dbxout and dwarf2out. Rather than iterate over the TYPE_METHODS, they now need to deal with member fns in the regular TYPE_FIELDS iteration. dbxout was a little weirdly convoluted, apparently presuming that functions with the same name are all together. That's not true, so other than maybe slight debug bloat in cases when they happen to be adjacent, it seems more sensible to handle each member function as a separate item. The dwarf2out changes are just moving the processing to the TYPE_FIELDS loop, and thereby deleting some duplicate code. I'd appreciate a review of this patch. Oh, the patch series survived a bootstrap on x86_64-linux. nathan Index: gcc/dbxout.c =================================================================== --- gcc/dbxout.c (revision 250160) +++ gcc/dbxout.c (working copy) @@ -311,8 +311,7 @@ static void dbxout_typedefs (tree); static void dbxout_type_index (tree); static void dbxout_args (tree); static void dbxout_type_fields (tree); -static void dbxout_type_method_1 (tree); -static void dbxout_type_methods (tree); +static void dbxout_type_fn_member (tree); static void dbxout_range_type (tree, tree, tree); static void dbxout_type (tree, int); static bool print_int_cst_bounds_in_octal_p (tree, tree, tree); @@ -1493,6 +1492,8 @@ dbxout_type_fields (tree type) || ! tree_fits_uhwi_p (DECL_SIZE (tem))))) continue; + else if (TREE_CODE (tem) == FUNCTION_DECL) + dbxout_type_fn_member (tem); else if (TREE_CODE (tem) != CONST_DECL) { /* Continue the line if necessary, @@ -1542,14 +1543,23 @@ dbxout_type_fields (tree type) } } -/* Subroutine of `dbxout_type_methods'. Output debug info about the - method described DECL. */ +/* Subroutine of `dbxout_type'. Output debug info about the + function member DECL. */ static void -dbxout_type_method_1 (tree decl) +dbxout_type_fn_member (tree decl) { + if (!use_gnu_debug_info_extensions) + return; + char c1 = 'A', c2; + CONTIN; + stabstr_I (DECL_NAME (decl)); + stabstr_S ("::"); + + dbxout_type (TREE_TYPE (decl), 0); + if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE) c2 = '?'; else /* it's a METHOD_TYPE. */ @@ -1586,72 +1596,7 @@ dbxout_type_method_1 (tree decl) dbxout_type (DECL_CONTEXT (decl), 0); stabstr_C (';'); } -} - -/* Subroutine of `dbxout_type'. Output debug info about the methods defined - in TYPE. */ - -static void -dbxout_type_methods (tree type) -{ - /* C++: put out the method names and their parameter lists */ - tree methods = TYPE_METHODS (type); - tree fndecl; - tree last; - - if (methods == NULL_TREE) - return; - - if (TREE_CODE (methods) != TREE_VEC) - fndecl = methods; - else if (TREE_VEC_ELT (methods, 0) != NULL_TREE) - fndecl = TREE_VEC_ELT (methods, 0); - else - fndecl = TREE_VEC_ELT (methods, 1); - - while (fndecl) - { - int need_prefix = 1; - - /* Group together all the methods for the same operation. - These differ in the types of the arguments. */ - for (last = NULL_TREE; - fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last)); - fndecl = DECL_CHAIN (fndecl)) - /* Output the name of the field (after overloading), as - well as the name of the field before overloading, along - with its parameter list */ - { - /* Skip methods that aren't FUNCTION_DECLs. (In C++, these - include TEMPLATE_DECLs.) The debugger doesn't know what - to do with such entities anyhow. */ - if (TREE_CODE (fndecl) != FUNCTION_DECL) - continue; - - CONTIN; - - last = fndecl; - - /* Also ignore abstract methods; those are only interesting to - the DWARF backends. */ - if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT_P (fndecl)) - continue; - - /* Redundantly output the plain name, since that's what gdb - expects. */ - if (need_prefix) - { - stabstr_I (DECL_NAME (fndecl)); - stabstr_S ("::"); - need_prefix = 0; - } - - dbxout_type (TREE_TYPE (fndecl), 0); - dbxout_type_method_1 (fndecl); - } - if (!need_prefix) - stabstr_C (';'); - } + stabstr_C (';'); } /* Emit a "range" type specification, which has the form: @@ -2211,10 +2156,6 @@ dbxout_type (tree type, int full) /* Write out the field declarations. */ dbxout_type_fields (type); - if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE) - { - dbxout_type_methods (type); - } stabstr_C (';'); Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 250160) +++ gcc/dwarf2out.c (working copy) @@ -24088,7 +24088,8 @@ gen_member_die (tree type, dw_die_ref co { tree member; tree binfo = TYPE_BINFO (type); - dw_die_ref child; + + gcc_assert (TYPE_MAIN_VARIANT (type) == type); /* If this is not an incomplete type, output descriptions of each of its members. Note that as we output the DIEs necessary to represent the @@ -24125,13 +24126,16 @@ gen_member_die (tree type, dw_die_ref co && (lang_hooks.decls.decl_dwarf_attribute (member, DW_AT_inline) != -1)); + /* Ignore clones. */ + if (DECL_ABSTRACT_ORIGIN (member)) + continue; + /* If we thought we were generating minimal debug info for TYPE and then changed our minds, some of the member declarations may have already been defined. Don't define them again, but do put them in the right order. */ - child = lookup_decl_die (member); - if (child) + if (dw_die_ref child = lookup_decl_die (member)) { /* Handle inline static data members, which only have in-class declarations. */ @@ -24159,6 +24163,7 @@ gen_member_die (tree type, dw_die_ref co static_inline_p = false; } } + if (child->die_tag == DW_TAG_variable && child->die_parent == comp_unit_die () && ref == NULL) @@ -24197,23 +24202,6 @@ gen_member_die (tree type, dw_die_ref co DECL_EXTERNAL (member) = old_extern; } } - - /* We do not keep type methods in type variants. */ - gcc_assert (TYPE_MAIN_VARIANT (type) == type); - /* Now output info about the function members (if any). */ - if (TYPE_METHODS (type) != error_mark_node) - for (member = TYPE_METHODS (type); member; member = DECL_CHAIN (member)) - { - /* Don't include clones in the member list. */ - if (DECL_ABSTRACT_ORIGIN (member)) - continue; - - child = lookup_decl_die (member); - if (child) - splice_child_die (context_die, child); - else - gen_decl_die (member, NULL, NULL, context_die); - } } /* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG