Skip to content

Commit

Permalink
libgcov: Fix merging of topn [PR92924]
Browse files Browse the repository at this point in the history
	PR tree-optimization/92924
	* libgcov-merge.c (merge_topn_values_set): Fix merging.
  • Loading branch information
Jan Hubicka committed Jan 24, 2020
1 parent ad8e241 commit e3fe007
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions libgcc/libgcov-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ merge_topn_values_set (gcov_type *counters)
for (unsigned i = 0; i < GCOV_TOPN_VALUES; i++)
{
if (read_counters[2 * i + 1] == 0)
return;
continue;

unsigned j;
int slot = -1;

for (j = 0; j < GCOV_TOPN_VALUES; j++)
{
if (counters[2 * j] == read_counters[2 * i])
Expand All @@ -123,18 +125,23 @@ merge_topn_values_set (gcov_type *counters)
break;
}
else if (counters[2 * j + 1] == 0)
{
counters[2 * j] += read_counters[2 * i];
counters[2 * j + 1] += read_counters[2 * i + 1];
break;
}
slot = j;
}

/* We haven't found a slot, bail out. */
if (j == GCOV_TOPN_VALUES)
{
counters[1] = -1;
return;
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;
return;
}
}
}
}
Expand Down

0 comments on commit e3fe007

Please sign in to comment.