Commit 6b00c969 by Richard Henderson Committed by Richard Henderson

cgraphunit.c (cgraph_finalize_function): Add nested arg.

        * cgraphunit.c (cgraph_finalize_function): Add nested arg.
        Tweek tests for function already generated.
        (cgraph_expand_function): Don't double announce in !unit-at-a-time.
        * cgraph.h (cgraph_finalize_function): Update for extra arg.
        * c-decl.c (finish_function): Likewise.

        * semantics.c (expand_or_defer_fn): Update for new
        cgraph_finalize_function argument.

        * parse.y (source_end_java_method): Update for new
        cgraph_finalize_function argument.

From-SVN: r71298
parent dd5c7759
2003-09-11 Richard Henderson <rth@redhat.com>
* cgraphunit.c (cgraph_finalize_function): Add nested arg.
Tweek tests for function already generated.
(cgraph_expand_function): Don't double announce in !unit-at-a-time.
* cgraph.h (cgraph_finalize_function): Update for extra arg.
* c-decl.c (finish_function): Likewise.
2003-09-10 Joe Buck <jbuck@welsh-buck.org> 2003-09-10 Joe Buck <jbuck@welsh-buck.org>
* c-decl.c (poplevel): Eliminate use of |= in function_body assignment. * c-decl.c (poplevel): Eliminate use of |= in function_body assignment.
......
...@@ -6144,7 +6144,7 @@ finish_function () ...@@ -6144,7 +6144,7 @@ finish_function ()
/* ??? Objc emits functions after finalizing the compilation unit. /* ??? Objc emits functions after finalizing the compilation unit.
This should be cleaned up later and this conditional removed. */ This should be cleaned up later and this conditional removed. */
if (!cgraph_global_info_ready) if (!cgraph_global_info_ready)
cgraph_finalize_function (fndecl); cgraph_finalize_function (fndecl, false);
else else
c_expand_body (fndecl); c_expand_body (fndecl);
current_function_decl = NULL; current_function_decl = NULL;
......
...@@ -168,7 +168,7 @@ void cgraph_varpool_finalize_decl (tree); ...@@ -168,7 +168,7 @@ void cgraph_varpool_finalize_decl (tree);
bool cgraph_varpool_assemble_pending_decls (void); bool cgraph_varpool_assemble_pending_decls (void);
/* In cgraphunit.c */ /* In cgraphunit.c */
void cgraph_finalize_function (tree); void cgraph_finalize_function (tree, bool);
void cgraph_finalize_compilation_unit (void); void cgraph_finalize_compilation_unit (void);
void cgraph_create_edges (tree, tree); void cgraph_create_edges (tree, tree);
void cgraph_optimize (void); void cgraph_optimize (void);
......
...@@ -106,7 +106,7 @@ decide_is_function_needed (struct cgraph_node *node, tree decl) ...@@ -106,7 +106,7 @@ decide_is_function_needed (struct cgraph_node *node, tree decl)
/* "extern inline" functions are never output locally. */ /* "extern inline" functions are never output locally. */
if (DECL_EXTERNAL (decl)) if (DECL_EXTERNAL (decl))
return false; return false;
/* We want to emit COMDAT functions only when they turns out to be neccesary. */ /* We want to emit COMDAT functions only when absolutely neccesary. */
if (DECL_COMDAT (decl)) if (DECL_COMDAT (decl))
return false; return false;
if (!DECL_INLINE (decl) if (!DECL_INLINE (decl)
...@@ -142,34 +142,39 @@ cgraph_assemble_pending_functions (void) ...@@ -142,34 +142,39 @@ cgraph_assemble_pending_functions (void)
return output; return output;
} }
/* Analyze function once it is parsed. Set up the local information /* DECL has been parsed. Take it, queue it, compile it at the whim of the
available - create cgraph edges for function calls via BODY. */ logic in effect. If NESTED is true, then our caller cannot stand to have
the garbage collector run at the moment. We would need to either create
a new GC context, or just not compile right now. */
void void
cgraph_finalize_function (tree decl) cgraph_finalize_function (tree decl, bool nested)
{ {
struct cgraph_node *node = cgraph_node (decl); struct cgraph_node *node = cgraph_node (decl);
if (node->local.finalized) if (node->local.finalized)
{ {
/* As an GCC extension we allow redefinition of the function. The /* As an GCC extension we allow redefinition of the function. The
semantics when both copies of bodies differ is not well defined. We semantics when both copies of bodies differ is not well defined.
replace the old body with new body so in unit at a time mode we always We replace the old body with new body so in unit at a time mode
use new body, while in normal mode we may end up with old body inlined we always use new body, while in normal mode we may end up with
into some functions and new body expanded and inlined in others. old body inlined into some functions and new body expanded and
inlined in others.
??? It may make more sense to use one body for inlining and other body ??? It may make more sense to use one body for inlining and other
for expanding the function but this is dificult to do. */ body for expanding the function but this is dificult to do. */
/* Reset our datastructures so we can analyze the function body
again. */ if (TREE_ASM_WRITTEN (decl))
abort ();
/* Reset our datastructures so we can analyze the function again. */
memset (&node->local, 0, sizeof (node->local)); memset (&node->local, 0, sizeof (node->local));
memset (&node->global, 0, sizeof (node->global)); memset (&node->global, 0, sizeof (node->global));
memset (&node->rtl, 0, sizeof (node->rtl)); memset (&node->rtl, 0, sizeof (node->rtl));
node->analyzed = false; node->analyzed = false;
if (node->output)
abort ();
while (node->callees) while (node->callees)
cgraph_remove_call (node->decl, node->callees->callee->decl); cgraph_remove_call (node->decl, node->callees->callee->decl);
/* We may need to re-queue the node for assembling in case /* We may need to re-queue the node for assembling in case
we already proceeded it and ignored as not needed. */ we already proceeded it and ignored as not needed. */
if (node->reachable && !flag_unit_at_a_time) if (node->reachable && !flag_unit_at_a_time)
...@@ -183,6 +188,7 @@ cgraph_finalize_function (tree decl) ...@@ -183,6 +188,7 @@ cgraph_finalize_function (tree decl)
node->reachable = 0; node->reachable = 0;
} }
} }
notice_global_symbol (decl); notice_global_symbol (decl);
node->decl = decl; node->decl = decl;
node->local.finalized = true; node->local.finalized = true;
...@@ -195,13 +201,13 @@ cgraph_finalize_function (tree decl) ...@@ -195,13 +201,13 @@ cgraph_finalize_function (tree decl)
if (decide_is_function_needed (node, decl)) if (decide_is_function_needed (node, decl))
cgraph_mark_needed_node (node); cgraph_mark_needed_node (node);
/* If not unit at a time, go ahead and emit everything we've /* If not unit at a time, go ahead and emit everything we've found
found to be reachable at this time. Do this only at top-level. */ to be reachable at this time. */
if (!node->origin) if (!nested)
cgraph_assemble_pending_functions (); cgraph_assemble_pending_functions ();
/* If we've not yet emitted decl, tell the debug info about it. */ /* If we've not yet emitted decl, tell the debug info about it. */
if (flag_unit_at_a_time || !node->reachable) if (!TREE_ASM_WRITTEN (decl))
(*debug_hooks->deferred_inline_function) (decl); (*debug_hooks->deferred_inline_function) (decl);
} }
...@@ -465,7 +471,8 @@ cgraph_expand_function (struct cgraph_node *node) ...@@ -465,7 +471,8 @@ cgraph_expand_function (struct cgraph_node *node)
tree decl = node->decl; tree decl = node->decl;
struct cgraph_edge *e; struct cgraph_edge *e;
announce_function (decl); if (flag_unit_at_a_time)
announce_function (decl);
cgraph_optimize_function (node); cgraph_optimize_function (node);
......
2003-09-11 Richard Henderson <rth@redhat.com>
* semantics.c (expand_or_defer_fn): Update for new
cgraph_finalize_function argument.
2003-09-10 Richard Henderson <rth@redhat.com> 2003-09-10 Richard Henderson <rth@redhat.com>
* decl2.c (cxx_callgraph_analyze_expr): Mark argument unused. * decl2.c (cxx_callgraph_analyze_expr): Mark argument unused.
......
...@@ -2940,7 +2940,7 @@ expand_or_defer_fn (tree fn) ...@@ -2940,7 +2940,7 @@ expand_or_defer_fn (tree fn)
import_export_decl (fn); import_export_decl (fn);
/* Expand or defer, at the whim of the compilation unit manager. */ /* Expand or defer, at the whim of the compilation unit manager. */
cgraph_finalize_function (fn); cgraph_finalize_function (fn, function_depth > 1);
} }
/* Helper function for walk_tree, used by finish_function to override all /* Helper function for walk_tree, used by finish_function to override all
......
2003-09-11 Richard Henderson <rth@redhat.com>
* parse.y (source_end_java_method): Update for new
cgraph_finalize_function argument.
2003-09-09 Richard Henderson <rth@redhat.com> 2003-09-09 Richard Henderson <rth@redhat.com>
* parse.y (source_end_java_method): Update call to * parse.y (source_end_java_method): Update call to
......
...@@ -7474,7 +7474,7 @@ source_end_java_method (void) ...@@ -7474,7 +7474,7 @@ source_end_java_method (void)
/* In unit-at-a-time mode, don't expand the method yet. */ /* In unit-at-a-time mode, don't expand the method yet. */
if (DECL_SAVED_TREE (fndecl) && flag_unit_at_a_time) if (DECL_SAVED_TREE (fndecl) && flag_unit_at_a_time)
{ {
cgraph_finalize_function (fndecl); cgraph_finalize_function (fndecl, false);
current_function_decl = NULL_TREE; current_function_decl = NULL_TREE;
java_parser_context_restore_global (); java_parser_context_restore_global ();
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment