On Wed, Feb 17, 2021 at 2:16 PM Martin Liška <mli...@suse.cz> wrote:
>
> On 2/17/21 9:36 AM, Martin Liška wrote:
> > I'll write it even more robust...
>
> This is more elegant approach I've just tested on the instrumented clang.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?

Isn't it still too complicated?  We're asked to write N counters so why
don't we just write N counters?  Thus, you already do

       for (struct gcov_kvp *node = (struct gcov_kvp *)(intptr_t)start;
-          node != NULL; node = node->next)
+          node != NULL; node = node->next, j++)
        {
          gcov_write_counter (node->value);
          gcov_write_counter (node->count);
+
+         /* Stop when we reach expected number of items.  */
+         if (j + 1 == list_sizes[i])
+           break;
        }

why isn't this then only thing you need (just using pair_count as gathered
previously)?  And just count pair_count to zero as IV?  No need to
do the node != NULL check?

Note architectures with less nice memory ordering guarantees might
eventually see partially updated pointers and counters so I think
we at least want atomic_read ()s of the values with the weakest
consistency possible.  (but that can be done as followup if we agree on that)

Richard.

> Thanks,
> Martin

Reply via email to