From patchwork Fri Jul 23 12:00:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 59772 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]) by ozlabs.org (Postfix) with SMTP id 3D86DB6EFE for ; Fri, 23 Jul 2010 21:58:13 +1000 (EST) Received: (qmail 15970 invoked by alias); 23 Jul 2010 11:58:11 -0000 Received: (qmail 15957 invoked by uid 22791); 23 Jul 2010 11:58:10 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_FILL_THIS_FORM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Jul 2010 11:58:03 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6NBw21Y019300 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 23 Jul 2010 07:58:02 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6NBw1lb019434 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 23 Jul 2010 07:58:01 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o6NC0C9D009065; Fri, 23 Jul 2010 14:00:12 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o6NC0BRe009064; Fri, 23 Jul 2010 14:00:11 +0200 Date: Fri, 23 Jul 2010 14:00:11 +0200 From: Jakub Jelinek To: Richard Henderson , Richard Guenther Cc: Roland McGrath , gcc-patches@gcc.gnu.org Subject: [PATCH] Don't emit certain artificial names into DW_AT_name in debug info Message-ID: <20100723120011.GH18378@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20100722162552.GA18378@tyan-ft48-01.lab.bos.redhat.com> <20100722191935.2EBF3400B8@magilla.sf.frob.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100722191935.2EBF3400B8@magilla.sf.frob.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 On Thu, Jul 22, 2010 at 12:19:35PM -0700, Roland McGrath wrote: > Similarly: > > > > Should that really have a name? As it stands, the debugger is going to > present ".omp_data_i" as a resolvable identifier in this scope, as it > would for any other artifical parameter (such as C++ "this"). > > Next: > > > > This needs artificial=true too. Again, it seems quite questionable > whether the non-source name should appear at all. AIUI, this sort of > thing is exactly what DW_AT_description is for. This patch attempts to deal with the artificial names of DW_AT_artificial DIEs in debug info, as discussed yesterday on IRC. We can't just avoid emitting DW_AT_name for DECL_ARTIFICIAL decls, because e.g. for `this' we want to emit the name. And, there are also types for which we don't want to emit the made up names. The names are useful in dumps though, so instead of clearing them this patch steals one free bit and uses it to say that DECL_NAME resp. TYPE_NAME shouldn't be added into debug info. In the debug info names like array3_integer(kind=4), a.0, .omp_data_i etc. are undesirable though, they show up when listing variables, stand in in tab completion, etc. Tested on a short fortran array testcase as well as OpenMP C testcase, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for trunk? 2010-07-23 Jakub Jelinek * tree.h (struct tree_base): Add nameless_flag bitfield. (TYPE_NAMELESS, DECL_NAMELESS): Define. * omp-low.c (create_omp_child_function, scan_omp_parallel, scan_omp_task, lower_omp_taskreg): Set DECL_NAMELESS and/or DECL_ARTIFICIAL where needed. * dwarf2out.c (dwarf2_name): Return NULL if DECL_NAMELESS. (type_tag): Return NULL if TYPE_NAMELESS or if TYPE_DECL has DECL_NAMELESS set. * trans-types.c (gfc_get_array_descriptor_base, gfc_get_array_type_bounds): Set TYPE_NAMELESS. * trans-decl.c (gfc_build_qualified_array): Set DECL_NAMELESS instead of clearing DECL_NAME. (gfc_build_dummy_array_decl): Set DECL_NAMELESS. Jakub --- gcc/tree.h.jj 2010-07-16 17:55:08.000000000 +0200 +++ gcc/tree.h 2010-07-23 10:44:34.000000000 +0200 @@ -387,8 +387,9 @@ struct GTY(()) tree_base { unsigned visited : 1; unsigned packed_flag : 1; unsigned user_align : 1; + unsigned nameless_flag : 1; - unsigned spare : 13; + unsigned spare : 12; /* This field is only used with type nodes; the only reason it is present in tree_base instead of tree_type is to save space. The size of the @@ -2180,6 +2181,9 @@ extern enum machine_mode vector_type_mod the term. */ #define TYPE_RESTRICT(NODE) (TYPE_CHECK (NODE)->type.restrict_flag) +/* If nonzero, type's name shouldn't be emitted into debug info. */ +#define TYPE_NAMELESS(NODE) (TYPE_CHECK (NODE)->base.nameless_flag) + /* The address space the type is in. */ #define TYPE_ADDR_SPACE(NODE) (TYPE_CHECK (NODE)->base.address_space) @@ -2529,6 +2533,10 @@ struct function; #define DECL_CONTEXT(NODE) (DECL_MINIMAL_CHECK (NODE)->decl_minimal.context) #define DECL_FIELD_CONTEXT(NODE) \ (FIELD_DECL_CHECK (NODE)->decl_minimal.context) + +/* If nonzero, decl's name shouldn't be emitted into debug info. */ +#define DECL_NAMELESS(NODE) (DECL_MINIMAL_CHECK (NODE)->base.nameless_flag) + struct GTY(()) tree_decl_minimal { struct tree_common common; location_t locus; --- gcc/omp-low.c.jj 2010-07-23 09:07:09.000000000 +0200 +++ gcc/omp-low.c 2010-07-23 11:16:03.000000000 +0200 @@ -1563,6 +1563,7 @@ create_omp_child_function (omp_context * TREE_STATIC (decl) = 1; TREE_USED (decl) = 1; DECL_ARTIFICIAL (decl) = 1; + DECL_NAMELESS (decl) = 1; DECL_IGNORED_P (decl) = 0; TREE_PUBLIC (decl) = 0; DECL_UNINLINABLE (decl) = 1; @@ -1580,6 +1581,7 @@ create_omp_child_function (omp_context * t = build_decl (DECL_SOURCE_LOCATION (decl), PARM_DECL, get_identifier (".omp_data_i"), ptr_type_node); DECL_ARTIFICIAL (t) = 1; + DECL_NAMELESS (t) = 1; DECL_ARG_TYPE (t) = ptr_type_node; DECL_CONTEXT (t) = current_function_decl; TREE_USED (t) = 1; @@ -1592,6 +1594,7 @@ create_omp_child_function (omp_context * PARM_DECL, get_identifier (".omp_data_o"), ptr_type_node); DECL_ARTIFICIAL (t) = 1; + DECL_NAMELESS (t) = 1; DECL_ARG_TYPE (t) = ptr_type_node; DECL_CONTEXT (t) = current_function_decl; TREE_USED (t) = 1; @@ -1638,6 +1641,8 @@ scan_omp_parallel (gimple_stmt_iterator name = create_tmp_var_name (".omp_data_s"); name = build_decl (gimple_location (stmt), TYPE_DECL, name, ctx->record_type); + DECL_ARTIFICIAL (name) = 1; + DECL_NAMELESS (name) = 1; TYPE_NAME (ctx->record_type) = name; create_omp_child_function (ctx, false); gimple_omp_parallel_set_child_fn (stmt, ctx->cb.dst_fn); @@ -1681,6 +1686,8 @@ scan_omp_task (gimple_stmt_iterator *gsi name = create_tmp_var_name (".omp_data_s"); name = build_decl (gimple_location (stmt), TYPE_DECL, name, ctx->record_type); + DECL_ARTIFICIAL (name) = 1; + DECL_NAMELESS (name) = 1; TYPE_NAME (ctx->record_type) = name; create_omp_child_function (ctx, false); gimple_omp_task_set_child_fn (stmt, ctx->cb.dst_fn); @@ -1692,6 +1699,8 @@ scan_omp_task (gimple_stmt_iterator *gsi name = create_tmp_var_name (".omp_data_a"); name = build_decl (gimple_location (stmt), TYPE_DECL, name, ctx->srecord_type); + DECL_ARTIFICIAL (name) = 1; + DECL_NAMELESS (name) = 1; TYPE_NAME (ctx->srecord_type) = name; create_omp_child_function (ctx, true); } @@ -6487,6 +6496,7 @@ lower_omp_taskreg (gimple_stmt_iterator ctx->sender_decl = create_tmp_var (ctx->srecord_type ? ctx->srecord_type : ctx->record_type, ".omp_data_o"); + DECL_NAMELESS (ctx->sender_decl) = 1; TREE_ADDRESSABLE (ctx->sender_decl) = 1; gimple_omp_taskreg_set_data_arg (stmt, ctx->sender_decl); } --- gcc/dwarf2out.c.jj 2010-07-23 09:07:15.000000000 +0200 +++ gcc/dwarf2out.c 2010-07-23 11:13:59.000000000 +0200 @@ -11243,6 +11243,8 @@ output_comdat_type_unit (comdat_type_nod static const char * dwarf2_name (tree decl, int scope) { + if (DECL_NAMELESS (decl)) + return NULL; return lang_hooks.dwarf_name (decl, scope ? 1 : 0); } @@ -17711,7 +17713,8 @@ type_tag (const_tree type) tree t = 0; /* Find the IDENTIFIER_NODE for the type name. */ - if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) + if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE + && !TYPE_NAMELESS (type)) t = TYPE_NAME (type); /* The g++ front end makes the TYPE_NAME of *each* tagged type point to @@ -17724,7 +17727,8 @@ type_tag (const_tree type) DECL_NAME isn't set. The default hook for decl_printable_name doesn't like that, and in this context it's correct to return 0, instead of "" or the like. */ - if (DECL_NAME (TYPE_NAME (type))) + if (DECL_NAME (TYPE_NAME (type)) + && !DECL_NAMELESS (TYPE_NAME (type))) name = lang_hooks.dwarf_name (TYPE_NAME (type), 2); } --- gcc/fortran/trans-types.c.jj 2010-07-16 17:55:04.000000000 +0200 +++ gcc/fortran/trans-types.c 2010-07-23 11:13:59.000000000 +0200 @@ -1546,6 +1546,7 @@ gfc_get_array_descriptor_base (int dimen sprintf (name, "array_descriptor" GFC_RANK_PRINTF_FORMAT, dimen + codimen); TYPE_NAME (fat_type) = get_identifier (name); + TYPE_NAMELESS (fat_type) = 1; /* Add the data member as the first element of the descriptor. */ decl = gfc_add_field_to_struct_1 (fat_type, @@ -1616,6 +1617,7 @@ gfc_get_array_type_bounds (tree etype, i sprintf (name, "array" GFC_RANK_PRINTF_FORMAT "_%.*s", dimen + codimen, GFC_MAX_SYMBOL_LEN, type_name); TYPE_NAME (fat_type) = get_identifier (name); + TYPE_NAMELESS (fat_type) = 1; GFC_DESCRIPTOR_TYPE_P (fat_type) = 1; TYPE_LANG_SPECIFIC (fat_type) --- gcc/fortran/trans-decl.c.jj 2010-07-22 11:35:35.000000000 +0200 +++ gcc/fortran/trans-decl.c 2010-07-23 11:27:32.000000000 +0200 @@ -759,16 +759,16 @@ gfc_build_qualified_array (tree decl, gf gtype = build_array_type (gtype, rtype); /* Ensure the bound variables aren't optimized out at -O0. For -O1 and above they often will be optimized out, but - can be tracked by VTA. Also clear the artificial - lbound.N or ubound.N DECL_NAME, so that it doesn't end up - in debug info. */ + can be tracked by VTA. Also set DECL_NAMELESS, so that + the artificial lbound.N or ubound.N DECL_NAME doesn't + end up in debug info. */ if (lbound && TREE_CODE (lbound) == VAR_DECL && DECL_ARTIFICIAL (lbound) && DECL_IGNORED_P (lbound)) { if (DECL_NAME (lbound) && strstr (IDENTIFIER_POINTER (DECL_NAME (lbound)), "lbound") != 0) - DECL_NAME (lbound) = NULL_TREE; + DECL_NAMELESS (lbound) = 1; DECL_IGNORED_P (lbound) = 0; } if (ubound && TREE_CODE (ubound) == VAR_DECL @@ -777,7 +777,7 @@ gfc_build_qualified_array (tree decl, gf if (DECL_NAME (ubound) && strstr (IDENTIFIER_POINTER (DECL_NAME (ubound)), "ubound") != 0) - DECL_NAME (ubound) = NULL_TREE; + DECL_NAMELESS (ubound) = 1; DECL_IGNORED_P (ubound) = 0; } } @@ -879,6 +879,7 @@ gfc_build_dummy_array_decl (gfc_symbol * VAR_DECL, get_identifier (name), type); DECL_ARTIFICIAL (decl) = 1; + DECL_NAMELESS (decl) = 1; TREE_PUBLIC (decl) = 0; TREE_STATIC (decl) = 0; DECL_EXTERNAL (decl) = 0;