This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [trunk<-vta] Re: [vta, trunk?] declare frame decls for nested functions in the binding blocks


Alexandre Oliva <aoliva@redhat.com> writes:

> On Jan  3, 2008, Alexandre Oliva <aoliva@redhat.com> wrote:
>
>> Declarations with DECL_VALUE_EXPR in nested functions may refer to
>> frame declarations that end up optimized away, but debug information
>> for them should still reference the optimized-away frame decl
>> variable.  We even have code to keep variables reference in
>> DECL_VALUE_EXPR around, but if we never add such variables to the
>> binding blocks, this doesn't quite work so well.
>
>> The problem only became apparent when debug stmts that claimed to set
>> these no-longer-existent variables caused Bad Things (TM) to happen.
>
>> This patch arranges for the frame decl variable to be added to the
>> binding block as well, such that it is kept around as needed.
>
> Ok for trunk?
>
> for  gcc/ChangeLog
>>From  Alexandre Oliva  <aoliva@redhat.com>
>
> 	* tree-nested.c (finalize_nesting_tree_1): Declare the
> 	frame_decl in the binding tree.

Is there any way to write a test case for this?

Ian


> Index: gcc/tree-nested.c
> ===================================================================
> --- gcc/tree-nested.c.orig	2009-05-28 05:33:39.000000000 -0300
> +++ gcc/tree-nested.c	2009-05-29 04:15:56.000000000 -0300
> @@ -1,5 +1,5 @@
>  /* Nested function decomposition for GIMPLE.
> -   Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
> +   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
>  
>     This file is part of GCC.
>  
> @@ -2179,10 +2179,26 @@ finalize_nesting_tree_1 (struct nesting_
>        /* In some cases the frame type will trigger the -Wpadded warning.
>  	 This is not helpful; suppress it. */
>        int save_warn_padded = warn_padded;
> +      tree *adjust;
> +
>        warn_padded = 0;
>        layout_type (root->frame_type);
>        warn_padded = save_warn_padded;
>        layout_decl (root->frame_decl, 0);
> +
> +      /* Remove root->frame_decl from root->new_local_var_chain, such
> +	 that we can declare it also in the lexical blocks, which
> +	 helps ensure virtual regs that end up appearing in its RTL
> +	 expression get substituted in instantiate_virtual_regs().  */
> +      for (adjust = &root->new_local_var_chain;
> +	   *adjust != root->frame_decl;
> +	   adjust = &TREE_CHAIN (*adjust))
> +	gcc_assert (TREE_CHAIN (*adjust));
> +      *adjust = TREE_CHAIN (*adjust);
> +
> +      TREE_CHAIN (root->frame_decl) = NULL_TREE;
> +      declare_vars (root->frame_decl,
> +		    gimple_seq_first_stmt (gimple_body (context)), true);
>      }
>  
>    /* If any parameters were referenced non-locally, then we need to 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]