public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [incremental] Patch: FYI: nested functions -vs- delayed gimplification
@ 2007-12-13 22:53 Tom Tromey
  2007-12-14 13:32 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2007-12-13 22:53 UTC (permalink / raw)
  To: Gcc Patch List

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [incremental] Patch: FYI: nested functions -vs- delayed gimplification
  2007-12-13 22:53 [incremental] Patch: FYI: nested functions -vs- delayed gimplification Tom Tromey
@ 2007-12-14 13:32 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2007-12-14 13:32 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Gcc Patch List

On 12/13/07 5:24 PM, Tom Tromey wrote:

> 	* 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.

This would be a nice stage1 patch for 4.4, as well.


Diego.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-14 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-13 22:53 [incremental] Patch: FYI: nested functions -vs- delayed gimplification Tom Tromey
2007-12-14 13:32 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).