aboutsummaryrefslogtreecommitdiff
path: root/gcc/passes.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/passes.c')
-rw-r--r--gcc/passes.c99
1 files changed, 53 insertions, 46 deletions
diff --git a/gcc/passes.c b/gcc/passes.c
index fb60fc8..c0a76d6 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -132,7 +132,7 @@ opt_pass::opt_pass (const pass_data &data, context *ctxt)
void
pass_manager::execute_early_local_passes ()
{
- execute_pass_list (pass_early_local_passes_1->sub);
+ execute_pass_list (cfun, pass_early_local_passes_1->sub);
}
unsigned int
@@ -1498,27 +1498,17 @@ pass_manager::pass_manager (context *ctxt)
call CALLBACK on the current function. */
static void
-do_per_function (void (*callback) (void *data), void *data)
+do_per_function (void (*callback) (function *, void *data), void *data)
{
if (current_function_decl)
- callback (data);
+ callback (cfun, data);
else
{
struct cgraph_node *node;
FOR_EACH_DEFINED_FUNCTION (node)
if (node->analyzed && gimple_has_body_p (node->decl)
&& (!node->clone_of || node->decl != node->clone_of->decl))
- {
- push_cfun (DECL_STRUCT_FUNCTION (node->decl));
- callback (data);
- if (!flag_wpa)
- {
- free_dominance_info (CDI_DOMINATORS);
- free_dominance_info (CDI_POST_DOMINATORS);
- }
- pop_cfun ();
- ggc_collect ();
- }
+ callback (DECL_STRUCT_FUNCTION (node->decl), data);
}
}
@@ -1533,12 +1523,12 @@ static GTY ((length ("nnodes"))) cgraph_node_ptr *order;
call CALLBACK on the current function.
This function is global so that plugins can use it. */
void
-do_per_function_toporder (void (*callback) (void *data), void *data)
+do_per_function_toporder (void (*callback) (function *, void *data), void *data)
{
int i;
if (current_function_decl)
- callback (data);
+ callback (cfun, data);
else
{
gcc_assert (!order);
@@ -1554,15 +1544,7 @@ do_per_function_toporder (void (*callback) (void *data), void *data)
order[i] = NULL;
node->process = 0;
if (cgraph_function_with_gimple_body_p (node))
- {
- cgraph_get_body (node);
- push_cfun (DECL_STRUCT_FUNCTION (node->decl));
- callback (data);
- free_dominance_info (CDI_DOMINATORS);
- free_dominance_info (CDI_POST_DOMINATORS);
- pop_cfun ();
- ggc_collect ();
- }
+ callback (DECL_STRUCT_FUNCTION (node->decl), data);
}
}
ggc_free (order);
@@ -1573,14 +1555,16 @@ do_per_function_toporder (void (*callback) (void *data), void *data)
/* Helper function to perform function body dump. */
static void
-execute_function_dump (void *data)
+execute_function_dump (function *fn, void *data)
{
opt_pass *pass = (opt_pass *)data;
- if (dump_file && current_function_decl)
+ if (dump_file)
{
- if (cfun->curr_properties & PROP_trees)
- dump_function_to_file (current_function_decl, dump_file, dump_flags);
+ push_cfun (fn);
+
+ if (fn->curr_properties & PROP_trees)
+ dump_function_to_file (fn->decl, dump_file, dump_flags);
else
print_rtl_with_bb (dump_file, get_insns (), dump_flags);
@@ -1588,7 +1572,7 @@ execute_function_dump (void *data)
close the file before aborting. */
fflush (dump_file);
- if ((cfun->curr_properties & PROP_cfg)
+ if ((fn->curr_properties & PROP_cfg)
&& (dump_flags & TDF_GRAPH))
{
if (!pass->graph_dump_initialized)
@@ -1596,8 +1580,10 @@ execute_function_dump (void *data)
clean_graph_dump_file (dump_file_name);
pass->graph_dump_initialized = true;
}
- print_graph_cfg (dump_file_name, cfun);
+ print_graph_cfg (dump_file_name, fn);
}
+
+ pop_cfun ();
}
}
@@ -1728,13 +1714,15 @@ pass_manager::dump_profile_report () const
/* Perform all TODO actions that ought to be done on each function. */
static void
-execute_function_todo (void *data)
+execute_function_todo (function *fn, void *data)
{
unsigned int flags = (size_t)data;
- flags &= ~cfun->last_verified;
+ flags &= ~fn->last_verified;
if (!flags)
return;
+ push_cfun (fn);
+
/* Always cleanup the CFG before trying to update SSA. */
if (flags & TODO_cleanup_cfg)
{
@@ -1774,7 +1762,10 @@ execute_function_todo (void *data)
/* If we've seen errors do not bother running any verifiers. */
if (seen_error ())
- return;
+ {
+ pop_cfun ();
+ return;
+ }
#if defined ENABLE_CHECKING
if (flags & TODO_verify_ssa
@@ -1793,7 +1784,9 @@ execute_function_todo (void *data)
verify_rtl_sharing ();
#endif
- cfun->last_verified = flags & TODO_verify_all;
+ fn->last_verified = flags & TODO_verify_all;
+
+ pop_cfun ();
}
/* Perform all TODO actions. */
@@ -1855,9 +1848,9 @@ verify_interpass_invariants (void)
/* Clear the last verified flag. */
static void
-clear_last_verified (void *data ATTRIBUTE_UNUSED)
+clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
{
- cfun->last_verified = 0;
+ fn->last_verified = 0;
}
/* Helper function. Verify that the properties has been turn into the
@@ -1865,10 +1858,10 @@ clear_last_verified (void *data ATTRIBUTE_UNUSED)
#ifdef ENABLE_CHECKING
static void
-verify_curr_properties (void *data)
+verify_curr_properties (function *fn, void *data)
{
unsigned int props = (size_t)data;
- gcc_assert ((cfun->curr_properties & props) == props);
+ gcc_assert ((fn->curr_properties & props) == props);
}
#endif
@@ -1927,11 +1920,11 @@ pass_fini_dump_file (opt_pass *pass)
properties. */
static void
-update_properties_after_pass (void *data)
+update_properties_after_pass (function *fn, void *data)
{
opt_pass *pass = (opt_pass *) data;
- cfun->curr_properties = (cfun->curr_properties | pass->properties_provided)
- & ~pass->properties_destroyed;
+ fn->curr_properties = (fn->curr_properties | pass->properties_provided)
+ & ~pass->properties_destroyed;
}
/* Execute summary generation for all of the passes in IPA_PASS. */
@@ -2206,20 +2199,33 @@ execute_one_pass (opt_pass *pass)
return true;
}
-void
-execute_pass_list (opt_pass *pass)
+static void
+execute_pass_list_1 (opt_pass *pass)
{
do
{
gcc_assert (pass->type == GIMPLE_PASS
|| pass->type == RTL_PASS);
if (execute_one_pass (pass) && pass->sub)
- execute_pass_list (pass->sub);
+ execute_pass_list_1 (pass->sub);
pass = pass->next;
}
while (pass);
}
+void
+execute_pass_list (function *fn, opt_pass *pass)
+{
+ push_cfun (fn);
+ execute_pass_list_1 (pass);
+ if (fn->cfg)
+ {
+ free_dominance_info (CDI_DOMINATORS);
+ free_dominance_info (CDI_POST_DOMINATORS);
+ }
+ pop_cfun ();
+}
+
/* Write out all LTO data. */
static void
write_lto (void)
@@ -2543,7 +2549,8 @@ execute_ipa_pass_list (opt_pass *pass)
if (pass->sub->type == GIMPLE_PASS)
{
invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_START, NULL);
- do_per_function_toporder ((void (*)(void *))execute_pass_list,
+ do_per_function_toporder ((void (*)(function *, void *))
+ execute_pass_list,
pass->sub);
invoke_plugin_callbacks (PLUGIN_EARLY_GIMPLE_PASSES_END, NULL);
}