Commit 8e7d1486 by Jan Hubicka Committed by Jan Hubicka

re PR bootstrap/82832 (Broken PGO LTO bootstrap on x86_64 after r254379)


	PR bootstrap/82832
	* ipa-inline-transform.c (update_noncloned_frequencies): Always
	scale.
	(inline_transform): Likewise.
	* predict.c (counts_to_freqs): Remove useless conditional.
	* profile-count.h (profile_count::apply_scale): Move sanity check.
	* tree-inline.c (copy_bb): Always scale.
	(copy_cfg_body): Likewise.

From-SVN: r254452
parent 454f8b2b
2017-11-06 Jan Hubicka <hubicka@ucw.cz>
PR bootstrap/82832
* ipa-inline-transform.c (update_noncloned_frequencies): Always
scale.
(inline_transform): Likewise.
* predict.c (counts_to_freqs): Remove useless conditional.
* profile-count.h (profile_count::apply_scale): Move sanity check.
* tree-inline.c (copy_bb): Always scale.
(copy_cfg_body): Likewise.
2017-11-06 Christophe Lyon <christophe.lyon@linaro.org>
PR target/67591
......@@ -59,7 +59,18 @@ update_noncloned_frequencies (struct cgraph_node *node,
profile_count den)
{
struct cgraph_edge *e;
bool scale = (num == profile_count::zero () || den > 0);
/* We always must scale to be sure counters end up compatible.
If den is zero, just force it nonzero and hope for reasonable
approximation.
When num is forced nonzero, also update den, so we do not scale profile
to 0. */
if (!(num == den)
&& !(den.force_nonzero () == den))
{
den = den.force_nonzero ();
num = num.force_nonzero ();
}
/* We do not want to ignore high loop nest after freq drops to 0. */
if (!freq_scale)
......@@ -71,19 +82,16 @@ update_noncloned_frequencies (struct cgraph_node *node,
e->frequency = CGRAPH_FREQ_MAX;
if (!e->inline_failed)
update_noncloned_frequencies (e->callee, freq_scale, num, den);
if (scale)
e->count = e->count.apply_scale (num, den);
e->count = e->count.apply_scale (num, den);
}
for (e = node->indirect_calls; e; e = e->next_callee)
{
e->frequency = e->frequency * (gcov_type) freq_scale / CGRAPH_FREQ_BASE;
if (e->frequency > CGRAPH_FREQ_MAX)
e->frequency = CGRAPH_FREQ_MAX;
if (scale)
e->count = e->count.apply_scale (num, den);
e->count = e->count.apply_scale (num, den);
}
if (scale)
node->count = node->count.apply_scale (num, den);
node->count = node->count.apply_scale (num, den);
}
/* We removed or are going to remove the last call to NODE.
......@@ -692,7 +700,10 @@ inline_transform (struct cgraph_node *node)
basic_block bb;
FOR_ALL_BB_FN (bb, cfun)
bb->count = bb->count.apply_scale (num, den);
if (num == profile_count::zero ())
bb->count = bb->count.global0 ();
else
bb->count = bb->count.apply_scale (num, den);
ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
}
todo = optimize_inline_calls (current_function_decl);
......
......@@ -3324,8 +3324,7 @@ counts_to_freqs (void)
basic_block bb;
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR_FOR_FN (cfun), NULL, next_bb)
if (!(bb->count < true_count_max))
true_count_max = true_count_max.max (bb->count);
true_count_max = true_count_max.max (bb->count);
cfun->cfg->count_max = true_count_max;
......
......@@ -949,9 +949,9 @@ public:
return num;
if (!initialized_p () || !num.initialized_p () || !den.initialized_p ())
return profile_count::uninitialized ();
gcc_checking_assert (den.m_val);
if (num == den)
return *this;
gcc_checking_assert (den.m_val);
profile_count ret;
uint64_t val;
......
......@@ -1770,8 +1770,18 @@ copy_bb (copy_body_data *id, basic_block bb,
basic_block copy_basic_block;
tree decl;
basic_block prev;
bool scale = !num.initialized_p ()
|| (den.nonzero_p () || num == profile_count::zero ());
/* We always must scale to be sure counters end up compatible.
If den is zero, just force it nonzero and hope for reasonable
approximation.
When num is forced nonzero, also update den, so we do not scale profile
to 0. */
if (!(num == den)
&& !(den.force_nonzero () == den))
{
den = den.force_nonzero ();
num = num.force_nonzero ();
}
/* Search for previous copied basic block. */
prev = bb->prev_bb;
......@@ -1781,10 +1791,7 @@ copy_bb (copy_body_data *id, basic_block bb,
/* create_basic_block() will append every new block to
basic_block_info automatically. */
copy_basic_block = create_basic_block (NULL, (basic_block) prev->aux);
if (scale)
copy_basic_block->count = bb->count.apply_scale (num, den);
else if (num.initialized_p ())
copy_basic_block->count = bb->count;
copy_basic_block->count = bb->count.apply_scale (num, den);
copy_gsi = gsi_start_bb (copy_basic_block);
......@@ -2691,6 +2698,18 @@ copy_cfg_body (copy_body_data * id, profile_count,
profile_count den = ENTRY_BLOCK_PTR_FOR_FN (src_cfun)->count;
profile_count num = entry_block_map->count;
/* We always must scale to be sure counters end up compatible.
If den is zero, just force it nonzero and hope for reasonable
approximation.
When num is forced nonzero, also update den, so we do not scale profile
to 0. */
if (!(num == den)
&& !(den.force_nonzero () == den))
{
den = den.force_nonzero ();
num = num.force_nonzero ();
}
cfun_to_copy = id->src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
/* Register specific tree functions. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment