Commit e3fe0070 by Jan Hubicka

libgcov: Fix merging of topn [PR92924]

	PR tree-optimization/92924
	* libgcov-merge.c (merge_topn_values_set): Fix merging.
parent ad8e2415
...@@ -112,9 +112,11 @@ merge_topn_values_set (gcov_type *counters) ...@@ -112,9 +112,11 @@ merge_topn_values_set (gcov_type *counters)
for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++) for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
{ {
if (read_counters[2 * i + 1] == 0) if (read_counters[2 * i + 1] == 0)
return; continue;
unsigned j; unsigned j;
int slot = -1;
for (j = 0; j < GCOV_TOPN_VALUES; j++) for (j = 0; j < GCOV_TOPN_VALUES; j++)
{ {
if (counters[2 * j] == read_counters[2 * i]) if (counters[2 * j] == read_counters[2 * i])
...@@ -123,20 +125,25 @@ merge_topn_values_set (gcov_type *counters) ...@@ -123,20 +125,25 @@ merge_topn_values_set (gcov_type *counters)
break; break;
} }
else if (counters[2 * j + 1] == 0) else if (counters[2 * j + 1] == 0)
{ slot = j;
counters[2 * j] += read_counters[2 * i];
counters[2 * j + 1] += read_counters[2 * i + 1];
break;
}
} }
/* We haven't found a slot, bail out. */
if (j == GCOV_TOPN_VALUES) if (j == GCOV_TOPN_VALUES)
{ {
if (slot > 0)
{
/* If we found empty slot, add the value. */
counters[2 * slot] = read_counters[2 * i];
counters[2 * slot + 1] = read_counters[2 * i + 1];
}
else
{
/* We haven't found a slot, bail out. */
counters[1] = -1; counters[1] = -1;
return; return;
} }
} }
}
} }
/* The profile merging function for choosing the most common value. /* The profile merging function for choosing the most common value.
......
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