This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't emit certain artificial names into DW_AT_name in debug info


On Thu, Jul 22, 2010 at 12:19:35PM -0700, Roland McGrath wrote:
> Similarly: 
> 
>    <formal_parameter name=".omp_data_i" type="#ref1" artificial=1 location={locexpr}/>
> 
> 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:
> 
>   <structure_type ref="ref4" name=".omp_data_s.10" byte_size=0x8>
> 
> 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  <jakub@redhat.com>

	* 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.

--- 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 "<anonymous>" 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;


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]