This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[trunk<-vta] Re: [vta, trunk?] declare frame decls for nested functions in the binding blocks
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 01 Jun 2009 04:52:38 -0300
- Subject: [trunk<-vta] Re: [vta, trunk?] declare frame decls for nested functions in the binding blocks
- References: <orbq83jr8l.fsf@oliva.athome.lsd.ic.unicamp.br>
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.
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
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
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