diff mbox

Fix debug info with subref array pointers at -O0 (Fortran FE + middle-end coalescing fix; PR debug/51517)

Message ID 20111214174908.GI1957@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 14, 2011, 5:49 p.m. UTC
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  <jakub@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.


	Jakub

Comments

Tobias Burnus Dec. 15, 2011, 8:22 a.m. UTC | #1
Hi Jakub,

On 12/14/2011 06:49 PM, Jakub Jelinek wrote:
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and
> after a while for 4.6 too)?

The Fortran part of the patch is OK. Thanks for the patch!

Tobias

> 2011-12-14  Jakub Jelinek<jakub@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.
Richard Biener Dec. 15, 2011, 9:08 a.m. UTC | #2
On Thu, Dec 15, 2011 at 9:22 AM, Tobias Burnus <burnus@net-b.de> wrote:
> Hi Jakub,
>
>
> On 12/14/2011 06:49 PM, Jakub Jelinek wrote:
>>
>> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk (and
>> after a while for 4.6 too)?
>
>
> The Fortran part of the patch is OK. Thanks for the patch!

And the middle-end part is obvious.

Thanks,
Richard.

> Tobias
>
>
>> 2011-12-14  Jakub Jelinek<jakub@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.
diff mbox

Patch

--- 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 <amacleod@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);