Commit 03105885 by Martin Liska Committed by Martin Liska

Add vertical spacing in order to separate functions.

2019-05-20  Martin Liska  <mliska@suse.cz>

	* profile-count.c: Add vertical spacing in order
	to separate functions.
	* profile-count.h: Likewise.

From-SVN: r271399
parent a4c3f08d
2019-05-20 Martin Liska <mliska@suse.cz>
* profile-count.c: Add vertical spacing in order
to separate functions.
* profile-count.h: Likewise.
2019-05-20 Martin Liska <mliska@suse.cz>
* profile-count.h: Do not use full qualified
names if possible.
* profile-count.c (profile_count::to_frequency): Likewise.
......
......@@ -353,6 +353,7 @@ profile_count::adjust_for_ipa_scaling (profile_count *num,
if it is nonzero, not changing anything if IPA is uninitialized
and if IPA is zero, turning THIS into corresponding local profile with
global0. */
profile_count
profile_count::combine_with_ipa_count (profile_count ipa)
{
......@@ -369,6 +370,7 @@ profile_count::combine_with_ipa_count (profile_count ipa)
/* The profiling runtime uses gcov_type, which is usually 64bit integer.
Conversions back and forth are used to read the coverage and get it
into internal representation. */
profile_count
profile_count::from_gcov_type (gcov_type v, profile_quality quality)
{
......@@ -383,7 +385,6 @@ profile_count::from_gcov_type (gcov_type v, profile_quality quality)
return ret;
}
/* COUNT1 times event happens with *THIS probability, COUNT2 times OTHER
happens with COUNT2 probablity. Return probablity that either *THIS or
OTHER happens. */
......
......@@ -29,11 +29,13 @@ class profile_count;
enum profile_quality {
/* Uninitialized value. */
UNINITIALIZED_PROFILE,
/* Profile is based on static branch prediction heuristics and may
or may not match reality. It is local to function and cannot be compared
inter-procedurally. Never used by probabilities (they are always local).
*/
GUESSED_LOCAL,
/* Profile was read by feedback and was 0, we used local heuristics to guess
better. This is the case of functions not run in profile fedback.
Never used by probabilities. */
......@@ -48,12 +50,15 @@ enum profile_quality {
with feedback and propagated from that).
Never used by probablities. */
GUESSED,
/* Profile was determined by autofdo. */
AFDO,
/* Profile was originally based on feedback but it was adjusted
by code duplicating optimization. It may not precisely reflect the
particular code path. */
ADJUSTED,
/* Profile was read from profile feedback or determined by accurate static
method. */
PRECISE
......@@ -167,6 +172,7 @@ public:
ret.m_quality = PRECISE;
return ret;
}
static profile_probability guessed_never ()
{
profile_probability ret;
......@@ -174,6 +180,7 @@ public:
ret.m_quality = GUESSED;
return ret;
}
static profile_probability very_unlikely ()
{
/* Be consistent with PROB_VERY_UNLIKELY in predict.h. */
......@@ -181,6 +188,7 @@ public:
r.m_val--;
return r;
}
static profile_probability unlikely ()
{
/* Be consistent with PROB_VERY_LIKELY in predict.h. */
......@@ -188,18 +196,22 @@ public:
r.m_val--;
return r;
}
static profile_probability even ()
{
return guessed_always ().apply_scale (1, 2);
}
static profile_probability very_likely ()
{
return always () - very_unlikely ();
}
static profile_probability likely ()
{
return always () - unlikely ();
}
static profile_probability guessed_always ()
{
profile_probability ret;
......@@ -207,6 +219,7 @@ public:
ret.m_quality = GUESSED;
return ret;
}
static profile_probability always ()
{
profile_probability ret;
......@@ -214,6 +227,7 @@ public:
ret.m_quality = PRECISE;
return ret;
}
/* Probabilities which has not been initialized. Either because
initialization did not happen yet or because profile is unknown. */
static profile_probability uninitialized ()
......@@ -224,12 +238,12 @@ public:
return c;
}
/* Return true if value has been initialized. */
bool initialized_p () const
{
return m_val != uninitialized_probability;
}
/* Return true if value can be trusted. */
bool reliable_p () const
{
......@@ -246,6 +260,7 @@ public:
ret.m_quality = GUESSED;
return ret;
}
int to_reg_br_prob_base () const
{
gcc_checking_assert (initialized_p ());
......@@ -260,6 +275,7 @@ public:
ret.m_quality = (enum profile_quality)(v & 7);
return ret;
}
int to_reg_br_prob_note () const
{
gcc_checking_assert (initialized_p ());
......@@ -292,6 +308,7 @@ public:
{
return m_val == other.m_val && m_quality == other.m_quality;
}
profile_probability operator+ (const profile_probability &other) const
{
if (other == never ())
......@@ -306,6 +323,7 @@ public:
ret.m_quality = MIN (m_quality, other.m_quality);
return ret;
}
profile_probability &operator+= (const profile_probability &other)
{
if (other == never ())
......@@ -324,6 +342,7 @@ public:
}
return *this;
}
profile_probability operator- (const profile_probability &other) const
{
if (*this == never ()
......@@ -336,6 +355,7 @@ public:
ret.m_quality = MIN (m_quality, other.m_quality);
return ret;
}
profile_probability &operator-= (const profile_probability &other)
{
if (*this == never ()
......@@ -350,6 +370,7 @@ public:
}
return *this;
}
profile_probability operator* (const profile_probability &other) const
{
if (*this == never ()
......@@ -362,6 +383,7 @@ public:
ret.m_quality = MIN (MIN (m_quality, other.m_quality), ADJUSTED);
return ret;
}
profile_probability &operator*= (const profile_probability &other)
{
if (*this == never ()
......@@ -376,6 +398,7 @@ public:
}
return *this;
}
profile_probability operator/ (const profile_probability &other) const
{
if (*this == never ())
......@@ -403,6 +426,7 @@ public:
ret.m_quality = MIN (MIN (m_quality, other.m_quality), ADJUSTED);
return ret;
}
profile_probability &operator/= (const profile_probability &other)
{
if (*this == never ())
......@@ -522,7 +546,6 @@ public:
noreturn heuristic that is only one giving probability over 99% or bellow
1%. In future we might want to propagate reliability information across the
CFG if we find this information useful on multiple places. */
bool probably_reliable_p () const
{
if (m_quality >= ADJUSTED)
......@@ -550,6 +573,7 @@ public:
{
return initialized_p () && other.initialized_p () && m_val < other.m_val;
}
bool operator> (const profile_probability &other) const
{
return initialized_p () && other.initialized_p () && m_val > other.m_val;
......@@ -559,6 +583,7 @@ public:
{
return initialized_p () && other.initialized_p () && m_val <= other.m_val;
}
bool operator>= (const profile_probability &other) const
{
return initialized_p () && other.initialized_p () && m_val >= other.m_val;
......@@ -578,8 +603,10 @@ public:
/* Return true if THIS is known to differ significantly from OTHER. */
bool differs_from_p (profile_probability other) const;
/* Return if difference is greater than 50%. */
bool differs_lot_from_p (profile_probability other) const;
/* COUNT1 times event happens with *THIS probability, COUNT2 times OTHER
happens with COUNT2 probablity. Return probablity that either *THIS or
OTHER happens. */
......@@ -692,6 +719,7 @@ public:
{
return from_gcov_type (0);
}
static profile_count adjusted_zero ()
{
profile_count c;
......@@ -699,6 +727,7 @@ public:
c.m_quality = ADJUSTED;
return c;
}
static profile_count guessed_zero ()
{
profile_count c;
......@@ -706,10 +735,12 @@ public:
c.m_quality = GUESSED;
return c;
}
static profile_count one ()
{
return from_gcov_type (1);
}
/* Value of counters which has not been initialized. Either because
initialization did not happen yet or because profile is unknown. */
static profile_count uninitialized ()
......@@ -732,16 +763,19 @@ public:
{
return m_val != uninitialized_count;
}
/* Return true if value can be trusted. */
bool reliable_p () const
{
return m_quality >= ADJUSTED;
}
/* Return true if vlaue can be operated inter-procedurally. */
bool ipa_p () const
{
return !initialized_p () || m_quality >= GUESSED_GLOBAL0;
}
/* Return true if quality of profile is precise. */
bool precise_p () const
{
......@@ -784,6 +818,7 @@ public:
{
return m_val == other.m_val && m_quality == other.m_quality;
}
profile_count operator+ (const profile_count &other) const
{
if (other == zero ())
......@@ -799,6 +834,7 @@ public:
ret.m_quality = MIN (m_quality, other.m_quality);
return ret;
}
profile_count &operator+= (const profile_count &other)
{
if (other == zero ())
......@@ -818,6 +854,7 @@ public:
}
return *this;
}
profile_count operator- (const profile_count &other) const
{
if (*this == zero () || other == zero ())
......@@ -830,6 +867,7 @@ public:
ret.m_quality = MIN (m_quality, other.m_quality);
return ret;
}
profile_count &operator-= (const profile_count &other)
{
if (*this == zero () || other == zero ())
......@@ -865,6 +903,7 @@ public:
gcc_checking_assert (compatible_p (other));
return m_val < other.m_val;
}
bool operator> (const profile_count &other) const
{
if (!initialized_p () || !other.initialized_p ())
......@@ -876,12 +915,14 @@ public:
gcc_checking_assert (compatible_p (other));
return initialized_p () && other.initialized_p () && m_val > other.m_val;
}
bool operator< (const gcov_type other) const
{
gcc_checking_assert (ipa_p ());
gcc_checking_assert (other >= 0);
return initialized_p () && m_val < (uint64_t) other;
}
bool operator> (const gcov_type other) const
{
gcc_checking_assert (ipa_p ());
......@@ -900,6 +941,7 @@ public:
gcc_checking_assert (compatible_p (other));
return m_val <= other.m_val;
}
bool operator>= (const profile_count &other) const
{
if (!initialized_p () || !other.initialized_p ())
......@@ -911,18 +953,21 @@ public:
gcc_checking_assert (compatible_p (other));
return m_val >= other.m_val;
}
bool operator<= (const gcov_type other) const
{
gcc_checking_assert (ipa_p ());
gcc_checking_assert (other >= 0);
return initialized_p () && m_val <= (uint64_t) other;
}
bool operator>= (const gcov_type other) const
{
gcc_checking_assert (ipa_p ());
gcc_checking_assert (other >= 0);
return initialized_p () && m_val >= (uint64_t) other;
}
/* Return true when value is not zero and can be used for scaling.
This is different from *this > 0 because that requires counter to
be IPA. */
......@@ -994,6 +1039,7 @@ public:
ret.m_quality = MIN (m_quality, prob.m_quality);
return ret;
}
/* Return *THIS * NUM / DEN. */
profile_count apply_scale (int64_t num, int64_t den) const
{
......@@ -1010,6 +1056,7 @@ public:
ret.m_quality = MIN (m_quality, ADJUSTED);
return ret;
}
profile_count apply_scale (profile_count num, profile_count den) const
{
if (*this == zero ())
......
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