Skip to content
Snippets Groups Projects
  1. Jan 03, 2024
  2. Dec 01, 2023
  3. Nov 21, 2023
    • Jakub Jelinek's avatar
      gcov: Formatting fixes · 69813540
      Jakub Jelinek authored
      I've noticed the r14-5579 commit introduced some formatting issues,
      this patch fixes what I saw.
      
      2023-11-21  Jakub Jelinek  <jakub@redhat.com>
      
      gcc/
      	* tree-profile.cc (gen_counter_update, tree_profiling): Formatting
      	fixes.
      libgcc/
      	* libgcov.h (GCOV_SUPPORTS_ATOMIC): Formatting fixes.
      69813540
  4. Nov 18, 2023
    • Sebastian Huber's avatar
      gcov: Improve -fprofile-update=atomic · 20a3c74c
      Sebastian Huber authored
      The code coverage support uses counters to determine which edges in the control
      flow graph were executed.  If a counter overflows, then the code coverage
      information is invalid.  Therefore the counter type should be a 64-bit integer.
      In multi-threaded applications, it is important that the counter increments are
      atomic.  This is not the case by default.  The user can enable atomic counter
      increments through the -fprofile-update=atomic and
      -fprofile-update=prefer-atomic options.
      
      If the target supports 64-bit atomic operations, then everything is fine.  If
      not and -fprofile-update=prefer-atomic was chosen by the user, then non-atomic
      counter increments will be used.  However, if the target does not support the
      required atomic operations and -fprofile-atomic=update was chosen by the user,
      then a warning was issued and as a forced fallback to non-atomic operations was
      done.  This is probably not what a user wants.  There is still hardware on the
      market which does not have atomic operations and is used for multi-threaded
      applications.  A user which selects -fprofile-update=atomic wants consistent
      code coverage data and not random data.
      
      This patch removes the fallback to non-atomic operations for
      -fprofile-update=atomic the target platform supports libatomic.  To
      mitigate potential performance issues an optimization for systems which
      only support 32-bit atomic operations is provided.  Here, the edge
      counter increments are done like this:
      
        low = __atomic_add_fetch_4 (&counter.low, 1, MEMMODEL_RELAXED);
        high_inc = low == 0 ? 1 : 0;
        __atomic_add_fetch_4 (&counter.high, high_inc, MEMMODEL_RELAXED);
      
      In gimple_gen_time_profiler() this split operation cannot be used, since the
      updated counter value is also required.  Here, a library call is emitted.  This
      is not a performance issue since the update is only done if counters[0] == 0.
      
      gcc/c-family/ChangeLog:
      
      	* c-cppbuiltin.cc (c_cpp_builtins):  Define
      	__LIBGCC_HAVE_LIBATOMIC for libgcov.
      
      gcc/ChangeLog:
      
      	* doc/invoke.texi (-fprofile-update): Clarify default method.  Document
      	the atomic method behaviour.
      	* tree-profile.cc (enum counter_update_method): New.
      	(counter_update): Likewise.
      	(gen_counter_update): Use counter_update_method.  Split the
      	atomic counter update in two 32-bit atomic operations if
      	necessary.
      	(tree_profiling): Select counter_update_method.
      
      libgcc/ChangeLog:
      
      	* libgcov.h (GCOV_SUPPORTS_ATOMIC): Always define it.
      	Set it also to 1, if __LIBGCC_HAVE_LIBATOMIC is defined.
      20a3c74c
    • Sebastian Huber's avatar
      gcov: Remove TARGET_GCOV_TYPE_SIZE target hook · 23d33775
      Sebastian Huber authored
      This reverts commit 8cdcea51.
      
      gcc/c-family/ChangeLog:
      
      	* c-cppbuiltin.cc (c_cpp_builtins): Do not define
      	__LIBGCC_GCOV_TYPE_SIZE.
      
      gcc/ChangeLog:
      
      	* config/sparc/rtemself.h (SPARC_GCOV_TYPE_SIZE): Remove.
      	* config/sparc/sparc.cc (sparc_gcov_type_size): Likewise.
      	(TARGET_GCOV_TYPE_SIZE): Likewise.
      	* coverage.cc (get_gcov_type): Use LONG_LONG_TYPE_SIZE instead
      	of removed target hook.
      	* doc/tm.texi: Regenerate.
      	* doc/tm.texi.in (TARGET_GCOV_TYPE_SIZE): Remove.
      	* target.def: Likewise.
      	* targhooks.cc (default_gcov_type_size): Likewise.
      	* targhooks.h (default_gcov_type_size): Likewise.
      
      libgcc/ChangeLog:
      
      	* libgcov.h (gcov_type): Use LONG_LONG_TYPE_SIZE.
      	(gcov_type_unsigned): Likewise.
      23d33775
  5. Jan 16, 2023
  6. Oct 12, 2022
    • Martin Liska's avatar
      gcov: rename gcov_write_summary · a9c83fb7
      Martin Liska authored
      gcc/ChangeLog:
      
      	* gcov-io.cc (gcov_write_summary): Rename to ...
      	(gcov_write_object_summary): ... this.
      	* gcov-io.h (GCOV_TAG_OBJECT_SUMMARY_LENGTH): Rename from ...
      	(GCOV_TAG_SUMMARY_LENGTH): ... this.
      
      libgcc/ChangeLog:
      
      	* libgcov-driver.c: Use new function.
      	* libgcov.h (gcov_write_summary): Rename to ...
      	(gcov_write_object_summary): ... this.
      a9c83fb7
  7. May 10, 2022
    • Martin Liska's avatar
      libgcov: use proper type for n_functions · 1bac97ad
      Martin Liska authored
      
      gcov_info::n_functions type is initialized by generated
      code in build_info_type:
      
      /* n_functions */
      field = build_decl (BUILTINS_LOCATION, FIELD_DECL, NULL_TREE,
      		    get_gcov_unsigned_t ());
      
      It uses gcov_unsigned_t, but the struct definition in libgcov.h uses
      unsigned type. That brings troubled on 16-bit targets.
      
      	PR gcov-profile/105535
      
      libgcc/ChangeLog:
      
      	* libgcov.h (struct gcov_info): Use gcov_unsigned_t for
      	n_functions.
      
      Co-Authored-By: default avatarHans-Peter Helfert <peter-helfert@t-online.de>
      1bac97ad
  8. Apr 28, 2022
    • Sebastian Huber's avatar
      gcov: Make gcov_seek() static · 68a4673f
      Sebastian Huber authored
      This function is only used by gcov_write_length() in the gcov-io.cc file.
      
      gcc/
      
      	* gcov-io.cc (gcov_seek): Make it static.
      	* gcov-io.h (struct gcov_summary): Do not mention gcov_seek().
      
      libgcc/
      
      	* libgcov.h (gcov_seek): Remove define and declaration.
      68a4673f
    • Sebastian Huber's avatar
      gcov: Add mode to all gcov_open() · d170ecc9
      Sebastian Huber authored
      gcc/
      
      	* gcov-io.cc (gcov_open): Always use the mode parameter.
      	* gcov-io.h (gcov_open): Declare it unconditionally.
      
      libgcc/
      
      	* libgcov-driver-system.c (gcov_exit_open_gcda_file): Open file for
      	reading and writing.
      	* libgcov-util.c (read_gcda_file): Open file for reading.
      	* libgcov.h (gcov_open): Delete declaration.
      d170ecc9
  9. Jan 03, 2022
  10. Oct 13, 2021
    • Martin Liska's avatar
      gcov: make profile merging smarter · 72e0c742
      Martin Liska authored
      Support merging of profiles that are built from a different .o files
      but belong to the same source file. Moreover, a checksum is verified
      during profile merging and so we can safely combine such profile.
      
      	PR gcov-profile/90364
      
      gcc/ChangeLog:
      
      	* coverage.c (build_info): Emit checksum to the global variable.
      	(build_info_type): Add new field for checksum.
      	(coverage_obj_finish): Pass object_checksum.
      	(coverage_init): Use 0 as checksum for .gcno files.
      	* gcov-dump.c (dump_gcov_file): Dump also new checksum field.
      	* gcov.c (read_graph_file): Read also checksum.
      	* doc/invoke.texi: Document the behaviour change.
      
      libgcc/ChangeLog:
      
      	* libgcov-driver.c (merge_one_data): Skip timestamp and verify
      	checksums.
      	(write_one_data): Write also checksum.
      	* libgcov-util.c (read_gcda_file): Read also checksum field.
      	* libgcov.h (struct gcov_info): Add new field.
      72e0c742
  11. Aug 16, 2021
    • Sebastian Huber's avatar
      gcov: Add TARGET_GCOV_TYPE_SIZE target hook · 8cdcea51
      Sebastian Huber authored
      If -fprofile-update=atomic is used, then the target must provide atomic
      operations for the counters of the type returned by get_gcov_type().
      This is a 64-bit type for targets which have a 64-bit long long type.
      On 32-bit targets this could be an issue since they may not provide
      64-bit atomic operations.  Allow targets to override the default type
      size with the new TARGET_GCOV_TYPE_SIZE target hook.
      
      If a 32-bit gcov type size is used, then there is currently a warning in
      libgcov-driver.c in a dead code block due to
      sizeof (counter) == sizeof (gcov_unsigned_t):
      
      libgcc/libgcov-driver.c: In function 'dump_counter':
      libgcc/libgcov-driver.c:401:46: warning: right shift count >= width of type [-Wshift-count-overflow]
        401 |     dump_unsigned ((gcov_unsigned_t)(counter >> 32), dump_fn, arg);
            |                                              ^~
      
      gcc/c-family/
      
      	* c-cppbuiltin.c (c_cpp_builtins): Define
      	__LIBGCC_GCOV_TYPE_SIZE if flag_building_libgcc is true.
      
      gcc/
      
      	* config/sparc/rtemself.h (SPARC_GCOV_TYPE_SIZE): Define.
      	* config/sparc/sparc.c (sparc_gcov_type_size): New.
      	(TARGET_GCOV_TYPE_SIZE): Redefine if SPARC_GCOV_TYPE_SIZE is defined.
      	* coverage.c (get_gcov_type): Use targetm.gcov_type_size().
      	* doc/tm.texi (TARGET_GCOV_TYPE_SIZE): Add hook under "Misc".
      	* doc/tm.texi.in: Regenerate.
      	* target.def (gcov_type_size): New target hook.
      	* targhooks.c (default_gcov_type_size): New.
      	* targhooks.h (default_gcov_type_size): Declare.
      	* tree-profile.c (gimple_gen_edge_profiler): Use precision of
      	gcov_type_node.
      	(gimple_gen_time_profiler): Likewise.
      
      libgcc/
      
      	* libgcov.h (gcov_type): Define using __LIBGCC_GCOV_TYPE_SIZE.
      	(gcov_type_unsigned): Likewise.
      8cdcea51
  12. Aug 06, 2021
    • Sebastian Huber's avatar
      gcov: Add __gcov_info_to_gdca() · 9124bbe1
      Sebastian Huber authored
      Add __gcov_info_to_gcda() to libgcov to get the gcda data for a gcda info in a
      freestanding environment.  It is intended to be used with the
      -fprofile-info-section option.  A crude test program which doesn't use a linker
      script is (use "gcc -coverage -fprofile-info-section -lgcov test.c" to compile
      it):
      
        #include <gcov.h>
        #include <stdio.h>
        #include <stdlib.h>
      
        extern const struct gcov_info *my_info;
      
        static void
        filename (const char *f, void *arg)
        {
          printf("filename: %s\n", f);
        }
      
        static void
        dump (const void *d, unsigned n, void *arg)
        {
          const unsigned char *c = d;
      
          for (unsigned i = 0; i < n; ++i)
            printf ("%02x", c[i]);
        }
      
        static void *
        allocate (unsigned length, void *arg)
        {
          return malloc (length);
        }
      
        int main()
        {
          __asm__ volatile (".set my_info, .LPBX2");
          __gcov_info_to_gcda (my_info, filename, dump, allocate, NULL);
          return 0;
        }
      
      With this patch, <stdint.h> is included in libgcov-driver.c even if
      inhibit_libc is defined.  This header file should be also available for
      freestanding environments.  If this is not the case, then we have to define
      intptr_t somehow.
      
      The patch removes one use of memset() which makes the <string.h> include
      superfluous.
      
      gcc/
      
      	* gcov-io.h (gcov_write): Declare.
      	* gcov-io.c (gcov_write): New.
      	(gcov_write_counter): Remove.
      	(gcov_write_tag_length): Likewise.
      	(gcov_write_summary): Replace gcov_write_tag_length() with calls to
      	gcov_write_unsigned().
      	* doc/invoke.texi (fprofile-info-section): Mention
      	__gcov_info_to_gdca().
      
      gcc/testsuite/
      
      	* gcc.dg/gcov-info-to-gcda.c: New test.
      
      libgcc/
      
      	* Makefile.in (LIBGCOV_DRIVER): Add _gcov_info_to_gcda.
      	* gcov.h (gcov_info): Declare.
      	(__gcov_info_to_gdca): Likewise.
      	* libgcov.h (gcov_write_counter): Remove.
      	(gcov_write_tag_length): Likewise.
      	* libgcov-driver.c (#include <stdint.h>): New.
      	(#include <string.h>): Remove.
      	(NEED_L_GCOV): Conditionally define.
      	(NEED_L_GCOV_INFO_TO_GCDA): Likewise.
      	(are_all_counters_zero): New.
      	(gcov_dump_handler): Likewise.
      	(gcov_allocate_handler): Likewise.
      	(dump_unsigned): Likewise.
      	(dump_counter): Likewise.
      	(write_topn_counters): Add dump_fn, allocate_fn, and arg parameters.
      	Use dump_unsigned() and dump_counter().
      	(write_one_data): Add dump_fn, allocate_fn, and arg parameters.  Use
      	dump_unsigned(), dump_counter(), and are_all_counters_zero().
      	(__gcov_info_to_gcda): New.
      9124bbe1
  13. Apr 29, 2021
    • Eric Botcazou's avatar
      Add parallelism support to gcov for MinGW platforms · 9ec469f5
      Eric Botcazou authored
      If you attempt a profiled bootstrap on the MinGW platforms with -jN, N > 1,
      it miserably fails because of profile mismatches all over the place, the
      reason being that gcov has no support for parallelism on these platforms.
      
      libgcc/
      	* libgcov.h: For the target, define GCOV_LOCKED_WITH_LOCKING
      	if __MSVCRT__ and, for the host, define it if HOST_HAS_LK_LOCK.
      	* libgcov-driver.c: Add directives if GCOV_LOCKED_WITH_LOCKING.
      gcc/
      	* configure.ac: Check for the presence of sys/locking.h header and
      	for whether _LK_LOCK is supported by _locking.
      	* configure: Regenerate.
      	* config.in: Likewise.
      	* gcov-io.h: Define GCOV_LOCKED_WITH_LOCKING if HOST_HAS_LK_LOCK.
      	* gcov-io.c (gcov_open): Add support for GCOV_LOCKED_WITH_LOCKING.
      	* system.h: Include <sys/locking.h> if HAVE_SYS_LOCKING_H.
      9ec469f5
  14. Mar 06, 2021
    • Jakub Jelinek's avatar
      libgcov: Fix build on Darwin [PR99406] · 73a9216b
      Jakub Jelinek authored
      As reported, bootstrap currently fails on older Darwin because MAP_ANONYMOUS
      is not defined.
      
      The following is what gcc/system.h does, so I think it should work for
      libgcov.
      
      2021-03-06  Jakub Jelinek  <jakub@redhat.com>
      
      	PR gcov-profile/99406
      	* libgcov.h (MAP_FAILED, MAP_ANONYMOUS): If HAVE_SYS_MMAN_H is
      	defined, define these macros if not defined already.
      73a9216b
  15. Mar 04, 2021
    • Martin Liska's avatar
      profiling: fix streaming of TOPN counters · 6a8fc0c3
      Martin Liska authored
      libgcc/ChangeLog:
      
      	PR gcov-profile/99105
      	* libgcov-driver.c (write_top_counters): Rename to ...
      	(write_topn_counters): ... this.
      	(write_one_data): Pre-allocate buffer for number of items
      	in the corresponding linked lists.
      	* libgcov.h (malloc_mmap): New function.
      	(allocate_gcov_kvp): Use it.
      
      gcc/testsuite/ChangeLog:
      
      	PR gcov-profile/99105
      	* gcc.dg/tree-prof/indir-call-prof-malloc.c: Use profile
      	correction as the wrapped malloc is called one more time
      	from libgcov.
      	* gcc.dg/tree-prof/pr97461.c: Likewise.
      6a8fc0c3
    • Martin Liska's avatar
      gcov: call mmap MAP_ANONYMOUS with fd equal to -1 · 4c955b4a
      Martin Liska authored
      libgcc/ChangeLog:
      
      	PR gcov-profile/99385
      	* libgcov.h (allocate_gcov_kvp): Call mmap with fd equal to -1.
      4c955b4a
  16. Mar 03, 2021
    • Martin Liska's avatar
      gcov: use mmap pools for KVP. · 00d79dc4
      Martin Liska authored
      gcc/ChangeLog:
      
      	PR gcov-profile/97461
      	* gcov-io.h (GCOV_PREALLOCATED_KVP): Remove.
      
      libgcc/ChangeLog:
      
      	PR gcov-profile/97461
      	* config.in: Regenerate.
      	* configure: Likewise.
      	* configure.ac: Check sys/mman.h header file
      	* libgcov-driver.c (struct gcov_kvp): Remove static
      	pre-allocated pool and use a dynamic one.
      	* libgcov.h (MMAP_CHUNK_SIZE): New.
      	(gcov_counter_add): Use mmap to allocate pool for struct
      	gcov_kvp.
      00d79dc4
  17. Jan 26, 2021
  18. Jan 25, 2021
    • Martin Liska's avatar
      Restore profile reproducibility. · 5089df53
      Martin Liska authored
      gcc/ChangeLog:
      
      	PR gcov-profile/98739
      	* common.opt: Add missing sign symbol.
      	* value-prof.c (get_nth_most_common_value): Restore handling
      	of PROFILE_REPRODUCIBILITY_PARALLEL_RUNS and
      	PROFILE_REPRODUCIBILITY_MULTITHREADED.
      
      libgcc/ChangeLog:
      
      	PR gcov-profile/98739
      	* libgcov-merge.c (__gcov_merge_topn): Mark when merging
      	ends with a dropped counter.
      	* libgcov.h (gcov_topn_add_value): Add return value.
      5089df53
  19. Jan 04, 2021
  20. Oct 27, 2020
    • Martin Liska's avatar
      gcov-profile: use static pool for TOPN first · 14e19b82
      Martin Liska authored
      gcc/ChangeLog:
      
      	PR gcov-profile/97461
      	* gcov-io.h (GCOV_PREALLOCATED_KVP): Pre-allocate 64
      	static counters.
      
      libgcc/ChangeLog:
      
      	PR gcov-profile/97461
      	* libgcov.h (gcov_counter_add): Use first static counters
      	as it should help to have malloc wrappers set up.
      
      gcc/testsuite/ChangeLog:
      
      	PR gcov-profile/97461
      	* gcc.dg/tree-prof/pr97461.c: New test.
      14e19b82
  21. Jul 31, 2020
    • Martin Liska's avatar
      libgcov: support overloaded malloc · bc2b1a23
      Martin Liska authored
      gcc/ChangeLog:
      
      	* gcov-io.h (GCOV_PREALLOCATED_KVP): New.
      
      libgcc/ChangeLog:
      
      	* libgcov-driver.c: Add __gcov_kvp_pool
      	and __gcov_kvp_pool_index variables.
      	* libgcov.h (allocate_gcov_kvp): New.
      	(gcov_topn_add_value): Use it.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-prof/indir-call-prof-malloc.c: New test.
      bc2b1a23
  22. Jun 25, 2020
    • Martin Liska's avatar
      gcov-tool: fix merge operation for summary · 88891c5f
      Martin Liska authored
      libgcc/ChangeLog:
      
      	* libgcov-driver.c (merge_summary): Remove function as its name
      	is misleading and doing something different.
      	(dump_one_gcov): Add ATTRIBUTE_UNUSED for 2 args. Take read summary
      	in gcov-tool.
      	* libgcov-util.c (curr_object_summary): Remove.
      	(read_gcda_file): Remove unused curr_object_summary.
      	(gcov_merge): Merge summaries.
      	* libgcov.h: Add summary argument for gcov_info struct.
      88891c5f
  23. Jun 17, 2020
    • Martin Liska's avatar
      gcov: fix gcov-tool merge for TOPN counters · 5fc312a9
      Martin Liska authored
      libgcc/ChangeLog:
      
      	* libgcov-util.c (read_gcda_finalize): Remove const operator.
      	(merge_wrapper): Add both counts and use them properly.
      	(topn_to_memory_representation): New function.
      	(gcov_merge): Covert on disk representation to in memory
      	representation.
      	* libgcov.h: Remove const operator.
      5fc312a9
  24. Jun 09, 2020
    • Martin Liska's avatar
      libgcov: fix TOPN type casting · 862b9b22
      Martin Liska authored
      The patch fixes tree-prof.exp tests on solaris11 and i686-linux-gnu,
      problem was that sizeof of a pointer is different from sizeof gcov_type.
      
      I'm going to install it if there are no objections.
      Thanks,
      Martin
      
      libgcc/ChangeLog:
      
      	PR gcov-profile/95494
      	* libgcov-driver.c (write_top_counters): Cast first to
      	intptr_t as sizeof(*) != sizeof(gcov_type).
      	* libgcov.h (gcov_counter_set_if_null): Remove.
      	(gcov_topn_add_value): Cast first to intptr_t and update
      	linked list directly.
      862b9b22
  25. Jun 03, 2020
    • Martin Liska's avatar
      gcov: Fix build on AIX · eb3480fc
      Martin Liska authored
      We must guard used atomic builtins with GCOV_SUPPORTS_ATOMIC.
      The patch is tested on AIX and I'm going to push it.
      
      libgcc/ChangeLog:
      
      	PR gcov-profile/95480
      	* libgcov-profiler.c (GCOV_SUPPORTS_ATOMIC): Move to...
      	* libgcov.h (GCOV_SUPPORTS_ATOMIC): ...here.
      	(gcov_counter_add): Use GCOV_SUPPORTS_ATOMIC guard.
      	(gcov_counter_set_if_null): Likewise.
      eb3480fc
  26. Jun 02, 2020
    • Martin Liska's avatar
      libgcov: replace malloc and calloc. · a04b7410
      Martin Liska authored
      The calloc was in the original tested version of the patch
      and I made accidental last minute change.
      
      Installed to master as obvious.
      
      libgcc/ChangeLog:
      
      	* libgcov.h (gcov_topn_add_value): Use xcalloc instead
      	of xmalloc.
      a04b7410
    • Martin Liska's avatar
      Make TOPN counter dynamically allocated. · 871e5ada
      Martin Liska authored
      gcc/ChangeLog:
      
      	* coverage.c (get_coverage_counts): Skip sanity check for TOP N counters
      	as they have variable number of counters.
      	* gcov-dump.c (main): Add new option -r.
      	(print_usage): Likewise.
      	(tag_counters): All new raw format.
      	* gcov-io.h (struct gcov_kvp): New.
      	(GCOV_TOPN_VALUES): Remove.
      	(GCOV_TOPN_VALUES_COUNTERS): Likewise.
      	(GCOV_TOPN_MEM_COUNTERS): New.
      	(GCOV_TOPN_DISK_COUNTERS): Likewise.
      	(GCOV_TOPN_MAXIMUM_TRACKED_VALUES): Likewise.
      	* ipa-profile.c (ipa_profile_generate_summary): Use
      	GCOV_TOPN_MAXIMUM_TRACKED_VALUES.
      	(ipa_profile_write_edge_summary): Likewise.
      	(ipa_profile_read_edge_summary): Likewise.
      	(ipa_profile): Remove usage of GCOV_TOPN_VALUES.
      	* profile.c (sort_hist_values): Sort variable number
      	of counters.
      	(compute_value_histograms): Special case for TOP N counters
      	that have dynamic number of key-value pairs.
      	* value-prof.c (dump_histogram_value): Dump variable number
      	of key-value pairs.
      	(stream_in_histogram_value): Stream in variable number
      	of key-value pairs for TOP N counter.
      	(get_nth_most_common_value): Deal with variable number
      	of key-value pairs.
      	(dump_ic_profile): Use GCOV_TOPN_MAXIMUM_TRACKED_VALUES
      	for loop iteration.
      	(gimple_find_values_to_profile): Set GCOV_TOPN_MEM_COUNTERS
      	to n_counters.
      	* doc/gcov-dump.texi: Document new -r option.
      
      libgcc/ChangeLog:
      
      	* libgcov-driver.c (prune_topn_counter): Remove.
      	(prune_counters): Likewise.
      	(merge_one_data): Special case TOP N counters
      	as they have variable length.
      	(write_top_counters): New.
      	(write_one_data): Special case TOP N.
      	(dump_one_gcov): Do not prune TOP N counters.
      	* libgcov-merge.c (merge_topn_values_set): Remove.
      	(__gcov_merge_topn): Use gcov_topn_add_value.
      	* libgcov-profiler.c (__gcov_topn_values_profiler_body):
      	Likewise here.
      	* libgcov.h (gcov_counter_add): New.
      	(gcov_counter_set_if_null): Likewise.
      	(gcov_topn_add_value): New.
      871e5ada
  27. May 28, 2020
    • Martin Liska's avatar
      gcov-tool: Flexible endian adjustment for merging coverage data · 17d1594b
      Martin Liska authored
      gcc/ChangeLog:
      2020-05-27  Dong JianQiang  <dongjianqiang2@huawei.com>
      
      	PR gcov-profile/95332
      	* gcov-io.c (gcov_var::endian): Move field.
      	(from_file): Add IN_GCOV_TOOL check.
      	* gcov-io.h (gcov_magic): Ditto.
      
      libgcc/ChangeLog:
      2020-05-27  Dong JianQiang  <dongjianqiang2@huawei.com>
      
      	PR gcov-profile/95332
      	* libgcov-util.c (read_gcda_file): Call gcov_magic.
      	* libgcov.h (gcov_magic): Disable GCC poison.
      17d1594b
  28. May 05, 2020
    • Martin Liska's avatar
      Do locking for __gcov_dump and __gcov_reset as well. · d39f7dc8
      Martin Liska authored
      	PR gcov-profile/93623
      	* Makefile.in: Add _gcov_lock_unlock to LIBGCOV_INTERFACE.
      	* libgcov-interface.c (ALIAS_void_fn): Remove.
      	(__gcov_lock): New.
      	(__gcov_unlock): New.
      	(__gcov_flush): Use __gcov_lock and __gcov_unlock.
      	(__gcov_reset): Likewise.
      	(__gcov_dump): Likewise.
      	* libgcov.h (__gcov_lock): New declaration.
      	(__gcov_unlock): Likewise.
      d39f7dc8
  29. Jan 27, 2020
    • Martin Liska's avatar
      Add __gcov_indirect_call_profiler_v4_atomic. · 3ae37f92
      Martin Liska authored
      	PR gcov-profile/93403
      	* tree-profile.c (gimple_init_gcov_profiler): Generate
      	both __gcov_indirect_call_profiler_v4 and
      	__gcov_indirect_call_profiler_v4_atomic.
      	PR gcov-profile/93403
      	* libgcov-profiler.c (__gcov_indirect_call_profiler_v4):
      	Call __gcov_indirect_call_profiler_body.
      	(__gcov_indirect_call_profiler_body): New.
      	(__gcov_indirect_call_profiler_v4_atomic): New.
      	* libgcov.h (__gcov_indirect_call_profiler_v4_atomic):
      	New declaration.
      3ae37f92
  30. Jan 01, 2020
  31. Jul 03, 2019
    • Martin Liska's avatar
      Rename SINGE_VALUE to TOPN_VALUES counters. · 596341c7
      Martin Liska authored
      2019-07-03  Martin Liska  <mliska@suse.cz>
      
      	* gcov-counter.def (GCOV_COUNTER_V_SINGLE): Remove.
      	(GCOV_COUNTER_V_TOPN): New.
      	(GCOV_COUNTER_V_INDIR): Use _topn.
      	* gcov-io.h (GCOV_DISK_SINGLE_VALUES): Remove.
      	(GCOV_TOPN_VALUES): New.
      	(GCOV_SINGLE_VALUE_COUNTERS): Remove.
      	(GCOV_TOPN_VALUES_COUNTERS): New.
      	* profile.c (instrument_values): Use HIST_TYPE_TOPN_VALUES.
      	* tree-profile.c:
      	(gimple_init_gcov_profiler): Rename variables from one_value
      	to topn_values.
      	(gimple_gen_one_value_profiler): Remove.
      	(gimple_gen_topn_values_profiler): New function.
      	* value-prof.c (dump_histogram_value): Use TOPN_VALUES
      	names instead of SINGLE_VALUE.
      	(stream_out_histogram_value): Likewise.
      	(stream_in_histogram_value): Likewise.
      	(get_most_common_single_value): Likewise.
      	(gimple_divmod_fixed_value_transform): Likewise.
      	(gimple_stringops_transform): Likewise.
      	(gimple_divmod_values_to_profile): Likewise.
      	(gimple_stringops_values_to_profile): Likewise.
      	(gimple_find_values_to_profile): Likewise.
      	* value-prof.h (enum hist_type): Rename to TOPN.
      	(gimple_gen_one_value_profiler): Remove.
      	(gimple_gen_topn_values_profiler): New.
      2019-07-03  Martin Liska  <mliska@suse.cz>
      
      	* Makefile.in: Use topn_values instead of one_value names.
      	* libgcov-merge.c (__gcov_merge_single): Move to ...
      	(__gcov_merge_topn): ... this.
      	(merge_single_value_set): Move to ...
      	(merge_topn_values_set): ... this.
      	* libgcov-profiler.c (__gcov_one_value_profiler_body): Move to
      	...
      	(__gcov_topn_values_profiler_body): ... this.
      	(__gcov_one_value_profiler_v2): Move to ...
      	(__gcov_topn_values_profiler): ... this.
      	(__gcov_one_value_profiler_v2_atomic): Move to ...
      	(__gcov_topn_values_profiler_atomic): ... this.
      	(__gcov_indirect_call_profiler_v4): Remove.
      	* libgcov-util.c (__gcov_single_counter_op): Move to ...
      	(__gcov_topn_counter_op): ... this.
      	* libgcov.h (L_gcov_merge_single): Remove.
      	(L_gcov_merge_topn): New.
      	(__gcov_merge_single): Remove.
      	(__gcov_merge_topn): New.
      	(__gcov_one_value_profiler_v2): Move to ..
      	(__gcov_topn_values_profiler): ... this.
      	(__gcov_one_value_profiler_v2_atomic): Move to ...
      	(__gcov_topn_values_profiler_atomic): ... this.
      
      From-SVN: r273005
      596341c7
  32. Jun 10, 2019
    • Martin Liska's avatar
      Add missing ATTR_UNUSED (PR bootstrap/90808). · 54e2d83c
      Martin Liska authored
      2019-06-10  Martin Liska  <mliska@suse.cz>
      
      	PR bootstrap/90808
      	* libgcov.h: Add ATTRIBUTE_UNUSED.
      
      From-SVN: r272114
      54e2d83c
    • Martin Liska's avatar
      Implement N disk counters for single value and indirect call counters. · 92d41717
      Martin Liska authored
      2019-06-10  Martin Liska  <mliska@suse.cz>
      
      	* gcov-io.h (GCOV_DISK_SINGLE_VALUES): New.
      	(GCOV_SINGLE_VALUE_COUNTERS): Likewise.
      	* ipa-profile.c (ipa_profile_generate_summary):
      	Use get_most_common_single_value.
      	* tree-profile.c (gimple_init_gcov_profiler):
      	Instrument with __gcov_one_value_profiler_v2
      	and __gcov_indirect_call_profiler_v4.
      	* value-prof.c (dump_histogram_value):
      	Print all values for HIST_TYPE_SINGLE_VALUE.
      	(stream_out_histogram_value): Update assert for
      	N values.
      	(stream_in_histogram_value): Set number of
      	counters for HIST_TYPE_SINGLE_VALUE.
      	(get_most_common_single_value): New.
      	(gimple_divmod_fixed_value_transform):
      	Use get_most_common_single_value.
      	(gimple_ic_transform): Likewise.
      	(gimple_stringops_transform): Likewise.
      	(gimple_find_values_to_profile): Set number
      	of counters for HIST_TYPE_SINGLE_VALUE.
      	* value-prof.h (get_most_common_single_value):
      	New.
      2019-06-10  Martin Liska  <mliska@suse.cz>
      
      	* Makefile.in: Add __gcov_one_value_profiler_v2,
      	__gcov_one_value_profiler_v2_atomic and
      	__gcov_indirect_call_profiler_v4.
      	* libgcov-merge.c (__gcov_merge_single): Change
      	function signature.
      	(merge_single_value_set): New.
      	* libgcov-profiler.c (__gcov_one_value_profiler_body):
      	Update functionality.
      	(__gcov_one_value_profiler): Remove.
      	(__gcov_one_value_profiler_v2): ... this.
      	(__gcov_one_value_profiler_atomic): Rename to ...
      	(__gcov_one_value_profiler_v2_atomic): this.
      	(__gcov_indirect_call_profiler_v3): Rename to ...
      	(__gcov_indirect_call_profiler_v4): ... this.
      	* libgcov.h (__gcov_one_value_profiler): Remove.
      	(__gcov_one_value_profiler_atomic): Remove.
      	(__gcov_one_value_profiler_v2_atomic): New.
      	(__gcov_indirect_call_profiler_v3): Remove.
      	(__gcov_one_value_profiler_v2): New.
      	(__gcov_indirect_call_profiler_v4): New.
      	(gcov_get_counter_ignore_scaling): New function.
      
      From-SVN: r272106
      92d41717
  33. Jun 07, 2019
    • Martin Liska's avatar
      Remove indirect call top N counter type. · e37333ba
      Martin Liska authored
      2019-06-07  Martin Liska  <mliska@suse.cz>
      
      	* doc/invoke.texi: Remove param.
      	* gcov-counter.def (GCOV_COUNTER_ICALL_TOPNV):
      	Remove.
      	* gcov-io.h (GCOV_ICALL_TOPN_VAL): Likewise.
      	(GCOV_ICALL_TOPN_NCOUNTS): Likewise.
      	* params.def (PARAM_INDIR_CALL_TOPN_PROFILE): Likewise.
      	* profile.c (instrument_values): Remove
      	HIST_TYPE_INDIR_CALL_TOPN.
      	* tree-profile.c (init_ic_make_global_vars):
      	Always build __gcov_indirect_call only.
      	(gimple_init_gcov_profiler): Remove usage
      	of PARAM_INDIR_CALL_TOPN_PROFILE.
      	(gimple_gen_ic_profiler): Likewise.
      	* value-prof.c (dump_histogram_value): Likewise.
      	(stream_in_histogram_value): Likewise.
      	(gimple_indirect_call_to_profile): Likewise.
      	(gimple_find_values_to_profile): Likewise.
      	* value-prof.h (enum hist_type): Likewise.
      2019-06-07  Martin Liska  <mliska@suse.cz>
      
      	* Makefile.in: Remove usage of
      	_gcov_merge_icall_topn.
      	* libgcov-driver.c (gcov_sort_n_vals): Remove.
      	(gcov_sort_icall_topn_counter): Likewise.
      	(gcov_sort_topn_counter_arrays): Likewise.
      	(dump_one_gcov): Remove call to gcov_sort_topn_counter_arrays.
      	* libgcov-merge.c (__gcov_merge_icall_topn): Remove.
      	* libgcov-profiler.c (__gcov_topn_value_profiler_body):
      	Likewise.
      	(GCOV_ICALL_COUNTER_CLEAR_THRESHOLD): Remove.
      	(struct indirect_call_tuple): Remove.
      	(__gcov_indirect_call_topn_profiler): Remove.
      	* libgcov-util.c (__gcov_icall_topn_counter_op): Remove.
      	* libgcov.h (gcov_sort_n_vals): Remove.
      	(L_gcov_merge_icall_topn): Likewise.
      	(__gcov_merge_icall_topn): Likewise.
      	(__gcov_indirect_call_topn_profiler): Likewise.
      
      From-SVN: r272030
      e37333ba
  34. Jan 18, 2019
    • Martin Liska's avatar
      Bump version of __gcov_indirect_call_profiler function as there was ABI change. · 756721ba
      Martin Liska authored
      2019-01-18  Martin Liska  <mliska@suse.cz>
      
      	* params.def: Fix comment.
      	* tree-profile.c (gimple_init_gcov_profiler): Bump function
      	name.
      	(gimple_gen_ic_func_profiler): Likewise.
      2019-01-18  Martin Liska  <mliska@suse.cz>
      
      	* gcc.dg/no_profile_instrument_function-attr-1.c: Update
      	expected function name.
      2019-01-18  Martin Liska  <mliska@suse.cz>
      
      	* libgcov-profiler.c (__gcov_indirect_call_profiler_v2): Rename
      	to ...
      	(__gcov_indirect_call_profiler_v3): ... this.
      	* libgcov.h (__gcov_indirect_call_profiler_v2): Likewise.
      	(__gcov_indirect_call_profiler_v3): Likewise.
      	* Makefile.in: Bump function name.
      
      From-SVN: r268071
      756721ba
  35. Jan 01, 2019
Loading