Commit db51f624 by Jan Hubicka Committed by Jan Hubicka

profile-count.c (profile_count::to_cgraph_frequency, [...]): Check for compaibility of counts.


	* profile-count.c (profile_count::to_cgraph_frequency,
	profile_count::to_sreal_scale): Check for compaibility of counts.
	* profile-count.h (compatible_p): Make public; add checking for
	global0 versus global types.
	* cgraph.c (cgraph_node::verify_node): Verify count compatibility.

From-SVN: r278835
parent 60178a32
2019-11-29 Jan Hubicka <hubicka@ucw.cz>
* profile-count.c (profile_count::to_cgraph_frequency,
profile_count::to_sreal_scale): Check for compaibility of counts.
* profile-count.h (compatible_p): Make public; add checking for
global0 versus global types.
* cgraph.c (cgraph_node::verify_node): Verify count compatibility.
2019-11-29 Richard Biener <rguenther@suse.de> 2019-11-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/92715 PR tree-optimization/92715
...@@ -3061,6 +3061,13 @@ cgraph_node::verify_node (void) ...@@ -3061,6 +3061,13 @@ cgraph_node::verify_node (void)
error ("inline clone in same comdat group list"); error ("inline clone in same comdat group list");
error_found = true; error_found = true;
} }
if (inlined_to && !count.compatible_p (inlined_to->count))
{
error ("inline clone count is not compatible");
count.debug ();
inlined_to->count.debug ();
error_found = true;
}
if (!definition && !in_other_partition && local) if (!definition && !in_other_partition && local)
{ {
error ("local symbols must be defined"); error ("local symbols must be defined");
...@@ -3089,6 +3096,13 @@ cgraph_node::verify_node (void) ...@@ -3089,6 +3096,13 @@ cgraph_node::verify_node (void)
identifier_to_locale (e->caller->name ())); identifier_to_locale (e->caller->name ()));
error_found = true; error_found = true;
} }
if (!e->count.compatible_p (count))
{
error ("edge count is not compatible with function count");
e->count.debug ();
count.debug ();
error_found = true;
}
if (!e->indirect_unknown_callee if (!e->indirect_unknown_callee
|| !e->indirect_info) || !e->indirect_info)
{ {
...@@ -3137,6 +3151,13 @@ cgraph_node::verify_node (void) ...@@ -3137,6 +3151,13 @@ cgraph_node::verify_node (void)
{ {
if (e->verify_count ()) if (e->verify_count ())
error_found = true; error_found = true;
if (!e->count.compatible_p (count))
{
error ("edge count is not compatible with function count");
e->count.debug ();
count.debug ();
error_found = true;
}
if (gimple_has_body_p (e->caller->decl) if (gimple_has_body_p (e->caller->decl)
&& !e->caller->inlined_to && !e->caller->inlined_to
&& !e->speculative && !e->speculative
......
...@@ -291,6 +291,7 @@ profile_count::to_cgraph_frequency (profile_count entry_bb_count) const ...@@ -291,6 +291,7 @@ profile_count::to_cgraph_frequency (profile_count entry_bb_count) const
return 0; return 0;
gcc_checking_assert (entry_bb_count.initialized_p ()); gcc_checking_assert (entry_bb_count.initialized_p ());
uint64_t scale; uint64_t scale;
gcc_checking_assert (compatible_p (entry_bb_count));
if (!safe_scale_64bit (!entry_bb_count.m_val ? m_val + 1 : m_val, if (!safe_scale_64bit (!entry_bb_count.m_val ? m_val + 1 : m_val,
CGRAPH_FREQ_BASE, MAX (1, entry_bb_count.m_val), &scale)) CGRAPH_FREQ_BASE, MAX (1, entry_bb_count.m_val), &scale))
return CGRAPH_FREQ_MAX; return CGRAPH_FREQ_MAX;
...@@ -328,6 +329,7 @@ profile_count::to_sreal_scale (profile_count in, bool *known) const ...@@ -328,6 +329,7 @@ profile_count::to_sreal_scale (profile_count in, bool *known) const
return 0; return 0;
if (m_val == in.m_val) if (m_val == in.m_val)
return 1; return 1;
gcc_checking_assert (compatible_p (in));
if (!in.m_val) if (!in.m_val)
{ {
......
...@@ -700,6 +700,7 @@ private: ...@@ -700,6 +700,7 @@ private:
uint64_t UINT64_BIT_FIELD_ALIGN m_val : n_bits; uint64_t UINT64_BIT_FIELD_ALIGN m_val : n_bits;
#undef UINT64_BIT_FIELD_ALIGN #undef UINT64_BIT_FIELD_ALIGN
enum profile_quality m_quality : 3; enum profile_quality m_quality : 3;
public:
/* Return true if both values can meaningfully appear in single function /* Return true if both values can meaningfully appear in single function
body. We have either all counters in function local or global, otherwise body. We have either all counters in function local or global, otherwise
...@@ -711,9 +712,18 @@ private: ...@@ -711,9 +712,18 @@ private:
if (*this == zero () if (*this == zero ()
|| other == zero ()) || other == zero ())
return true; return true;
/* Do not allow nonzero global profile together with local guesses
that are globally0. */
if (ipa ().nonzero_p ()
&& !(other.ipa () == other))
return false;
if (other.ipa ().nonzero_p ()
&& !(ipa () == *this))
return false;
return ipa_p () == other.ipa_p (); return ipa_p () == other.ipa_p ();
} }
public:
/* Used for counters which are expected to be never executed. */ /* Used for counters which are expected to be never executed. */
static profile_count zero () static profile_count 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