aboutsummaryrefslogtreecommitdiff
path: root/gcc/passes.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2007-01-16 22:30:54 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2007-01-16 21:30:54 +0000
commit873aa8f5480598231174d8781bc60614815dd71d (patch)
tree804fa8f1f32288cbe6d17f5732d75a433109a589 /gcc/passes.c
parent2797f081d474a208a74af9684d2c5c3dc0ff282d (diff)
downloadgcc-873aa8f5480598231174d8781bc60614815dd71d.zip
gcc-873aa8f5480598231174d8781bc60614815dd71d.tar.gz
gcc-873aa8f5480598231174d8781bc60614815dd71d.tar.bz2
cgraph.h (cgraph_decide_inlining_incrementally): Kill.
* cgraph.h (cgraph_decide_inlining_incrementally): Kill. * tree-pass.h: Reorder to make IPA passes appear toegher. (pass_early_inline, pass_inline_parameters, pass_apply_inline): Declare. * cgraphunit.c (cgraph_finalize_function): Do not compute inling parameters, do not call early inliner. * ipa-inline.c: Update comments. Include tree-flow.h (cgraph_decide_inlining): Do not compute inlining parameters. (cgraph_decide_inlining_incrementally): Return TODOs; assume to be called with function context set up. (pass_ipa_inline): Remove unreachable functions before pass. (cgraph_early_inlining): Simplify assuming to be called from the PM as local pass. (pass_early_inline): New pass. (cgraph_gate_ipa_early_inlining): New gate. (pass_ipa_early_inline): Turn into simple wrapper. (compute_inline_parameters): New function. (gate_inline_passes): New gate. (pass_inline_parameters): New pass. (apply_inline): Move here from tree-optimize.c (pass_apply_inline): New pass. * ipa.c (cgraph_remove_unreachable_nodes): Verify cgraph after transforming. * tree-inline.c (optimize_inline_calls): Return TODOs rather than doing them by hand. (tree_function_versioning): Do not allocate dummy struct function. * tree-inline.h (optimize_inline_calls): Update prototype. * tree-optimize.c (execute_fixup_cfg): Export. (pass_fixup_cfg): Remove (tree_rest_of_compilation): Do not apply inlines. * tree-flow.h (execute_fixup_cfg): Declare. * Makefile.in (gt-passes.c): New. * passes.c: Include gt-passes.h (init_optimization_passes): New passes. (nnodes, order): New static vars. (do_per_function_toporder): New function. (execute_one_pass): Dump current pass here. (execute_ipa_pass_list): Don't dump current pass here. From-SVN: r120835
Diffstat (limited to 'gcc/passes.c')
-rw-r--r--gcc/passes.c73
1 files changed, 65 insertions, 8 deletions
diff --git a/gcc/passes.c b/gcc/passes.c
index d770ffc..9cb2c52 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -437,10 +437,11 @@ init_optimization_passes (void)
struct tree_opt_pass **p;
#define NEXT_PASS(PASS) (p = next_pass_1 (p, &PASS))
+
/* Interprocedural optimization passes. */
p = &all_ipa_passes;
NEXT_PASS (pass_ipa_function_and_variable_visibility);
- NEXT_PASS (pass_early_ipa_inline);
+ NEXT_PASS (pass_ipa_early_inline);
NEXT_PASS (pass_early_local_passes);
NEXT_PASS (pass_ipa_increase_alignment);
NEXT_PASS (pass_ipa_cp);
@@ -451,6 +452,12 @@ init_optimization_passes (void)
NEXT_PASS (pass_ipa_pta);
*p = NULL;
+ p = &pass_ipa_early_inline.sub;
+ NEXT_PASS (pass_early_inline);
+ NEXT_PASS (pass_inline_parameters);
+ NEXT_PASS (pass_rebuild_cgraph_edges);
+ *p = NULL;
+
/* All passes needed to lower the function into shape optimizers can
operate on. */
p = &all_lowering_passes;
@@ -464,6 +471,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_lower_vector);
NEXT_PASS (pass_warn_function_return);
NEXT_PASS (pass_build_cgraph_edges);
+ NEXT_PASS (pass_inline_parameters);
*p = NULL;
p = &pass_early_local_passes.sub;
@@ -473,6 +481,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_expand_omp);
NEXT_PASS (pass_all_early_optimizations);
NEXT_PASS (pass_rebuild_cgraph_edges);
+ NEXT_PASS (pass_inline_parameters);
*p = NULL;
p = &pass_all_early_optimizations.sub;
@@ -480,6 +489,8 @@ init_optimization_passes (void)
NEXT_PASS (pass_reset_cc_flags);
NEXT_PASS (pass_build_ssa);
NEXT_PASS (pass_early_warn_uninitialized);
+ NEXT_PASS (pass_rebuild_cgraph_edges);
+ NEXT_PASS (pass_early_inline);
NEXT_PASS (pass_cleanup_cfg);
NEXT_PASS (pass_rename_ssa_copies);
NEXT_PASS (pass_ccp);
@@ -494,7 +505,7 @@ init_optimization_passes (void)
*p = NULL;
p = &all_passes;
- NEXT_PASS (pass_fixup_cfg);
+ NEXT_PASS (pass_apply_inline);
NEXT_PASS (pass_all_optimizations);
NEXT_PASS (pass_warn_function_noreturn);
NEXT_PASS (pass_free_datastructures);
@@ -749,6 +760,52 @@ do_per_function (void (*callback) (void *data), void *data)
}
}
+/* Because inlining might remove no-longer reachable nodes, we need to
+ keep the array visible to garbage collector to avoid reading collected
+ out nodes. */
+static int nnodes;
+static GTY ((length ("nnodes"))) struct cgraph_node **order;
+
+/* If we are in IPA mode (i.e., current_function_decl is NULL), call
+ function CALLBACK for every function in the call graph. Otherwise,
+ call CALLBACK on the current function. */
+
+static void
+do_per_function_toporder (void (*callback) (void *data), void *data)
+{
+ int i;
+
+ if (current_function_decl)
+ callback (data);
+ else
+ {
+ gcc_assert (!order);
+ order = ggc_alloc (sizeof (*order) * cgraph_n_nodes);
+ nnodes = cgraph_postorder (order);
+ for (i = nnodes - 1; i >= 0; i--)
+ {
+ struct cgraph_node *node = order[i];
+
+ /* Allow possibly removed nodes to be garbage collected. */
+ order[i] = NULL;
+ if (node->analyzed && (node->needed || node->reachable))
+ {
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ current_function_decl = node->decl;
+ callback (data);
+ free_dominance_info (CDI_DOMINATORS);
+ free_dominance_info (CDI_POST_DOMINATORS);
+ current_function_decl = NULL;
+ pop_cfun ();
+ ggc_collect ();
+ }
+ }
+ }
+ ggc_free (order);
+ order = NULL;
+ nnodes = 0;
+}
+
/* Perform all TODO actions that ought to be done on each function. */
static void
@@ -903,6 +960,9 @@ execute_one_pass (struct tree_opt_pass *pass)
if (pass->gate && !pass->gate ())
return false;
+ if (!quiet_flag && !cfun)
+ fprintf (stderr, " <%s>", pass->name ? pass->name : "");
+
if (pass->todo_flags_start & TODO_set_props)
cfun->curr_properties = pass->properties_required;
@@ -1012,16 +1072,13 @@ execute_ipa_pass_list (struct tree_opt_pass *pass)
{
gcc_assert (!current_function_decl);
gcc_assert (!cfun);
- if (!quiet_flag)
- {
- fprintf (stderr, " <%s>", pass->name ? pass->name : "");
- fflush (stderr);
- }
if (execute_one_pass (pass) && pass->sub)
- do_per_function ((void (*)(void *))execute_pass_list, pass->sub);
+ do_per_function_toporder ((void (*)(void *))execute_pass_list,
+ pass->sub);
if (!current_function_decl)
cgraph_process_new_functions ();
pass = pass->next;
}
while (pass);
}
+#include "gt-passes.h"