diff options
Diffstat (limited to 'gcc/profile-count.cc')
-rw-r--r-- | gcc/profile-count.cc | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/profile-count.cc b/gcc/profile-count.cc index 2d9c778..e857cdd 100644 --- a/gcc/profile-count.cc +++ b/gcc/profile-count.cc @@ -94,9 +94,16 @@ profile_count::dump (FILE *f, struct function *fun) const else if (fun && initialized_p () && fun->cfg && ENTRY_BLOCK_PTR_FOR_FN (fun)->count.initialized_p ()) - fprintf (f, "%" PRId64 " (%s, freq %.4f)", m_val, - profile_quality_display_names[m_quality], - to_sreal_scale (ENTRY_BLOCK_PTR_FOR_FN (fun)->count).to_double ()); + { + if (compatible_p (ENTRY_BLOCK_PTR_FOR_FN (fun)->count)) + fprintf (f, "%" PRId64 " (%s, freq %.4f)", m_val, + profile_quality_display_names[m_quality], + to_sreal_scale + (ENTRY_BLOCK_PTR_FOR_FN (fun)->count).to_double ()); + else + fprintf (f, "%" PRId64 " (%s, incompatible with entry block count)", + m_val, profile_quality_display_names[m_quality]); + } else fprintf (f, "%" PRId64 " (%s)", m_val, profile_quality_display_names[m_quality]); @@ -344,6 +351,10 @@ profile_count::to_sreal_scale (profile_count in, bool *known) const return 1; if (!in.m_val) return m_val * 4; + /* Auto-FDO 0 really just means that we have no samples. + Treat it as small non-zero frequency. */ + if (!m_val && quality () == AFDO) + return (sreal)1 / (sreal)in.m_val; return (sreal)m_val / (sreal)in.m_val; } @@ -398,7 +409,7 @@ profile_count::combine_with_ipa_count (profile_count ipa) return this->global0adjusted (); } -/* Sae as profile_count::combine_with_ipa_count but within function with count +/* Same as profile_count::combine_with_ipa_count but within function with count IPA2. */ profile_count profile_count::combine_with_ipa_count_within (profile_count ipa, @@ -410,7 +421,16 @@ profile_count::combine_with_ipa_count_within (profile_count ipa, if (ipa2.ipa () == ipa2 && ipa.initialized_p ()) ret = ipa; else - ret = combine_with_ipa_count (ipa); + { + /* For inconsistent profiles we may end up having ipa2 of GLOBAL0 + while ipa is non-zero (i.e. non-zero IPA counters within function + executed 0 times). Be sure we produce GLOBAL0 as well + so counters remain compatible. */ + if (ipa.nonzero_p () + && ipa2.ipa ().initialized_p ()) + ipa = ipa2.ipa (); + ret = combine_with_ipa_count (ipa); + } gcc_checking_assert (ret.compatible_p (ipa2)); return ret; } |