This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[vta, trunk?, fortran]
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Tue, 25 Nov 2008 03:37:35 -0200
- Subject: [vta, trunk?, fortran]
This patch fixes 204 -fcompare-debug failures in GCC fortran
(including libgomp) testsuites.
It fixes two separate issues, that each cause divergence in decl uids,
which in turn lead to optimization differences in compilations with
and without -g.
1. we didn't generate range types for multidimensional arrays when not
generating debug info
2. we only generated base decls for array descriptors when emitting
debug info
I acknowledge these changes are somewhat wasteful, especially the
second part, that's most certainly too conservative, but I figured I'm
not sufficiently familiar with this front-end to figure out a better
way to do it.
Suggestions?
I'm installing this in the VTA branch.
Is this appropriate for the trunk?
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* fortran/trans-decl.c (gfc_build_qualified_array): Don't skip
generation of range types.
* fortran/trans.h (struct lang_type): Add base_decls.
(GFC_TYPE_ARRAY_BASE_DECL): New.
* fortran/trans-types.c (gfc_get_array_type_bounds): Initialize
base decls proactively and excessively.
(gfc_get_array_descr_info): Use existing base decls if available.
Index: gcc/fortran/trans-decl.c
===================================================================
--- gcc/fortran/trans-decl.c.orig 2008-10-10 09:30:58.000000000 -0300
+++ gcc/fortran/trans-decl.c 2008-11-21 17:28:28.000000000 -0200
@@ -704,9 +704,6 @@ gfc_build_qualified_array (tree decl, gf
layout_type (type);
}
- if (write_symbols == NO_DEBUG)
- return;
-
if (TYPE_NAME (type) != NULL_TREE
&& GFC_TYPE_ARRAY_UBOUND (type, sym->as->rank - 1) != NULL_TREE
&& TREE_CODE (GFC_TYPE_ARRAY_UBOUND (type, sym->as->rank - 1)) == VAR_DECL)
Index: gcc/fortran/trans-types.c
===================================================================
--- gcc/fortran/trans-types.c.orig 2008-10-10 09:30:58.000000000 -0300
+++ gcc/fortran/trans-types.c 2008-11-21 18:46:10.000000000 -0200
@@ -1599,6 +1599,16 @@ gfc_get_array_type_bounds (tree etype, i
arraytype = build_pointer_type (arraytype);
GFC_TYPE_ARRAY_DATAPTR_TYPE (fat_type) = arraytype;
+ /* This will generate the base declarations we need to emit debug
+ information for this type. FIXME: there must be a better way to
+ avoid divergence between compilations with and without debug
+ information. */
+ {
+ struct array_descr_info info;
+ gfc_get_array_descr_info (fat_type, &info);
+ gfc_get_array_descr_info (build_pointer_type (fat_type), &info);
+ }
+
return fat_type;
}
@@ -2290,14 +2300,16 @@ gfc_get_array_descr_info (const_tree typ
info->ndimensions = rank;
info->element_type = etype;
ptype = build_pointer_type (gfc_array_index_type);
- if (indirect)
+ base_decl = GFC_TYPE_ARRAY_BASE_DECL (type, indirect);
+ if (!base_decl)
{
- info->base_decl = build_decl (VAR_DECL, NULL_TREE,
- build_pointer_type (ptype));
- base_decl = build1 (INDIRECT_REF, ptype, info->base_decl);
+ base_decl = build_decl (VAR_DECL, NULL_TREE,
+ indirect ? build_pointer_type (ptype) : ptype);
+ GFC_TYPE_ARRAY_BASE_DECL (type, indirect) = base_decl;
}
- else
- info->base_decl = base_decl = build_decl (VAR_DECL, NULL_TREE, ptype);
+ info->base_decl = base_decl;
+ if (indirect)
+ base_decl = build1 (INDIRECT_REF, ptype, base_decl);
if (GFC_TYPE_ARRAY_SPAN (type))
elem_size = GFC_TYPE_ARRAY_SPAN (type);
Index: gcc/fortran/trans.h
===================================================================
--- gcc/fortran/trans.h.orig 2008-10-10 09:30:58.000000000 -0300
+++ gcc/fortran/trans.h 2008-11-21 18:34:17.000000000 -0200
@@ -620,6 +620,7 @@ struct lang_type GTY(())
tree dtype;
tree dataptr_type;
tree span;
+ tree base_decl[2];
};
struct lang_decl GTY(())
@@ -673,6 +674,8 @@ struct lang_decl GTY(())
#define GFC_TYPE_ARRAY_DATAPTR_TYPE(node) \
(TYPE_LANG_SPECIFIC(node)->dataptr_type)
#define GFC_TYPE_ARRAY_SPAN(node) (TYPE_LANG_SPECIFIC(node)->span)
+#define GFC_TYPE_ARRAY_BASE_DECL(node, internal) \
+ (TYPE_LANG_SPECIFIC(node)->base_decl[(internal)])
/* Build an expression with void type. */
#define build1_v(code, arg) fold_build1(code, void_type_node, arg)
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer