This is the mail archive of the
mailing list for the GCC project.
[incremental] Patch: FYI: nested functions -vs- delayed gimplification
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 Dec 2007 15:24:17 -0700
- Subject: [incremental] Patch: FYI: nested functions -vs- delayed gimplification
- Reply-to: Tom Tromey <tromey at redhat dot com>
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.
2007-12-13 Tom Tromey <email@example.com>
* tree-nested.c (gimplify_all_functions): New function.
(lower_nested_functions): Call it.
* cgraphunit.c (cgraph_lower_function): Call
(cgraph_finalize_function): ... not here.
(cgraph_analyze_function): Restore current_function_decl.
--- cgraphunit.c (revision 130053)
+++ cgraphunit.c (working copy)
@@ -527,6 +527,11 @@
+ if (node->nested)
+ lower_nested_functions (node->decl);
+ gcc_assert (!node->nested);
node->lowered = true;
@@ -550,9 +555,6 @@
node->local.finalized = true;
node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
- 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 @@
cgraph_analyze_function (struct cgraph_node *node)
+ tree save = current_function_decl;
tree decl = node->decl;
current_function_decl = decl;
@@ -795,7 +798,7 @@
- current_function_decl = NULL;
+ current_function_decl = save;
/* Look for externally_visible and used attributes and mark cgraph nodes
--- tree-nested.c (revision 130053)
+++ tree-nested.c (working copy)
@@ -1912,6 +1912,16 @@
+/* Gimplify a function and all its nested functions. */
+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 @@
+ gimplify_all_functions (cgn);
root = create_nesting_tree (cgn);
walk_all_functions (convert_nonlocal_reference, root);