/* Use IPA count and if it s not available appy local heuristics. */
if (c.initialized_p ())
- return maybe_hot_count_p (NULL, c * scale);
+ {
+ /* A special case; AFDO zero means that function may quite possibly
+ be executed few times per execution. If scale is large, we still
+ want to consider the call hot. */
+ if (c.quality () == AFDO)
+ c = c.force_nonzero ();
+ return maybe_hot_count_p (NULL, c * scale);
+ }
if (!count.initialized_p ())
return true;
cgraph_node *where = caller->inlined_to ? caller->inlined_to : caller;
if (e->count.ipa ().nonzero_p ())
return true;
/* If local (possibly guseed or adjusted 0 profile) claims edge is
- not executed, do not propagate. */
- if (e->count.initialized_p () && !e->count.nonzero_p ())
+ not executed, do not propagate.
+ Do not trust AFDO since branch needs to be executed multiple
+ time to count while we want to propagate even call called
+ once during the train run if callee is important. */
+ if (e->count.initialized_p () && !e->count.nonzero_p ()
+ && e->count.quality () != AFDO)
return false;
/* If we have zero IPA profile, still consider edge for cloning
in case we do partial training. */
/* Scaling to zero is always zero. */
if (*num == zero ())
return;
- /* If den is non-zero we are safe. */
- if (den->force_nonzero () == *den)
+ /* If den is non-zero we are safe.
+ However take care of zeros in AFDO profiles since
+ they simply means that no useful samples were collected.
+ Called function still may contain important loop. */
+ if (den->force_nonzero () == *den
+ && num->quality () != AFDO)
return;
/* Force both to non-zero so we do not push profiles to 0 when
both num == 0 and den == 0. */
profile_count
profile_count::from_gcov_type (gcov_type v, profile_quality quality)
- {
- profile_count ret;
- gcc_checking_assert (v >= 0);
- if (dump_file && v >= (gcov_type)max_count)
- fprintf (dump_file,
- "Capping gcov count %" PRId64 " to max_count %" PRId64 "\n",
- (int64_t) v, (int64_t) max_count);
- ret.m_val = MIN (v, (gcov_type)max_count);
- ret.m_quality = quality;
- return ret;
- }
+{
+ profile_count ret;
+ gcc_checking_assert (v >= 0);
+ if (dump_file && v >= (gcov_type)max_count)
+ fprintf (dump_file,
+ "Capping gcov count %" PRId64 " to max_count %" PRId64 "\n",
+ (int64_t) v, (int64_t) max_count);
+ ret.m_val = MIN (v, (gcov_type)max_count);
+ ret.m_quality = quality;
+ return ret;
+}
/* COUNT1 times event happens with *THIS probability, COUNT2 times OTHER
happens with COUNT2 probability. Return probability that either *THIS or