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]

[incremental] Patch: FYI: nested functions -vs- delayed gimplification


I'm checking this in on the incremental-compiler branch.

My naive delayed gimplification changes broke nested functions.
This patch fixes them up by ensuring that nested functions are
gimplified at the right time.

This work pointed out to me that the incremental compiler doesn't
handle reuse of nested functions.  I'm not sure what I'm going to do
about this yet, but the basic idea has to be to keep them around and
associate them with their outer functions somehow.

This fixes a number of test suite failures.

Tom

ChangeLog:
2007-12-13  Tom Tromey  <tromey@redhat.com>

	* tree-nested.c (gimplify_all_functions): New function.
	(lower_nested_functions): Call it.
	* cgraphunit.c (cgraph_lower_function): Call
	lower_nested_functions here...
	(cgraph_finalize_function): ... not here.
	(cgraph_analyze_function): Restore current_function_decl.

Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 130053)
+++ cgraphunit.c	(working copy)
@@ -527,6 +527,11 @@
 {
   if (node->lowered)
     return;
+
+  if (node->nested)
+    lower_nested_functions (node->decl);
+  gcc_assert (!node->nested);
+
   tree_lowering_passes (node->decl);
   node->lowered = true;
 }
@@ -550,9 +555,6 @@
   node->local.finalized = true;
   node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
   record_cdtor_fn (node->decl);
-  if (node->nested)
-    lower_nested_functions (decl);
-  gcc_assert (!node->nested);
 
   /* If not unit at a time, then we need to create the call graph
      now, so that called functions can be queued and emitted now.  */
@@ -777,6 +779,7 @@
 void
 cgraph_analyze_function (struct cgraph_node *node)
 {
+  tree save = current_function_decl;
   tree decl = node->decl;
 
   current_function_decl = decl;
@@ -795,7 +798,7 @@
     }
 
   pop_cfun ();
-  current_function_decl = NULL;
+  current_function_decl = save;
 }
 
 /* Look for externally_visible and used attributes and mark cgraph nodes
Index: tree-nested.c
===================================================================
--- tree-nested.c	(revision 130053)
+++ tree-nested.c	(working copy)
@@ -1912,6 +1912,16 @@
   while (root);
 }
 
+/* Gimplify a function and all its nested functions.  */
+static void
+gimplify_all_functions (struct cgraph_node *root)
+{
+  struct cgraph_node *iter;
+  gimplify_function_tree (root->decl);
+  for (iter = root->nested; iter; iter = iter->next_nested)
+    gimplify_all_functions (iter);
+}
+
 /* Main entry point for this pass.  Process FNDECL and all of its nested
    subroutines and turn them into something less tightly bound.  */
 
@@ -1926,6 +1936,8 @@
   if (!cgn->nested)
     return;
 
+  gimplify_all_functions (cgn);
+
   bitmap_obstack_initialize (&nesting_info_bitmap_obstack);
   root = create_nesting_tree (cgn);
   walk_all_functions (convert_nonlocal_reference, root);


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