On Wed, Jan 8, 2014 at 2:20 PM, Rong Xu <x...@google.com> wrote: > On Wed, Dec 18, 2013 at 9:28 AM, Xinliang David Li <davi...@google.com> wrote: >>>> >>>> #ifdef L_gcov_merge_ior >>>> /* The profile merging function that just adds the counters. It is given >>>> - an array COUNTERS of N_COUNTERS old counters and it reads the same >>>> number >>>> - of counters from the gcov file. */ >>>> + an array COUNTERS of N_COUNTERS old counters. >>>> + When SRC==NULL, it reads the same number of counters from the gcov >>>> file. >>>> + Otherwise, it reads from SRC array. */ >>>> void >>>> -__gcov_merge_ior (gcov_type *counters, unsigned n_counters) >>>> +__gcov_merge_ior (gcov_type *counters, unsigned n_counters, >>>> + gcov_type *src, unsigned w __attribute__ ((unused))) >>> >>> So the new in-memory variants are introduced for merging tool, while libgcc >>> use gcov_read_counter >>> interface? >>> Perhaps we can actually just duplicate the functions to avoid runtime to do >>> all the scalling >>> and in_mem tests it won't need? >> >> >> I thought about this one a little. How about making the interface >> change conditionally, but still share the implementation? The merge >> function bodies mostly remain unchanged and there is no runtime >> penalty for libgcov. The new macros can be shared across most of the >> mergers. >> >> #ifdef IN_PREOFILE_TOOL >> #define GCOV_MERGE_EXTRA_ARGS gcov_type *src, unsigned w >> #define GCOV_READ_COUNTER *(src++) * w >> #else >> #define GCOV_MERGE_EXTRA_ARGS >> #define GCOV_READ_COUNTER gcov_read_counter () >> #endif >> >> __gcov_merge_add (gcov_type *counters, unsigned n_counters, >> GCOV_MERGE_EXTRA_ARGS) >> { >> >> for (; n_counters; counters++, n_counters--) >> { >> *counters += GCOV_READ_COUNTER ; >> } >> >> } >> >> thanks, > > Personally I don't think the run time test of in_mem will cause any > issue. This is in profile dumping, why don't we care a few more cycle > heres? it won't pollute the profile. > > If you really don't like that, we can use the above approach, or I can > hide the logic in gcov_read_counter(), i.e. overload > gcov_read_counter() in profile_tool. For that, I will need a new > global variable SRC and set it before calling the merge function. > I would prefer to keep weight in _gcov_merge_* argument list. > > What do you think?
or perhaps just define an inline wrapper function to read counter. This wrapper function takes src as input. if src is NULL, call gcov_read_counter. David > > -Rong > >> >> David >> >>> >>> I would suggest going with libgcov.h changes and clenaups first, with >>> interface changes next >>> and the gcov-tool is probably quite obvious at the end? >>> Do you think you can split the patch this way? >>> >>> Thanks and sorry for taking long to review. I should have more time again >>> now. >>> Honza