cgraph_edge *
cgraph_edge::clone (cgraph_node *n, gcall *call_stmt, unsigned stmt_uid,
- gcov_type count_scale, int freq_scale, bool update_original)
+ profile_count num, profile_count den,
+ int freq_scale, bool update_original)
{
cgraph_edge *new_edge;
- profile_count gcov_count = count.apply_scale (count_scale, REG_BR_PROB_BASE);
+ profile_count gcov_count
+ = (num == profile_count::zero () || den > 0)
+ ? count.apply_scale (num, den) : count;
gcov_type freq;
/* We do not want to ignore loop nest after frequency drops to 0. */
{
new_edge = n->create_indirect_edge (call_stmt,
indirect_info->ecf_flags,
- count, freq, false);
+ gcov_count, freq, false);
*new_edge->indirect_info = *indirect_info;
}
}
{
cgraph_node *new_node = symtab->create_empty ();
cgraph_edge *e;
- gcov_type count_scale;
unsigned i;
if (new_inlined_to)
new_node->global = global;
new_node->global.inlined_to = new_inlined_to;
new_node->rtl = rtl;
- new_node->count = count;
new_node->frequency = frequency;
new_node->tp_first_run = tp_first_run;
new_node->tm_clone = tm_clone;
else
new_node->clone.combined_args_to_skip = args_to_skip;
- if (count.initialized_p ())
- {
- if (new_node->count > count)
- count_scale = REG_BR_PROB_BASE;
- else
- count_scale = new_node->count.probability_in (count);
- }
- else
- count_scale = 0;
- if (update_original)
- count -= prof_count;
-
FOR_EACH_VEC_ELT (redirect_callers, i, e)
{
/* Redirect calls to the old version node to point to its new
new_node->expand_all_artificial_thunks ();
for (e = callees;e; e=e->next_callee)
- e->clone (new_node, e->call_stmt, e->lto_stmt_uid, count_scale,
+ e->clone (new_node, e->call_stmt, e->lto_stmt_uid, new_node->count, count,
freq, update_original);
for (e = indirect_calls; e; e = e->next_callee)
e->clone (new_node, e->call_stmt, e->lto_stmt_uid,
- count_scale, freq, update_original);
+ new_node->count, count, freq, update_original);
new_node->clone_references (this);
new_node->next_sibling_clone = clones;
clones = new_node;
new_node->clone_of = this;
+ if (update_original)
+ count -= prof_count;
+
if (call_duplication_hook)
symtab->call_cgraph_duplication_hooks (this, new_node);
if (!bbs_to_copy
|| bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
e->clone (new_version, e->call_stmt,
- e->lto_stmt_uid, REG_BR_PROB_BASE,
+ e->lto_stmt_uid, count, count,
CGRAPH_FREQ_BASE,
true);
for (e = indirect_calls; e; e=e->next_callee)
if (!bbs_to_copy
|| bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
e->clone (new_version, e->call_stmt,
- e->lto_stmt_uid, REG_BR_PROB_BASE,
+ e->lto_stmt_uid, count, count,
CGRAPH_FREQ_BASE,
true);
FOR_EACH_VEC_ELT (redirect_callers, i, e)
struct cgraph_edge *old_edge = edge;
edge = edge->clone (id->dst_node, call_stmt,
gimple_uid (stmt),
- REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
+ profile_count::one (),
+ profile_count::one (),
+ CGRAPH_FREQ_BASE,
true);
/* We could also just rescale the frequency, but
doing so would introduce roundoff errors and make
old_edge->speculative_call_info (direct, indirect, ref);
indirect = indirect->clone (id->dst_node, call_stmt,
gimple_uid (stmt),
- REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
+ profile_count::one (),
+ profile_count::one (),
+ CGRAPH_FREQ_BASE,
true);
if (old_edge->frequency + indirect->frequency)
{
cg_edge->remove ();
edge = id->src_node->callees->clone (id->dst_node, call_stmt,
gimple_uid (stmt),
- REG_BR_PROB_BASE, CGRAPH_FREQ_BASE,
+ profile_count::one (),
+ profile_count::one (),
+ CGRAPH_FREQ_BASE,
true);
edge->frequency = freq;
edge->count = count;