+2014-04-28 Richard Biener <rguenther@suse.de>
+
+ * tree-pass.h (execute_pass_list): Adjust prototype.
+ * passes.c (pass_manager::execute_early_local_passes):
+ Adjust.
+ (do_per_function): Change callback signature, push all actual
+ work to the callbals.
+ (do_per_function_toporder): Likewise.
+ (execute_function_dump): Adjust.
+ (execute_function_todo): Likewise.
+ (clear_last_verified): Likewise.
+ (verify_curr_properties): Likewise.
+ (update_properties_after_pass): Likewise.
+ (execute_pass_list_1): Split out from ...
+ (execute_pass_list): ... here. Adjust.
+ (execute_ipa_pass_list): Likewise.
+ * cgraphunit.c (cgraph_add_new_function): Adjust.
+ (analyze_function): Likewise.
+ (expand_function): Likewise.
+ * cgraph.c (release_function_body): Free dominance info
+ here instead of asserting it was magically freed elsewhere.
+
2014-04-28 Eric Botcazou <ebotcazou@adacore.com>
* configure.ac: Tweak GAS check for LEON instructions on SPARC.
push_cfun (DECL_STRUCT_FUNCTION (fndecl));
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
- execute_pass_list (passes->all_lowering_passes);
+ execute_pass_list (cfun, passes->all_lowering_passes);
passes->execute_early_local_passes ();
bitmap_obstack_release (NULL);
pop_cfun ();
gimple_register_cfg_hooks ();
bitmap_obstack_initialize (NULL);
- execute_pass_list (g->get_passes ()->all_lowering_passes);
+ execute_pass_list (cfun, g->get_passes ()->all_lowering_passes);
free_dominance_info (CDI_POST_DOMINATORS);
free_dominance_info (CDI_DOMINATORS);
compact_blocks ();
/* Signal the start of passes. */
invoke_plugin_callbacks (PLUGIN_ALL_PASSES_START, NULL);
- execute_pass_list (g->get_passes ()->all_passes);
+ execute_pass_list (cfun, g->get_passes ()->all_passes);
/* Signal the end of passes. */
invoke_plugin_callbacks (PLUGIN_ALL_PASSES_END, NULL);
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
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);
}
}
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);
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);
/* 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);
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)
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 ();
}
}
/* 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)
{
/* 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
verify_rtl_sharing ();
#endif
- cfun->last_verified = flags & TODO_verify_all;
+ fn->last_verified = flags & TODO_verify_all;
+
+ pop_cfun ();
}
/* Perform all TODO actions. */
/* 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
#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
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. */
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)
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);
}