summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-30 11:58:01 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-30 11:58:01 +0000
commit523c1122434af355049edacf489e8da82ee7709d (patch)
tree4ee7560469c1e50ca7f51f6e50bca995ec5871a0 /gcc/cgraph.c
parent311a2fe08784f5d009281ab401fe4f143d4c2825 (diff)
downloadgcc-523c1122434af355049edacf489e8da82ee7709d.tar.gz
* cgraph.c (cgraph_exapnd_queue): Rename to...
(cgraph_new_nodes): ... this one. (cgraph_state): New global variable. (cgraph_add_new_function): Work in more cases. * cgraph.h (cgraph_expand_queue): Rename to ... (cgraph_new_nodes): ... this one. (cgraph_state): New enum and static variable. (cgraph_add_new_function): Update prototype. (cgraph_process_new_functions): New. * omp-low.c (expand_omp_parallel): Update. * cgraphunit.c (initialize_inline_failed): Declare early. (cgraph_process_new_functions): New function. (cgraph_assemble_pending_functions): Use it. (cgraph_expand_all_functions): Use it. (cgraph_optimize): Use it; set cgraph_state. * passes.c (execute_one_pass, execute_ipa_pass_list): Process new functions git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120282 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c68
1 files changed, 54 insertions, 14 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index d35b4db5a56..21e821c2b4d 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -97,10 +97,10 @@ struct cgraph_node *cgraph_nodes;
/* Queue of cgraph nodes scheduled to be lowered. */
struct cgraph_node *cgraph_nodes_queue;
-/* Queue of cgraph nodes scheduled to be expanded. This is a
+/* Queue of cgraph nodes scheduled to be added into cgraph. This is a
secondary queue used during optimization to accommodate passes that
may generate new functions that need to be optimized and expanded. */
-struct cgraph_node *cgraph_expand_queue;
+struct cgraph_node *cgraph_new_nodes;
/* Number of nodes in existence. */
int cgraph_n_nodes;
@@ -111,6 +111,9 @@ int cgraph_max_uid;
/* Set when whole unit has been analyzed so we can access global info. */
bool cgraph_global_info_ready = false;
+/* What state callgraph is in right now. */
+enum cgraph_state cgraph_state = CGRAPH_STATE_CONSTRUCTION;
+
/* Set when the cgraph is fully build and the basic flags are computed. */
bool cgraph_function_flags_ready = false;
@@ -911,23 +914,60 @@ cgraph_function_body_availability (struct cgraph_node *node)
return avail;
}
-/* Add the function FNDECL to the call graph. FNDECL is assumed to be
- in low GIMPLE form and ready to be processed by cgraph_finalize_function.
+/* Add the function FNDECL to the call graph.
+ Unlike cgraph_finalize_function, this function is intended to be used
+ by middle end and allows insertion of new function at arbitrary point
+ of compilation. The function can be either in high, low or SSA form
+ GIMPLE.
- When operating in unit-at-a-time, a new callgraph node is added to
- CGRAPH_EXPAND_QUEUE, which is processed after all the original
- functions in the call graph .
+ The function is assumed to be reachable and have address taken (so no
+ API breaking optimizations are performed on it).
- When not in unit-at-a-time, the new callgraph node is added to
- CGRAPH_NODES_QUEUE for cgraph_assemble_pending_functions to
- process. */
+ Main work done by this function is to enqueue the function for later
+ processing to avoid need the passes to be re-entrant. */
void
-cgraph_add_new_function (tree fndecl)
+cgraph_add_new_function (tree fndecl, bool lowered)
{
- struct cgraph_node *n = cgraph_node (fndecl);
- n->next_needed = cgraph_expand_queue;
- cgraph_expand_queue = n;
+ struct cgraph_node *node;
+ switch (cgraph_state)
+ {
+ case CGRAPH_STATE_CONSTRUCTION:
+ /* Just enqueue function to be processed at nearest occurence. */
+ node = cgraph_node (fndecl);
+ node->next_needed = cgraph_new_nodes;
+ if (lowered)
+ node->lowered = true;
+ cgraph_new_nodes = node;
+ break;
+
+ case CGRAPH_STATE_IPA:
+ case CGRAPH_STATE_EXPANSION:
+ /* Bring the function into finalized state and enqueue for later
+ analyzing and compilation. */
+ node = cgraph_node (fndecl);
+ node->local.local = false;
+ node->local.finalized = true;
+ node->reachable = node->needed = true;
+ if (lowered)
+ node->lowered = true;
+ node->next_needed = cgraph_new_nodes;
+ cgraph_new_nodes = node;
+ break;
+
+ case CGRAPH_STATE_FINISHED:
+ /* At the very end of compilation we have to do all the work up
+ to expansion. */
+ push_cfun (DECL_STRUCT_FUNCTION (fndecl));
+ current_function_decl = fndecl;
+ tree_register_cfg_hooks ();
+ if (!lowered)
+ tree_lowering_passes (fndecl);
+ tree_rest_of_compilation (fndecl);
+ pop_cfun ();
+ current_function_decl = NULL;
+ break;
+ }
}
#include "gt-cgraph.h"