Hi!

As written in the PR, there are 3 bugs:
1) setting DECL_INITIAL on !TREE_STATIC span VAR_DECLs has no code
   generation effect, only confuses dwarf2out.c
2) the span VAR_DECLs weren't initialized
3) coalescing at -O0 wrongly looked at DECL_ARTIFICIAL, we want
   to look at DECL_IGNORED_P, as even some artificial vars are essential
   for debug info quality
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and
after a while for 4.6 too)?

2011-12-14  Jakub Jelinek  <ja...@redhat.com>

        PR debug/51517
        * trans-decl.c (gfc_get_symbol_decl): Don't set DECL_INITAL on span.
        (gfc_trans_deferred_vars): Instead add its runtime initialization
        here.
        * tree-ssa-coalesce.c (coalesce_ssa_name): For !optimize, test
        !DECL_IGNORED_P instead of !DECL_ARTIFICIAL.

--- gcc/fortran/trans-decl.c.jj 2011-12-11 22:02:37.000000000 +0100
+++ gcc/fortran/trans-decl.c    2011-12-14 16:07:54.934241029 +0100
@@ -1434,7 +1434,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
       gfc_finish_var_decl (span, sym);
       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;
@@ -3577,6 +3576,17 @@ gfc_trans_deferred_vars (gfc_symbol * pr
       if (sym->assoc)
        continue;
 
+      if (sym->attr.subref_array_pointer
+         && GFC_DECL_SPAN (sym->backend_decl)
+         && !TREE_STATIC (GFC_DECL_SPAN (sym->backend_decl)))
+       {
+         gfc_init_block (&tmpblock);
+         gfc_add_modify (&tmpblock, GFC_DECL_SPAN (sym->backend_decl),
+                         build_int_cst (gfc_array_index_type, 0));
+         gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock),
+                               NULL_TREE);
+       }
+
       if (sym->attr.dimension || sym->attr.codimension)
        {
           /* Assumed-size Cray pointees need to be treated as AS_EXPLICIT.  */
--- gcc/tree-ssa-coalesce.c.jj  2011-05-02 18:39:28.000000000 +0200
+++ gcc/tree-ssa-coalesce.c     2011-12-14 15:49:38.848584269 +0100
@@ -1,5 +1,5 @@
 /* Coalesce SSA_NAMES together for the out-of-ssa pass.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
    Contributed by Andrew MacLeod <amacl...@redhat.com>
 
@@ -1372,7 +1372,7 @@ coalesce_ssa_name (void)
 
          if (a
              && SSA_NAME_VAR (a)
-             && !DECL_ARTIFICIAL (SSA_NAME_VAR (a))
+             && !DECL_IGNORED_P (SSA_NAME_VAR (a))
              && (!has_zero_uses (a) || !SSA_NAME_IS_DEFAULT_DEF (a)))
            {
              tree *slot = (tree *) htab_find_slot (ssa_name_hash, a, INSERT);

        Jakub

Reply via email to