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