diff options
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 3932006..2cbacc7 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -500,6 +500,8 @@ cgraph_node::create (tree decl) node->decl = decl; + node->count = profile_count::uninitialized (); + if ((flag_openacc || flag_openmp) && lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl))) { @@ -808,7 +810,7 @@ cgraph_edge::set_call_stmt (gcall *new_stmt, bool update_speculative) cgraph_edge * symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee, - gcall *call_stmt, gcov_type count, int freq, + gcall *call_stmt, profile_count count, int freq, bool indir_unknown_callee) { cgraph_edge *edge; @@ -849,10 +851,9 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee, edge->lto_stmt_uid = 0; edge->count = count; - gcc_assert (count >= 0); edge->frequency = freq; - gcc_assert (freq >= 0); - gcc_assert (freq <= CGRAPH_FREQ_MAX); + gcc_checking_assert (freq >= 0); + gcc_checking_assert (freq <= CGRAPH_FREQ_MAX); edge->call_stmt = call_stmt; push_cfun (DECL_STRUCT_FUNCTION (caller->decl)); @@ -894,7 +895,7 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee, cgraph_edge * cgraph_node::create_edge (cgraph_node *callee, - gcall *call_stmt, gcov_type count, int freq) + gcall *call_stmt, profile_count count, int freq) { cgraph_edge *edge = symtab->create_edge (this, callee, call_stmt, count, freq, false); @@ -931,7 +932,7 @@ cgraph_allocate_init_indirect_info (void) cgraph_edge * cgraph_node::create_indirect_edge (gcall *call_stmt, int ecf_flags, - gcov_type count, int freq, + profile_count count, int freq, bool compute_indirect_info) { cgraph_edge *edge = symtab->create_edge (this, NULL, call_stmt, @@ -1047,7 +1048,7 @@ cgraph_edge::remove (void) Return direct edge created. */ cgraph_edge * -cgraph_edge::make_speculative (cgraph_node *n2, gcov_type direct_count, +cgraph_edge::make_speculative (cgraph_node *n2, profile_count direct_count, int direct_frequency) { cgraph_node *n = caller; @@ -1303,19 +1304,21 @@ cgraph_edge::redirect_call_stmt_to_callee (void) else { if (dump_file) - fprintf (dump_file, - "Expanding speculative call of %s -> %s count: " - "%" PRId64"\n", - e->caller->dump_name (), - e->callee->dump_name (), - (int64_t)e->count); + { + fprintf (dump_file, + "Expanding speculative call of %s -> %s count: ", + e->caller->dump_name (), + e->callee->dump_name ()); + e->count.dump (dump_file); + fprintf (dump_file, "\n"); + } gcc_assert (e2->speculative); push_cfun (DECL_STRUCT_FUNCTION (e->caller->decl)); new_stmt = gimple_ic (e->call_stmt, dyn_cast<cgraph_node *> (ref->referred), - e->count || e2->count - ? RDIV (e->count * REG_BR_PROB_BASE, - e->count + e2->count) + e->count > profile_count::zero () + || e2->count > profile_count::zero () + ? e->count.probability_in (e->count + e2->count) : e->frequency || e2->frequency ? RDIV (e->frequency * REG_BR_PROB_BASE, e->frequency + e2->frequency) @@ -1591,7 +1594,7 @@ cgraph_update_edges_for_call_stmt_node (cgraph_node *node, { cgraph_edge *e = node->get_edge (old_stmt); cgraph_edge *ne = NULL; - gcov_type count; + profile_count count; int frequency; if (e) @@ -2033,8 +2036,12 @@ cgraph_edge::dump_edge_flags (FILE *f) fprintf (f, "(call_stmt_cannot_inline_p) "); if (indirect_inlining_edge) fprintf (f, "(indirect_inlining) "); - if (count) - fprintf (f, "(%" PRId64"x) ", (int64_t)count); + if (count.initialized_p ()) + { + fprintf (f, "("); + count.dump (f); + fprintf (f, ")"); + } if (frequency) fprintf (f, "(%.2f per call) ", frequency / (double)CGRAPH_FREQ_BASE); if (can_throw_external) @@ -2085,9 +2092,11 @@ cgraph_node::dump (FILE *f) fprintf (f, "\n"); } fprintf (f, " Function flags:"); - if (count) - fprintf (f, " executed %" PRId64"x", - (int64_t)count); + if (count.initialized_p ()) + { + fprintf (f, " profile_count "); + count.dump (f); + } if (origin) fprintf (f, " nested in: %s", origin->asm_name ()); if (gimple_has_body_p (decl)) @@ -2737,6 +2746,10 @@ cgraph_edge::maybe_hot_p (void) return false; if (caller->frequency == NODE_FREQUENCY_HOT) return true; + /* If profile is now known yet, be conservative. + FIXME: this predicate is used by early inliner and can do better there. */ + if (symtab->state < IPA_SSA) + return true; if (caller->frequency == NODE_FREQUENCY_EXECUTED_ONCE && frequency < CGRAPH_FREQ_BASE * 3 / 2) return false; |