From 1920df6c2253448d27f4e8e016fa504810857649 Mon Sep 17 00:00:00 2001 From: Kenneth Zadeck Date: Thu, 15 May 2008 22:58:03 +0000 Subject: [PATCH] cgraph.h (compute_inline_parameters): Made public. 2008-05-15 Kenneth Zadeck * cgraph.h (compute_inline_parameters): Made public. * tree-pass.h (ipa_opt_pass): Removed function_generate_summary, variable_generate_summary, function_write_summary, variable_write_summary, variable_read_summary. Added generate_summary, write_summary, read_summary. * cgraphunit.c (cgraph_process_new_functions): Changed call from pass_ipa_inline.function_generate_summary, to compute_inline_parameters. * ipa-inline.c (compute_inline_parameters): Made public and added node parameter. (compute_inline_parameters_for_current): New function. (pass_inline_param): Now calls compute_inline_parameters_for_current. (inline_generate_summary): Removed parameter and made to loop over all cgraph nodes. (pass_ipa_inline): Updated for new IPA_PASS structure. * passes.c (execute_ipa_summary_passes): Now is called once per pass rather than once per node*pass. From-SVN: r135401 --- gcc/ChangeLog | 21 ++++++++++++++++++++ gcc/cgraph.h | 1 + gcc/cgraphunit.c | 2 +- gcc/ipa-inline.c | 51 ++++++++++++++++++++++++++++++++++++------------ gcc/passes.c | 18 ++++++++--------- gcc/tree-pass.h | 24 +++++++++++------------ 6 files changed, 83 insertions(+), 34 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d5f25c9edc3..6d9adc3cef9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2008-05-15 Kenneth Zadeck + + * cgraph.h (compute_inline_parameters): Made public. + * tree-pass.h (ipa_opt_pass): Removed function_generate_summary, + variable_generate_summary, function_write_summary, + variable_write_summary, variable_read_summary. Added + generate_summary, write_summary, read_summary. + * cgraphunit.c (cgraph_process_new_functions): Changed call from + pass_ipa_inline.function_generate_summary, to + compute_inline_parameters. + * ipa-inline.c (compute_inline_parameters): Made public and added + node parameter. + (compute_inline_parameters_for_current): New function. + (pass_inline_param): Now calls + compute_inline_parameters_for_current. + (inline_generate_summary): Removed parameter and made to loop over + all cgraph nodes. + (pass_ipa_inline): Updated for new IPA_PASS structure. + * passes.c (execute_ipa_summary_passes): Now is called once per + pass rather than once per node*pass. + 2008-05-15 Anatoly Sokolov * config/avr/avr.c (avr_base_arch_macro, avr_have_movw_lpmx_p, diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 97b5e1fd484..b537cb5785b 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -418,6 +418,7 @@ varpool_next_static_initializer (struct varpool_node *node) void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool, bool); void cgraph_mark_inline_edge (struct cgraph_edge *, bool); bool cgraph_default_inline_p (struct cgraph_node *, const char **); +unsigned int compute_inline_parameters (struct cgraph_node *); /* Create a new static variable of type TYPE. */ diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 0806050ef64..9f6ea72be80 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -460,7 +460,7 @@ cgraph_process_new_functions (void) cgraph_analyze_function (node); push_cfun (DECL_STRUCT_FUNCTION (fndecl)); current_function_decl = fndecl; - pass_ipa_inline.function_generate_summary (node); + compute_inline_parameters (node); if ((cgraph_state == CGRAPH_STATE_IPA_SSA && !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (fndecl))) /* When not optimizing, be sure we run early local passes anyway diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 5361b8a1d17..c3e58f33301 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -1519,11 +1519,9 @@ struct simple_ipa_opt_pass pass_ipa_early_inline = }; /* Compute parameters of functions used by inliner. */ -static unsigned int -compute_inline_parameters (void) +unsigned int +compute_inline_parameters (struct cgraph_node *node) { - struct cgraph_node *node = cgraph_node (current_function_decl); - gcc_assert (!node->global.inlined_to); inline_summary (node)->estimated_self_stack_size = estimated_stack_frame_size (); @@ -1543,6 +1541,16 @@ compute_inline_parameters (void) return 0; } + +/* Compute parameters of functions used by inliner using + current_function_decl. */ +static unsigned int +compute_inline_parameters_for_current (void) +{ + compute_inline_parameters (cgraph_node (current_function_decl)); + return 0; +} + /* When inlining shall be performed. */ static bool gate_inline_passes (void) @@ -1556,7 +1564,7 @@ struct gimple_opt_pass pass_inline_parameters = GIMPLE_PASS, NULL, /* name */ gate_inline_passes, /* gate */ - compute_inline_parameters, /* execute */ + compute_inline_parameters_for_current,/* execute */ NULL, /* sub */ NULL, /* next */ 0, /* static_pass_number */ @@ -1571,9 +1579,30 @@ struct gimple_opt_pass pass_inline_parameters = /* Note function body size. */ static void -inline_generate_summary (struct cgraph_node *node ATTRIBUTE_UNUSED) +inline_generate_summary (void) { - compute_inline_parameters (); + struct cgraph_node **order = + XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); + int nnodes = cgraph_postorder (order); + int i; + + 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; + compute_inline_parameters (node); + pop_cfun (); + } + } + + current_function_decl = NULL; + free (order); return; } @@ -1619,12 +1648,10 @@ struct ipa_opt_pass pass_ipa_inline = TODO_dump_cgraph | TODO_dump_func | TODO_remove_functions /* todo_flags_finish */ }, - inline_generate_summary, /* function_generate_summary */ - NULL, /* variable_generate_summary */ - NULL, /* function_write_summary */ - NULL, /* variable_write_summary */ + inline_generate_summary, /* generate_summary */ + NULL, /* write_summary */ + NULL, /* read_summary */ NULL, /* function_read_summary */ - NULL, /* variable_read_summary */ 0, /* TODOs */ inline_transform, /* function_transform */ NULL, /* variable_transform */ diff --git a/gcc/passes.c b/gcc/passes.c index ede2cd9c5f8..fa74d0fe0b1 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1157,21 +1157,21 @@ add_ipa_transform_pass (void *data) VEC_safe_push (ipa_opt_pass, heap, cfun->ipa_transforms_to_apply, ipa_pass); } -/* Execute IPA pass function summary generation. DATA is pointer to - pass list to execute. */ +/* Execute summary generation for all of the passes in IPA_PASS. */ static void -execute_ipa_summary_passes (void *data) +execute_ipa_summary_passes (struct ipa_opt_pass *ipa_pass) { - struct ipa_opt_pass *ipa_pass = (struct ipa_opt_pass *)data; - struct cgraph_node *node = cgraph_node (cfun->decl); - while (ipa_pass && ipa_pass->pass.type == IPA_PASS) + while (ipa_pass) { struct opt_pass *pass = &ipa_pass->pass; - if (!pass->gate || pass->gate ()) + + /* Execute all of the IPA_PASSes in the list. */ + if (ipa_pass->pass.type == IPA_PASS + && (!pass->gate || pass->gate ())) { pass_init_dump_file (pass); - ipa_pass->function_generate_summary (node); + ipa_pass->generate_summary (); pass_fini_dump_file (pass); } ipa_pass = (struct ipa_opt_pass *)ipa_pass->pass.next; @@ -1356,7 +1356,7 @@ execute_ipa_pass_list (struct opt_pass *pass) { if (!quiet_flag && !cfun) fprintf (stderr, " "); - do_per_function_toporder (execute_ipa_summary_passes, pass); + execute_ipa_summary_passes ((struct ipa_opt_pass *) pass); } summaries_generated = true; } diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index b1ac95f52c2..8ec46e87939 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -155,24 +155,24 @@ struct ipa_opt_pass { struct opt_pass pass; - /* IPA passes can analyze function body and variable initializers using this - hook and produce summary. */ - void (*function_generate_summary) (struct cgraph_node *); - void (*variable_generate_summary) (struct varpool_node *); - - /* These hooks will be used to serialize IPA summaries on disk. For a moment - they are just placeholders. */ - void (*function_write_summary) (struct cgraph_node *); - void (*variable_write_summary) (struct varpool_node *); - void (*function_read_summary) (struct cgraph_node *); - void (*variable_read_summary) (struct varpool_node *); + /* IPA passes can analyze function body and variable initializers + using this hook and produce summary. */ + void (*generate_summary) (void); + + /* This hook is used to serialize IPA summaries on disk. */ + void (*write_summary) (void); + /* For most ipa passes, the information can only be deserialized in + one chunk. However, function bodies are read function at a time + as needed so both calls are necessary. */ + void (*read_summary) (void); + void (*function_read_summary) (struct cgraph_node *); + /* Results of interprocedural propagation of an IPA pass is applied to function body via this hook. */ unsigned int function_transform_todo_flags_start; unsigned int (*function_transform) (struct cgraph_node *); void (*variable_transform) (struct varpool_node *); - }; /* Description of simple IPA pass. Simple IPA passes have just one execute -- 2.30.2