[PATCH] Improve VLAs in Fortran debuginfo even at -O1+

Jakub Jelinek jakub@redhat.com
Fri Apr 16 14:23:00 GMT 2010


On Wed, Apr 14, 2010 at 10:07:35PM +0200, Tobias Burnus wrote:
> Jakub Jelinek wrote:
> > One tiny issue left is (but that is for -O0 -g too) is that these
> > artificial vars still have names like ubound.0 and those names show up in
> > the debug info (the DIEs are DW_AT_artificial, but still).  I guess it would
> > make code less readable in the FE if we switched to some other names
> > (__ prefixed or starting with . or something similar);
> You mean for -fdump-tree-original? I don't think that having ".ubound.0"
> would be that much more unreadable; and, while having reasonable names
> helps, the front end already generates all the time new variables with
> helpful names such as D.1558 thus the additional dot before "ubound"
> wouldn't harm.
> Though, one could also think about a lang hook.

This patch just clears those artificial DECL_NAMEs if they could end up
in debug info.

Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?

2010-04-16  Jakub Jelinek  <jakub@redhat.com>

	* trans-decl.c (gfc_build_qualified_array): Ensure
	ubound.N and lbound.N artificial variable names don't appear
	in debug info.

--- gcc/fortran/trans-decl.c.jj	2010-04-14 19:40:49.000000000 +0200
+++ gcc/fortran/trans-decl.c	2010-04-16 11:00:58.000000000 +0200
@@ -771,19 +771,34 @@ gfc_build_qualified_array (tree decl, gf
 
       for (dim = sym->as->rank - 1; dim >= 0; dim--)
 	{
-	  rtype = build_range_type (gfc_array_index_type,
-				    GFC_TYPE_ARRAY_LBOUND (type, dim),
-				    GFC_TYPE_ARRAY_UBOUND (type, dim));
+	  tree lbound, ubound;
+	  lbound = GFC_TYPE_ARRAY_LBOUND (type, dim);
+	  ubound = GFC_TYPE_ARRAY_UBOUND (type, dim);
+	  rtype = build_range_type (gfc_array_index_type, lbound, ubound);
 	  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.  */
-	  if (GFC_TYPE_ARRAY_LBOUND (type, dim)
-	      && TREE_CODE (GFC_TYPE_ARRAY_LBOUND (type, dim)) == VAR_DECL)
-	    DECL_IGNORED_P (GFC_TYPE_ARRAY_LBOUND (type, dim)) = 0;
-	  if (GFC_TYPE_ARRAY_UBOUND (type, dim)
-	      && TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, dim)) == VAR_DECL)
-	    DECL_IGNORED_P (GFC_TYPE_ARRAY_UBOUND (type, dim)) = 0;
+	     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.  */
+	  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_IGNORED_P (lbound) = 0;
+	    }
+	  if (ubound && TREE_CODE (ubound) == VAR_DECL
+	      && DECL_ARTIFICIAL (ubound) && DECL_IGNORED_P (ubound))
+	    {
+	      if (DECL_NAME (ubound)
+		  && strstr (IDENTIFIER_POINTER (DECL_NAME (ubound)),
+			     "ubound") != 0)
+		DECL_NAME (ubound) = NULL_TREE;
+	      DECL_IGNORED_P (ubound) = 0;
+	    }
 	}
       TYPE_NAME (type) = type_decl = build_decl (input_location,
 						 TYPE_DECL, NULL, gtype);


	Jakub



More information about the Gcc-patches mailing list