[PATCH] Fix debuginfo for Fortran subref array pointers

Jakub Jelinek jakub@redhat.com
Fri Aug 29 09:43:00 GMT 2008


Hi!

This patch fixes debuginfo for Fortran subref array pointers (stride
has to be multiplied by the content of its span variable instead of
element size) and also fixes a couple of small issues (e.g.
TREE_STATIC has been always set on the span variable, which is undesirable
at least for OpenMP or recursive procedures).  That said, subref array
pointers don't appear to work for dummy arguments (f951 ICEs if a
dummy array pointer is later pointed to is_subref_array) and I don't see how
it can possibly work with array pointers in modules, or in common blocks,
or threadprivate.

Is there a plan to do it right with the next major ABI change (i.e.
represent strides in bytes rather than elements and kill this span stuff)?
I think there are comments about intending to go from 7 to 15 maximum rank
and that will need ABI changes to the array descriptors anyway.

2008-08-28  Jakub Jelinek  <jakub@redhat.com>

	* dwarf2out.c (descr_info_loc): Handle VAR_DECL.

	* trans.h (struct lang_type): Add span.
	(GFC_TYPE_ARRAY_SPAN): Define.
	* trans-decl.c (gfc_get_symbol_decl): For subref array pointers,
	copy TREE_STATIC from decl to span instead of setting it
	unconditionally, set DECL_ARTIFICIAL, fix type of initializer
	and set GFC_TYPE_ARRAY_SPAN on decl's type.
	* trans-types.c (gfc_get_array_descr_info): If
	GFC_TYPE_ARRAY_SPAN is non-NULL, use it as element size.

--- gcc/fortran/trans.h.jj	2008-08-26 21:43:04.000000000 +0200
+++ gcc/fortran/trans.h	2008-08-28 09:58:01.000000000 +0200
@@ -615,6 +615,7 @@ struct lang_type		GTY(())
   tree offset;
   tree dtype;
   tree dataptr_type;
+  tree span;
 };
 
 struct lang_decl		GTY(())
@@ -667,6 +668,7 @@ struct lang_decl		GTY(())
 #define GFC_TYPE_ARRAY_DTYPE(node) (TYPE_LANG_SPECIFIC(node)->dtype)
 #define GFC_TYPE_ARRAY_DATAPTR_TYPE(node) \
   (TYPE_LANG_SPECIFIC(node)->dataptr_type)
+#define GFC_TYPE_ARRAY_SPAN(node) (TYPE_LANG_SPECIFIC(node)->span)
 
 /* Build an expression with void type.  */
 #define build1_v(code, arg) fold_build1(code, void_type_node, arg)
--- gcc/fortran/trans-decl.c.jj	2008-08-26 22:54:24.000000000 +0200
+++ gcc/fortran/trans-decl.c	2008-08-28 10:54:28.000000000 +0200
@@ -1105,10 +1105,12 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       span = build_decl (VAR_DECL, create_tmp_var_name ("span"),
 			 gfc_array_index_type);
       gfc_finish_var_decl (span, sym);
-      TREE_STATIC (span) = 1;
-      DECL_INITIAL (span) = build_int_cst (NULL_TREE, 0);
+      TREE_STATIC (span) = TREE_STATIC (decl);
+      DECL_ARTIFICIAL (span) = 1;
+      DECL_INITIAL (span) = build_int_cst (gfc_array_index_type, 0);
 
       GFC_DECL_SPAN (decl) = span;
+      GFC_TYPE_ARRAY_SPAN (TREE_TYPE (decl)) = span;
     }
 
   sym->backend_decl = decl;
--- gcc/fortran/trans-types.c.jj	2008-08-26 21:43:04.000000000 +0200
+++ gcc/fortran/trans-types.c	2008-08-28 10:23:39.000000000 +0200
@@ -2289,7 +2289,10 @@ gfc_get_array_descr_info (const_tree typ
   else
     info->base_decl = base_decl = build_decl (VAR_DECL, NULL_TREE, ptype);
 
-  elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype));
+  if (GFC_TYPE_ARRAY_SPAN (type))
+    elem_size = GFC_TYPE_ARRAY_SPAN (type);
+  else
+    elem_size = fold_convert (gfc_array_index_type, TYPE_SIZE_UNIT (etype));
   field = TYPE_FIELDS (TYPE_MAIN_VARIANT (type));
   data_off = byte_position (field);
   field = TREE_CHAIN (field);
--- gcc/dwarf2out.c.jj	2008-08-26 21:43:42.000000000 +0200
+++ gcc/dwarf2out.c	2008-08-28 10:35:38.000000000 +0200
@@ -12853,6 +12853,8 @@ descr_info_loc (tree val, tree base_decl
     {
     CASE_CONVERT:
       return descr_info_loc (TREE_OPERAND (val, 0), base_decl);
+    case VAR_DECL:
+      return loc_descriptor_from_tree_1 (val, 0);
     case INTEGER_CST:
       if (host_integerp (val, 0))
 	return int_loc_descriptor (tree_low_cst (val, 0));

	Jakub



More information about the Gcc-patches mailing list