aboutsummaryrefslogtreecommitdiff
path: root/gcc/passes.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2015-11-04 17:50:45 +0100
committerMartin Liska <marxin@gcc.gnu.org>2015-11-04 16:50:45 +0000
commitbe373510f80fc6fc1e7b227056a69b703ce1c7a4 (patch)
tree316a2296cdfe0b08198dd411e536b7787022ff04 /gcc/passes.c
parenta6c764d02ec7716720ceac34b667cda3741c5c42 (diff)
downloadgcc-be373510f80fc6fc1e7b227056a69b703ce1c7a4.zip
gcc-be373510f80fc6fc1e7b227056a69b703ce1c7a4.tar.gz
gcc-be373510f80fc6fc1e7b227056a69b703ce1c7a4.tar.bz2
Pass manager: add support for termination of pass list
* cgraphunit.c (cgraph_node::expand_thunk): Call allocate_struct_function before init_function_start. (cgraph_node::expand): Use push_cfun and pop_cfun. * config/i386/i386.c (ix86_code_end): Call allocate_struct_function before init_function_start. * config/rs6000/rs6000.c (rs6000_code_end): Likewise. * function.c (init_function_start): Move preamble to all callers. * passes.c (do_per_function_toporder): Use push_cfun and pop_cfun. (execute_one_pass): Handle newly added TODO_discard_function. (execute_pass_list_1): Terminate if cfun equals to NULL. (execute_pass_list): Do not push and pop cfun, expect that cfun is set. * tree-pass.h (TODO_discard_function): Define. From-SVN: r229764
Diffstat (limited to 'gcc/passes.c')
-rw-r--r--gcc/passes.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/gcc/passes.c b/gcc/passes.c
index f87dcf4..7a10cb6 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1706,7 +1706,12 @@ do_per_function_toporder (void (*callback) (function *, void *data), void *data)
order[i] = NULL;
node->process = 0;
if (node->has_gimple_body_p ())
- callback (DECL_STRUCT_FUNCTION (node->decl), data);
+ {
+ struct function *fn = DECL_STRUCT_FUNCTION (node->decl);
+ push_cfun (fn);
+ callback (fn, data);
+ pop_cfun ();
+ }
}
symtab->remove_cgraph_removal_hook (hook);
}
@@ -2347,6 +2352,23 @@ execute_one_pass (opt_pass *pass)
current_pass = NULL;
+ if (todo_after & TODO_discard_function)
+ {
+ gcc_assert (cfun);
+ /* As cgraph_node::release_body expects release dominators info,
+ we have to release it. */
+ if (dom_info_available_p (CDI_DOMINATORS))
+ free_dominance_info (CDI_DOMINATORS);
+
+ if (dom_info_available_p (CDI_POST_DOMINATORS))
+ free_dominance_info (CDI_POST_DOMINATORS);
+
+ tree fn = cfun->decl;
+ pop_cfun ();
+ gcc_assert (!cfun);
+ cgraph_node::get (fn)->release_body ();
+ }
+
/* Signal this is a suitable GC collection point. */
if (!((todo_after | pass->todo_flags_finish) & TODO_do_not_ggc_collect))
ggc_collect ();
@@ -2361,6 +2383,9 @@ execute_pass_list_1 (opt_pass *pass)
{
gcc_assert (pass->type == GIMPLE_PASS
|| pass->type == RTL_PASS);
+
+ if (cfun == NULL)
+ return;
if (execute_one_pass (pass) && pass->sub)
execute_pass_list_1 (pass->sub);
pass = pass->next;
@@ -2371,14 +2396,13 @@ execute_pass_list_1 (opt_pass *pass)
void
execute_pass_list (function *fn, opt_pass *pass)
{
- push_cfun (fn);
+ gcc_assert (fn == cfun);
execute_pass_list_1 (pass);
- if (fn->cfg)
+ if (cfun && fn->cfg)
{
free_dominance_info (CDI_DOMINATORS);
free_dominance_info (CDI_POST_DOMINATORS);
}
- pop_cfun ();
}
/* Write out all LTO data. */