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]

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


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.

I'm checking this in only in the vta branch, but it appears to me that
it's desirable on its own, no?

for  gcc/ChangeLog.vta
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	2007-11-23 18:05:54.000000000 -0200
+++ gcc/tree-nested.c	2007-12-27 06:22:05.000000000 -0200
@@ -1743,10 +1743,25 @@ 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, DECL_SAVED_TREE (context), true);
     }
 
   /* If any parameters were referenced non-locally, then we need to 
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
FSF Latin America Board Member         http://www.fsfla.org/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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