diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-10 15:13:54 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-02-10 15:13:54 +0000 |
commit | 8cff878b277f9af6c2827a87581baac5f768e12a (patch) | |
tree | d4e178503efd243eed24ff3b753cd998370d75d4 /gcc/ipa-inline-analysis.c | |
parent | 9610b14f8599a9db94822d3f0923b58b2f1177dc (diff) | |
download | gcc-8cff878b277f9af6c2827a87581baac5f768e12a.tar.gz |
[./]
2016-02-10 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with some of GCC 6, using
svn merge -r222130:226090 ^/trunk ; UNSTABLE}}
[gcc/]
2016-02-10 Basile Starynkevitch <basile@starynkevitch.net>
{{ merging with trunk 226090 ; UNSTABLE }}
* melt-run.proto.h: include tree-ssa-scopedtables.h
* tree-ssa-dom.c: skip second record_edge_info
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@233272 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-inline-analysis.c')
-rw-r--r-- | gcc/ipa-inline-analysis.c | 148 |
1 files changed, 61 insertions, 87 deletions
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 5d998870f34..286335eb474 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -67,21 +67,14 @@ along with GCC; see the file COPYING3. If not see #include "config.h" #include "system.h" #include "coretypes.h" -#include "tm.h" -#include "hash-set.h" -#include "machmode.h" -#include "vec.h" -#include "double-int.h" -#include "input.h" -#include "alias.h" -#include "symtab.h" -#include "wide-int.h" -#include "inchash.h" -#include "real.h" +#include "backend.h" #include "tree.h" +#include "gimple.h" +#include "hard-reg-set.h" +#include "ssa.h" +#include "alias.h" #include "fold-const.h" #include "stor-layout.h" -#include "stringpool.h" #include "print-tree.h" #include "tree-inline.h" #include "langhooks.h" @@ -91,36 +84,16 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-pass.h" #include "coverage.h" -#include "predict.h" -#include "hard-reg-set.h" -#include "input.h" -#include "function.h" -#include "dominance.h" -#include "cfg.h" #include "cfganal.h" -#include "basic-block.h" -#include "tree-ssa-alias.h" #include "internal-fn.h" -#include "gimple-expr.h" -#include "is-a.h" -#include "gimple.h" #include "gimple-iterator.h" -#include "gimple-ssa.h" #include "tree-cfg.h" -#include "tree-phinodes.h" -#include "ssa-iterators.h" -#include "tree-ssanames.h" #include "tree-ssa-loop-niter.h" #include "tree-ssa-loop.h" -#include "hash-map.h" -#include "plugin-api.h" -#include "ipa-ref.h" #include "cgraph.h" #include "alloc-pool.h" #include "symbol-summary.h" #include "ipa-prop.h" -#include "lto-streamer.h" -#include "data-streamer.h" #include "tree-streamer.h" #include "ipa-inline.h" #include "cfgloop.h" @@ -170,7 +143,7 @@ vec<inline_edge_summary_t> inline_edge_summary_vec; vec<edge_growth_cache_entry> edge_growth_cache; /* Edge predicates goes here. */ -static alloc_pool edge_predicate_pool; +static object_allocator<predicate> edge_predicate_pool ("edge predicates", 10); /* Return true predicate (tautology). We represent it by empty list of clauses. */ @@ -804,13 +777,13 @@ edge_set_predicate (struct cgraph_edge *e, struct predicate *predicate) if (predicate && !true_predicate_p (predicate)) { if (!es->predicate) - es->predicate = (struct predicate *) pool_alloc (edge_predicate_pool); + es->predicate = edge_predicate_pool.allocate (); *es->predicate = *predicate; } else { if (es->predicate) - pool_free (edge_predicate_pool, es->predicate); + edge_predicate_pool.remove (es->predicate); es->predicate = NULL; } } @@ -823,13 +796,13 @@ set_hint_predicate (struct predicate **p, struct predicate new_predicate) if (false_predicate_p (&new_predicate) || true_predicate_p (&new_predicate)) { if (*p) - pool_free (edge_predicate_pool, *p); + edge_predicate_pool.remove (*p); *p = NULL; } else { if (!*p) - *p = (struct predicate *) pool_alloc (edge_predicate_pool); + *p = edge_predicate_pool.allocate (); **p = new_predicate; } } @@ -1044,9 +1017,6 @@ inline_summary_alloc (void) if (inline_edge_summary_vec.length () <= (unsigned) symtab->edges_max_uid) inline_edge_summary_vec.safe_grow_cleared (symtab->edges_max_uid + 1); - if (!edge_predicate_pool) - edge_predicate_pool = create_alloc_pool ("edge predicates", - sizeof (struct predicate), 10); } /* We are called multiple time for given function; clear @@ -1061,7 +1031,7 @@ reset_inline_edge_summary (struct cgraph_edge *e) es->call_stmt_size = es->call_stmt_time = 0; if (es->predicate) - pool_free (edge_predicate_pool, es->predicate); + edge_predicate_pool.remove (es->predicate); es->predicate = NULL; es->param.release (); } @@ -1086,17 +1056,17 @@ reset_inline_summary (struct cgraph_node *node, info->scc_no = 0; if (info->loop_iterations) { - pool_free (edge_predicate_pool, info->loop_iterations); + edge_predicate_pool.remove (info->loop_iterations); info->loop_iterations = NULL; } if (info->loop_stride) { - pool_free (edge_predicate_pool, info->loop_stride); + edge_predicate_pool.remove (info->loop_stride); info->loop_stride = NULL; } if (info->array_index) { - pool_free (edge_predicate_pool, info->array_index); + edge_predicate_pool.remove (info->array_index); info->array_index = NULL; } vec_free (info->conds); @@ -1602,7 +1572,7 @@ unmodified_parm (gimple stmt, tree op) loaded. */ static bool -unmodified_parm_or_parm_agg_item (struct ipa_node_params *info, +unmodified_parm_or_parm_agg_item (struct ipa_func_body_info *fbi, gimple stmt, tree op, int *index_p, struct agg_position_info *aggpos) { @@ -1611,7 +1581,7 @@ unmodified_parm_or_parm_agg_item (struct ipa_node_params *info, gcc_checking_assert (aggpos); if (res) { - *index_p = ipa_get_param_decl_index (info, res); + *index_p = ipa_get_param_decl_index (fbi->info, res); if (*index_p < 0) return false; aggpos->agg_contents = false; @@ -1627,13 +1597,14 @@ unmodified_parm_or_parm_agg_item (struct ipa_node_params *info, stmt = SSA_NAME_DEF_STMT (op); op = gimple_assign_rhs1 (stmt); if (!REFERENCE_CLASS_P (op)) - return unmodified_parm_or_parm_agg_item (info, stmt, op, index_p, + return unmodified_parm_or_parm_agg_item (fbi, stmt, op, index_p, aggpos); } aggpos->agg_contents = true; - return ipa_load_from_parm_agg (info, stmt, op, index_p, &aggpos->offset, - &aggpos->by_ref); + return ipa_load_from_parm_agg (fbi, fbi->info->descriptors, + stmt, op, index_p, &aggpos->offset, + NULL, &aggpos->by_ref); } /* See if statement might disappear after inlining. @@ -1772,7 +1743,7 @@ eliminated_by_inlining_prob (gimple stmt) predicates to the CFG edges. */ static void -set_cond_stmt_execution_predicate (struct ipa_node_params *info, +set_cond_stmt_execution_predicate (struct ipa_func_body_info *fbi, struct inline_summary *summary, basic_block bb) { @@ -1795,7 +1766,7 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info, /* TODO: handle conditionals like var = op0 < 4; if (var != 0). */ - if (unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos)) + if (unmodified_parm_or_parm_agg_item (fbi, last, op, &index, &aggpos)) { code = gimple_cond_code (last); inverted_code = invert_tree_comparison (code, HONOR_NANS (op)); @@ -1812,7 +1783,7 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info, struct predicate p = add_condition (summary, index, &aggpos, this_code, gimple_cond_rhs (last)); - e->aux = pool_alloc (edge_predicate_pool); + e->aux = edge_predicate_pool.allocate (); *(struct predicate *) e->aux = p; } } @@ -1838,14 +1809,13 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info, || gimple_call_num_args (set_stmt) != 1) return; op2 = gimple_call_arg (set_stmt, 0); - if (!unmodified_parm_or_parm_agg_item - (info, set_stmt, op2, &index, &aggpos)) + if (!unmodified_parm_or_parm_agg_item (fbi, set_stmt, op2, &index, &aggpos)) return; FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & EDGE_FALSE_VALUE) { struct predicate p = add_condition (summary, index, &aggpos, IS_NOT_CONSTANT, NULL_TREE); - e->aux = pool_alloc (edge_predicate_pool); + e->aux = edge_predicate_pool.allocate (); *(struct predicate *) e->aux = p; } } @@ -1855,7 +1825,7 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info, predicates to the CFG edges. */ static void -set_switch_stmt_execution_predicate (struct ipa_node_params *info, +set_switch_stmt_execution_predicate (struct ipa_func_body_info *fbi, struct inline_summary *summary, basic_block bb) { @@ -1873,12 +1843,12 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info, return; gswitch *last = as_a <gswitch *> (lastg); op = gimple_switch_index (last); - if (!unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos)) + if (!unmodified_parm_or_parm_agg_item (fbi, last, op, &index, &aggpos)) return; FOR_EACH_EDGE (e, ei, bb->succs) { - e->aux = pool_alloc (edge_predicate_pool); + e->aux = edge_predicate_pool.allocate (); *(struct predicate *) e->aux = false_predicate (); } n = gimple_switch_num_labels (last); @@ -1916,8 +1886,8 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info, which it is executable. */ static void -compute_bb_predicates (struct cgraph_node *node, - struct ipa_node_params *parms_info, +compute_bb_predicates (struct ipa_func_body_info *fbi, + struct cgraph_node *node, struct inline_summary *summary) { struct function *my_function = DECL_STRUCT_FUNCTION (node->decl); @@ -1926,13 +1896,13 @@ compute_bb_predicates (struct cgraph_node *node, FOR_EACH_BB_FN (bb, my_function) { - set_cond_stmt_execution_predicate (parms_info, summary, bb); - set_switch_stmt_execution_predicate (parms_info, summary, bb); + set_cond_stmt_execution_predicate (fbi, summary, bb); + set_switch_stmt_execution_predicate (fbi, summary, bb); } /* Entry block is always executable. */ ENTRY_BLOCK_PTR_FOR_FN (my_function)->aux - = pool_alloc (edge_predicate_pool); + = edge_predicate_pool.allocate (); *(struct predicate *) ENTRY_BLOCK_PTR_FOR_FN (my_function)->aux = true_predicate (); @@ -1968,7 +1938,7 @@ compute_bb_predicates (struct cgraph_node *node, if (!bb->aux) { done = false; - bb->aux = pool_alloc (edge_predicate_pool); + bb->aux = edge_predicate_pool.allocate (); *((struct predicate *) bb->aux) = p; } else if (!predicates_equal_p (&p, (struct predicate *) bb->aux)) @@ -2059,7 +2029,7 @@ will_be_nonconstant_expr_predicate (struct ipa_node_params *info, a compile time constant. */ static struct predicate -will_be_nonconstant_predicate (struct ipa_node_params *info, +will_be_nonconstant_predicate (struct ipa_func_body_info *fbi, struct inline_summary *summary, gimple stmt, vec<predicate_t> nonconstant_names) @@ -2093,7 +2063,7 @@ will_be_nonconstant_predicate (struct ipa_node_params *info, tree op; gcc_assert (gimple_assign_single_p (stmt)); op = gimple_assign_rhs1 (stmt); - if (!unmodified_parm_or_parm_agg_item (info, stmt, op, &base_index, + if (!unmodified_parm_or_parm_agg_item (fbi, stmt, op, &base_index, &aggpos)) return p; } @@ -2106,7 +2076,7 @@ will_be_nonconstant_predicate (struct ipa_node_params *info, { tree parm = unmodified_parm (stmt, use); /* For arguments we can build a condition. */ - if (parm && ipa_get_param_decl_index (info, parm) >= 0) + if (parm && ipa_get_param_decl_index (fbi->info, parm) >= 0) continue; if (TREE_CODE (use) != SSA_NAME) return p; @@ -2127,7 +2097,7 @@ will_be_nonconstant_predicate (struct ipa_node_params *info, tree parm = unmodified_parm (stmt, use); int index; - if (parm && (index = ipa_get_param_decl_index (info, parm)) >= 0) + if (parm && (index = ipa_get_param_decl_index (fbi->info, parm)) >= 0) { if (index != base_index) p = add_condition (summary, index, NULL, CHANGED, NULL_TREE); @@ -2509,13 +2479,17 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) int freq; struct inline_summary *info = inline_summaries->get (node); struct predicate bb_predicate; - struct ipa_node_params *parms_info = NULL; + struct ipa_func_body_info fbi; vec<predicate_t> nonconstant_names = vNULL; int nblocks, n; int *order; predicate array_index = true_predicate (); gimple fix_builtin_expect_stmt; + gcc_assert (my_function && my_function->cfg); + gcc_assert (cfun == my_function); + + memset(&fbi, 0, sizeof(fbi)); info->conds = NULL; info->entry = NULL; @@ -2538,7 +2512,11 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) if (ipa_node_params_sum) { - parms_info = IPA_NODE_REF (node); + fbi.node = node; + fbi.info = IPA_NODE_REF (node); + fbi.bb_infos = vNULL; + fbi.bb_infos.safe_grow_cleared (last_basic_block_for_fn (cfun)); + fbi.param_count = count_formal_params(node->decl); nonconstant_names.safe_grow_cleared (SSANAMES (my_function)->length ()); } @@ -2556,10 +2534,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) bb_predicate = not_inlined_predicate (); account_size_time (info, 2 * INLINE_SIZE_SCALE, 0, &bb_predicate); - gcc_assert (my_function && my_function->cfg); - if (parms_info) - compute_bb_predicates (node, parms_info, info); - gcc_assert (cfun == my_function); + if (fbi.info) + compute_bb_predicates (&fbi, node, info); order = XNEWVEC (int, n_basic_blocks_for_fn (cfun)); nblocks = pre_and_rev_post_order_compute (NULL, order, false); for (n = 0; n < nblocks; n++) @@ -2576,7 +2552,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) } /* TODO: Obviously predicates can be propagated down across CFG. */ - if (parms_info) + if (fbi.info) { if (bb->aux) bb_predicate = *(struct predicate *) bb->aux; @@ -2592,7 +2568,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) dump_predicate (dump_file, info->conds, &bb_predicate); } - if (parms_info && nonconstant_names.exists ()) + if (fbi.info && nonconstant_names.exists ()) { struct predicate phi_predicate; bool first_phi = true; @@ -2601,7 +2577,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) gsi_next (&bsi)) { if (first_phi - && !phi_result_unknown_predicate (parms_info, info, bb, + && !phi_result_unknown_predicate (fbi.info, info, bb, &phi_predicate, nonconstant_names)) break; @@ -2710,9 +2686,9 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) /* TODO: When conditional jump or swithc is known to be constant, but we did not translate it into the predicates, we really can account just maximum of the possible paths. */ - if (parms_info) + if (fbi.info) will_be_nonconstant - = will_be_nonconstant_predicate (parms_info, info, + = will_be_nonconstant_predicate (&fbi, info, stmt, nonconstant_names); if (this_time || this_size) { @@ -2727,7 +2703,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) if (prob == 2 && dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "\t\tWill be eliminated by inlining\n"); - if (parms_info) + if (fbi.info) p = and_predicates (info->conds, &bb_predicate, &will_be_nonconstant); else @@ -2795,7 +2771,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) && !is_gimple_min_invariant (niter_desc.niter)) { predicate will_be_nonconstant - = will_be_nonconstant_expr_predicate (parms_info, info, + = will_be_nonconstant_expr_predicate (fbi.info, info, niter_desc.niter, nonconstant_names); if (!true_predicate_p (&will_be_nonconstant)) @@ -2833,7 +2809,7 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) || is_gimple_min_invariant (iv.step)) continue; will_be_nonconstant - = will_be_nonconstant_expr_predicate (parms_info, info, + = will_be_nonconstant_expr_predicate (fbi.info, info, iv.step, nonconstant_names); if (!true_predicate_p (&will_be_nonconstant)) @@ -2864,12 +2840,12 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early) edge_iterator ei; if (bb->aux) - pool_free (edge_predicate_pool, bb->aux); + edge_predicate_pool.remove ((predicate *)bb->aux); bb->aux = NULL; FOR_EACH_EDGE (e, ei, bb->succs) { if (e->aux) - pool_free (edge_predicate_pool, e->aux); + edge_predicate_pool.remove ((predicate *) e->aux); e->aux = NULL; } } @@ -4460,7 +4436,5 @@ inline_free_summary (void) inline_summaries->release (); inline_summaries = NULL; inline_edge_summary_vec.release (); - if (edge_predicate_pool) - free_alloc_pool (edge_predicate_pool); - edge_predicate_pool = 0; + edge_predicate_pool.release (); } |