aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2017-11-06 14:45:41 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2017-11-06 13:45:41 +0000
commit8e7d1486f6635614f97e26f27ed8033f647ef6f2 (patch)
tree48517ad3ae0dc37801c611131c9093c4b7475294 /gcc
parent454f8b2b0c6f9645b3df6be98efe2ca520f2ce82 (diff)
downloadgcc-8e7d1486f6635614f97e26f27ed8033f647ef6f2.zip
gcc-8e7d1486f6635614f97e26f27ed8033f647ef6f2.tar.gz
gcc-8e7d1486f6635614f97e26f27ed8033f647ef6f2.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/ipa-inline-transform.c27
-rw-r--r--gcc/predict.c3
-rw-r--r--gcc/profile-count.h2
-rw-r--r--gcc/tree-inline.c31
5 files changed, 57 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b21c5fc..26afa77 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+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
diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c
index 886e8ed..e367df7 100644
--- a/gcc/ipa-inline-transform.c
+++ b/gcc/ipa-inline-transform.c
@@ -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);
diff --git a/gcc/predict.c b/gcc/predict.c
index cf42ccb..0fd2b72 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -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;
diff --git a/gcc/profile-count.h b/gcc/profile-count.h
index d793d11..f16bbcb 100644
--- a/gcc/profile-count.h
+++ b/gcc/profile-count.h
@@ -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;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 040799c..7ef1072 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -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. */