From 2a5671ee800de5ace6b9d78cd47de73a04d92fa8 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 13 Mar 2015 08:47:14 +0000 Subject: re PR ipa/44563 (GCC uses a lot of RAM when compiling a large numbers of functions) 2015-03-10 Richard Biener PR middle-end/44563 * tree-cfgcleanup.c (split_bb_on_noreturn_calls): Remove. (cleanup_tree_cfg_1): Do not call it. (execute_cleanup_cfg_post_optimizing): Fixup the CFG here. (fixup_noreturn_call): Mark the stmt as control altering. * tree-cfg.c (execute_fixup_cfg): Do not dump the function here. (pass_data_fixup_cfg): Produce a dump file. * tree-ssa-dom.c: Include tree-cfgcleanup.h. (need_noreturn_fixup): New global. (pass_dominator::execute): Fixup queued noreturn calls. (optimize_stmt): Queue calls that became noreturn for fixup. * tree-ssa-forwprop.c (pass_forwprop::execute): Likewise. * tree-ssa-pre.c: Include tree-cfgcleanup.h. (el_to_fixup): New global. (eliminate_dom_walker::before_dom_childre): Queue calls that became noreturn for fixup. (eliminate): Fixup queued noreturn calls. * tree-ssa-propagate.c: Include tree-cfgcleanup.h. (substitute_and_fold_dom_walker): New member stmts_to_fixup. (substitute_and_fold_dom_walker::before_dom_children): Queue alls that became noreturn for fixup. (substitute_and_fold): Fixup queued noreturn calls. From-SVN: r221409 --- gcc/tree-ssa-dom.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'gcc/tree-ssa-dom.c') diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index d230ce1..ea49eb7 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-ssa-dom.h" #include "inchash.h" #include "gimplify.h" +#include "tree-cfgcleanup.h" /* This file implements optimizations on the dominator tree. */ @@ -246,6 +247,7 @@ static bool cfg_altered; /* Bitmap of blocks that have had EH statements cleaned. We should remove their dead edges eventually. */ static bitmap need_eh_cleanup; +static vec need_noreturn_fixup; /* Statistics for dominator optimizations. */ struct opt_stats_d @@ -885,6 +887,7 @@ pass_dominator::execute (function *fun) avail_exprs_stack.create (20); const_and_copies_stack.create (20); need_eh_cleanup = BITMAP_ALLOC (NULL); + need_noreturn_fixup.create (0); calculate_dominance_info (CDI_DOMINATORS); cfg_altered = false; @@ -967,6 +970,23 @@ pass_dominator::execute (function *fun) bitmap_clear (need_eh_cleanup); } + /* Fixup stmts that became noreturn calls. This may require splitting + blocks and thus isn't possible during the dominator walk or before + jump threading finished. Do this in reverse order so we don't + inadvertedly remove a stmt we want to fixup by visiting a dominating + now noreturn call first. */ + while (!need_noreturn_fixup.is_empty ()) + { + gimple stmt = need_noreturn_fixup.pop (); + if (dump_file && dump_flags & TDF_DETAILS) + { + fprintf (dump_file, "Fixing up noreturn call "); + print_gimple_stmt (dump_file, stmt, 0, 0); + fprintf (dump_file, "\n"); + } + fixup_noreturn_call (stmt); + } + statistics_counter_event (fun, "Redundant expressions eliminated", opt_stats.num_re); statistics_counter_event (fun, "Constants propagated", @@ -986,7 +1006,7 @@ pass_dominator::execute (function *fun) /* Free asserted bitmaps and stacks. */ BITMAP_FREE (need_eh_cleanup); - + need_noreturn_fixup.release (); avail_exprs_stack.release (); const_and_copies_stack.release (); @@ -2364,8 +2384,10 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si) gimple stmt, old_stmt; bool may_optimize_p; bool modified_p = false; + bool was_noreturn; old_stmt = stmt = gsi_stmt (si); + was_noreturn = is_gimple_call (stmt) && gimple_call_noreturn_p (stmt); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -2545,6 +2567,10 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si) if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " Flagged to clear EH edges.\n"); } + + if (!was_noreturn + && is_gimple_call (stmt) && gimple_call_noreturn_p (stmt)) + need_noreturn_fixup.safe_push (stmt); } } -- cgit v1.1