Commit Graph

51 Commits

Author SHA1 Message Date
Jakub Jelinek 7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Martin Liska 72e0c742bd gcov: make profile merging smarter
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.
2021-10-13 15:26:58 +02:00
Sebastian Huber 8cdcea51c0 gcov: Add TARGET_GCOV_TYPE_SIZE target hook
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.
2021-08-16 15:34:25 +02:00
Sebastian Huber 9124bbe185 gcov: Add __gcov_info_to_gdca()
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.
2021-08-06 07:28:26 +02:00
Eric Botcazou 9ec469f504 Add parallelism support to gcov for MinGW platforms
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.
2021-04-29 16:02:17 +02:00
Jakub Jelinek 73a9216b8a libgcov: Fix build on Darwin [PR99406]
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.
2021-03-06 16:22:27 +01:00
Martin Liska 6a8fc0c31a profiling: fix streaming of TOPN counters
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.
2021-03-04 16:21:52 +01:00
Martin Liska 4c955b4ad3 gcov: call mmap MAP_ANONYMOUS with fd equal to -1
libgcc/ChangeLog:

	PR gcov-profile/99385
	* libgcov.h (allocate_gcov_kvp): Call mmap with fd equal to -1.
2021-03-04 11:53:33 +01:00
Martin Liska 00d79dc4be gcov: use mmap pools for KVP.
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.
2021-03-03 14:21:45 +01:00
Martin Liska d40b21eebc libgcov: improve profile reproducibility
libgcc/ChangeLog:

	PR gcov-profile/98739
	* libgcov.h (gcov_topn_add_value): Do not train when
	we have a merged profile with a negative number of total
	value.
2021-01-26 12:44:34 +01:00
Martin Liska 5089df534b Restore profile reproducibility.
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.
2021-01-25 13:30:34 +01:00
Jakub Jelinek 99dee82307 Update copyright years. 2021-01-04 10:26:59 +01:00
Martin Liska 14e19b82c1 gcov-profile: use static pool for TOPN first
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.
2020-10-27 11:49:54 +01:00
Martin Liska bc2b1a232b libgcov: support overloaded malloc
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.
2020-07-31 10:57:50 +02:00
Martin Liska 88891c5ff0
gcov-tool: fix merge operation for summary
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.
2020-06-25 11:27:12 +02:00
Martin Liska 5fc312a98e
gcov: fix gcov-tool merge for TOPN counters
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.
2020-06-17 08:32:27 +02:00
Martin Liska 862b9b225f
libgcov: fix TOPN type casting
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.
2020-06-09 13:07:41 +02:00
Martin Liska eb3480fc0f
gcov: Fix build on AIX
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.
2020-06-03 08:12:50 +02:00
Martin Liska a04b7410d3
libgcov: replace malloc and calloc.
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.
2020-06-02 13:57:31 +02:00
Martin Liska 871e5ada6d
Make TOPN counter dynamically allocated.
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.
2020-06-02 12:11:02 +02:00
Martin Liska 17d1594bfe
gcov-tool: Flexible endian adjustment for merging coverage data
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.
2020-05-28 08:18:21 +02:00
Martin Liska d39f7dc8d5
Do locking for __gcov_dump and __gcov_reset as well.
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.
2020-05-05 16:15:45 +02:00
Martin Liska 3ae37f9297
Add __gcov_indirect_call_profiler_v4_atomic.
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.
2020-01-27 16:20:10 +01:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Martin Liska 596341c741 Rename SINGE_VALUE to TOPN_VALUES counters.
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
2019-07-03 12:42:23 +00:00
Martin Liska 54e2d83caf Add missing ATTR_UNUSED (PR bootstrap/90808).
2019-06-10  Martin Liska  <mliska@suse.cz>

	PR bootstrap/90808
	* libgcov.h: Add ATTRIBUTE_UNUSED.

From-SVN: r272114
2019-06-10 09:53:46 +00:00
Martin Liska 92d417175b Implement N disk counters for single value and indirect call counters.
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
2019-06-10 07:38:59 +00:00
Martin Liska e37333bad7 Remove indirect call top N counter type.
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
2019-06-07 06:41:58 +00:00
Martin Liska 756721ba89 Bump version of __gcov_indirect_call_profiler function as there was ABI change.
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
2019-01-18 11:32:53 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Martin Liska 3edbcdbead Fix divergence in indirect profiling (PR gcov-profile/84107).
2018-10-04  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/84107
	* tree-profile.c (init_ic_make_global_vars):
	Remove ic_void_ptr_var and ic_gcov_type_ptr_var.
	Come up with new ic_tuple* variables.  Emit
	__gcov_indirect_call{,_topn} variables.
	(gimple_gen_ic_profiler): Access the variable
	and emit gimple.
	(gimple_gen_ic_func_profiler): Access
	__gcov_indirect_call.callee field.
	(gimple_init_gcov_profiler): Use ptr_type_node.
	* value-prof.c (gimple_ic): Use ptr_type_node.
2018-10-04  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/84107
	* libgcov-profiler.c (__gcov_indirect_call):
	Change type to indirect_call_tuple.
	(struct indirect_call_tuple): New struct.
	(__gcov_indirect_call_topn_profiler): Change type.
	(__gcov_indirect_call_profiler_v2): Use the new
	variables.
	* libgcov.h (struct indirect_call_tuple): New struct
	definition.

From-SVN: r264840
2018-10-04 12:41:14 +00:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Richard Biener a51a76e594 re PR gcov-profile/81080 (target libgcov not built with large file support)
2017-06-21  Richard Biener  <rguenther@suse.de>

	PR gcov-profile/81080
	* configure.ac: Add AC_SYS_LARGEFILE.
	* libgcov.h: Include auto-target.h before tsystem.h to pick
	up _FILE_OFFSET_BITS which might differ for multilibs.
	* config.in: Regenerate.
	* configure: Likewise.

From-SVN: r249435
2017-06-21 07:01:34 +00:00
Martin Liska 46928a8fda Introduce gcov.h header file (PR gcov-profile/80435).
2017-04-19  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/80435
	* Makefile.in: Install gcov.h.
	* gcov.h: New file.
	* libgcov.h: Use the header and make __gcov_flush publicly
	visible.

From-SVN: r246990
2017-04-19 08:08:44 +00:00
Jakub Jelinek cbe34bb5ed Update copyright years.
From-SVN: r243994
2017-01-01 13:07:43 +01:00
Martin Liska 8c9434c2f9 gcov: dump in a static dtor instead of in an atexit handler
PR gcov-profile/7970
	PR gcov-profile/16855
	PR gcov-profile/44779
	* g++.dg/gcov/pr16855.C: New test.
	* coverage.c (build_gcov_exit_decl): New function.
	(coverage_obj_init): Call the function and generate __gcov_exit
	destructor.
	* doc/gcov.texi: Document when __gcov_exit function is called.
	* libgcov-driver.c (__gcov_init): Do not register a atexit
	handler.
	(__gcov_exit): Rename from gcov_exit.
	* libgcov.h (__gcov_exit): Declare.

From-SVN: r240529
2016-09-27 11:07:11 +00:00
Martin Liska 56b653f1a3 Remove __gcov_merge_delta (PR bootstrap/77749)
PR bootstrap/77749
	* gcov-counter.def: Remove GCOV_COUNTER_V_DELTA.
	PR bootstrap/77749
	* Makefile.in: Remove _gcov_merge_delta.
	* libgcov-merge.c (void __gcov_merge_delta): Remove.
	* libgcov-util.c (__gcov_delta_counter_op): Remove.
	* libgcov.h: Remove declaration of __gcov_merge_delta.

From-SVN: r240524
2016-09-27 10:04:39 +00:00
Martin Liska a266236e85 Add new *_atomic counter update function
PR gcov-profile/58306
	* Makefile.in: New functions (modules) are added.
	* libgcov-profiler.c (__gcov_interval_profiler_atomic): New
	function.
	(__gcov_pow2_profiler_atomic): New function.
	(__gcov_one_value_profiler_body): New argument is instroduced.
	(__gcov_one_value_profiler): Call with the new argument.
	(__gcov_one_value_profiler_atomic): Likewise.
	(__gcov_indirect_call_profiler_v2): Likewise.
	(__gcov_time_profiler_atomic): New function.
	(__gcov_average_profiler_atomic): Likewise.
	(__gcov_ior_profiler_atomic): Likewise.
	* libgcov.h: Declare the aforementioned functions.
	PR gcov-profile/58306
	* gcc.dg/tree-prof/val-profiler-threads-1.c: New test.
	PR gcov-profile/58306
	* tree-profile.c (gimple_init_edge_profiler): Create conditionally
	atomic variants of profile update functions.

From-SVN: r239324
2016-08-10 13:14:56 +00:00
Martin Liska 6dce6418c5 Remove __gcov_indirect_call_profiler
* Makefile.in: Remove __gcov_indirect_call_profiler.
	* libgcov-profiler.c (__gcov_indirect_call_profiler): Remove
	function.
	* libgcov.h: And the declaration of the function.

From-SVN: r239306
2016-08-09 21:01:19 +00:00
Jakub Jelinek 818ab71a41 Update copyright years.
From-SVN: r232055
2016-01-04 15:30:50 +01:00
Trevor Saunders a153644f75 replace BITS_PER_UNIT with __CHAR_BIT__ in target libs
libgcc/ChangeLog:

2015-11-07  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* config/visium/lib2funcs.c (__set_trampoline_parity): Use
	__CHAR_BIT__ instead of BITS_PER_UNIT.
	* fixed-bit.h: Likewise.
	* fp-bit.h: Likewise.
	* libgcc2.c (__popcountSI2): Likewise.
	(__popcountDI2): Likewise.
	* libgcc2.h: Likewise.
	* libgcov.h: Likewise.

libobjc/ChangeLog:

2015-11-07  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	PR libobjc/24775
	* encoding.c (_darwin_rs6000_special_round_type_align): Use
	__CHAR_BIT__ instead of BITS_PER_UNIT.
	(objc_sizeof_type): Likewise.
	(objc_layout_structure): Likewise.
	(objc_layout_structure_next_member): Likewise.
	(objc_layout_finish_structure): Likewise.
	(objc_layout_structure_get_info): Likewise.

From-SVN: r229936
2015-11-07 19:36:26 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Rong Xu afe0c5ee91 Makefile.in: Fix dependence.
2014-10-06  Rong Xu  <xur@google.com>

	* gcc/Makefile.in: Fix dependence.
	* gcc/gcov-counter.def (GCOV_COUNTER_ICALL_TOPNV): Add
        indirect call topn profiler.
	* gcc/gcov-io.h: Ditto.
	* libgcc/Makefile.in: Ditto.
	* libgcc/libgcov-driver.c (gcov_sort_n_vals): New utility function.
	(gcov_sort_icall_topn_counter): Ditto.
	(gcov_sort_topn_counter_arrays): Ditto.
	(dump_one_gcov): Sort indirect_call topn counters.
	* libgcc/libgcov-merge.c (__gcov_merge_icall_topn): New merge
        function.
	* libgcc/libgcov-profiler.c (__gcov_topn_value_profiler_body): New
        utility function.
	(__gcov_indirect_call_topn_profiler): New profiler function.
	* libgcc/libgcov-util.c (__gcov_icall_topn_counter_op): New.
	* libgcc/libgcov.h: New decls.

From-SVN: r215962
2014-10-07 04:02:31 +00:00
Nathan Sidwell cadb2b9689 Makefile.in (LIBGCOV_INTERFACE): Add _gcov_dump from ...
* Makefile.in (LIBGCOV_INTERFACE): Add _gcov_dump from ...
	(LIBGCOV_DRIVER): ... here.
	* libgcov-driver.c (gcov_master): New.
	(gcov_exit): Remove from master chain.
	(__gcov_init): Add to master chain if version compatible.  Don't
	clear the version.
	* libgcov_interface (__gcov_flust): Call gcov_dump_int.
	(gcov_reset_int): Clear master chain, if compatible.
	(gcov_dump_int): New internal interface.  Dump master chain, if
	compatible.
	(gcov_dump): Alias for gcov_dump_int.
	* libgcov.h (struct gcov_root): Add next and prev fields.
	(struct gcov_master): New struct.
	(__gcov_master): New.
	(gcov_dump_int): Declare.

From-SVN: r215337
2014-09-17 20:13:17 +00:00
Nathan Sidwell b20ee094df libgcov-interface.c (STRONG_ALIAS): New.
* libgcov-interface.c (STRONG_ALIAS): New.
	(__gcov_flush): Call __gcov_reset_int.
	(__gcov_reset): Strong alias for ...
	(__gcov_reset_ing): ... this renamed hidden version.
	* libgcov.h (__gcov_reset_int): New declaration.

From-SVN: r214840
2014-09-03 00:43:00 +00:00
Nathan Sidwell 4303c58196 Makefile.in (LIBGCOV_INTERFACE): Move _gcov_dump ...
* Makefile.in (LIBGCOV_INTERFACE): Move _gcov_dump ...
	(LIBGCOV_DRIVER): ... to here.
	* libgcov.h (gcov_do_dump): New #define.
	(struct gcov_root): New.
	(__gcov_root): New declaration.
	(__gcov_dump_one): Declare.
	* libgcov-driver.c (gcov_list, gcov_dump_complete,
	run_accounted): Delete.
	(gcov_compute_histogram): Add LIST argument, adjust.
	(compute_summary): Adjust gcov_compute_histogram call.
	(gcov_do_dump): Not hidden, static in libgcov.
	(gcov_clear): Move  to interface.c.
	(__gcov_dump_one): New, broken out of ...
	(gcov_exit): ... here.  Make static.
	(__gcov_root): New.
	(__gcov_init): Adjust.
	* libgcov-interface.c (gcov_clear, gcov_exit): Remove
	declarations.
	(__gcov_flush): Use __gcov_dump_one and __gcov_reset.
	(gcov_clear): Moved from driver.c.   Add LIST argument.
	(__gcov_reset): Adjust for changed interfaces.
	(__gcov_fork): Remove local declaration of __gcov_flush_mx.

From-SVN: r213719
2014-08-07 18:02:06 +00:00
Nathan Sidwell 1992616143 libgcov.h: Move renaming of entry points to lib gcov specific portion.
libgcc/
	* libgcov.h: Move renaming of entry points to lib gcov specific
	portion.
	(gcov_do_dump): New rename.
	(gcov_rewrite): Remove inline, make HIDDEN.
	* libgcov-driver.c (gcov_clear, gcov_exit): Remove declarations.
	(gcov_exit_compute_summary): Rename to ...
	(compute_summary): ... here.  Add LIST argument.
	(gcov_exit_merge_gcda): Rename to ...
	(merge_one_data): ... here.
	(gcov_exit_write_gcda): Rename to ...
	(write_one_data): ... here.
	(gcov_exit_merge_summary): Rename to ...
	(merge_summary): Add RUN_COUNTED argument.
	(gcov_exit_dump_gcov): Rename to ...
	(dump_one_gcov): Add RUN_COUNTED argument.
	(gcov_do_dump): New function, broken out of ...
	(gcov_exit): ... here.  Call it.

	gcc/
	* gcov-io.c (gcov_var): Make hidden.
	* gcov-tool.c (gcov_list, gcov_exit): Remove declarations.
	(gcov_do_dump): Declare.
	(gcov_output_files): Call gcov_do_dump, not gcov_exit).

From-SVN: r213188
2014-07-29 13:48:38 +00:00
Nathan Sidwell d10ee722fd gcov-tool.c (gcov_list): Declare here.
gcc/
	* gcov-tool.c (gcov_list): Declare here.
	(set_gcov_list): Remove.
	(gcov_output_files): Set gcov_list directly.

	libgcc/
	* libgcov-driver.c (set_gcov_list): Remove.
	(gcov_list): Make non-static in GCOV_TOOL.
	* libgcov.h (GCOV_TOOL_LINKAGE): Remove unused #define.

From-SVN: r212931
2014-07-23 12:08:31 +00:00
Richard Biener 72602c6cb4 libgcov.h (struct gcov_fn_info): Make ctrs size 1.
2014-07-14  Richard Biener  <rguenther@suse.de>

	* libgcov.h (struct gcov_fn_info): Make ctrs size 1.

From-SVN: r212520
2014-07-14 13:22:02 +00:00
Rong Xu c77556a5d1 Add gcov-tool: an offline gcda profile processing tool Support.
2014-07-10  Rong Xu  <xur@google.com>

	Add gcov-tool: an offline gcda profile processing tool
	Support.
	* gcc/gcov-io.c (gcov_position): Make avaialble to gcov-tool.
	(gcov_is_error): Ditto.
	(gcov_read_string): Ditto.
	(gcov_read_sync): Ditto.
	* gcc/gcov-io.h: Move counter defines to gcov-counter.def.
	* gcc/gcov-dump.c (tag_counters): Use gcov-counter.def.
	* gcc/coverage.c: Ditto.
	* gcc/gcov-tool.c: Offline gcda profile processing tool.
        (unlink_gcda_file): Remove one gcda file.
	(unlink_profile_dir): Remove gcda files from the profile path.
	(gcov_output_files): Output gcda files to an output dir.
	(profile_merge): Merge two profiles in directory.
	(print_merge_usage_message): Print merge usage.
	(merge_usage): Print merge usage and exit.
	(do_merge): Driver for profile merge sub-command.
	(profile_rewrite): Rewrite profile.
	(print_rewrite_usage_message): Print rewrite usage.
	(rewrite_usage): Print rewrite usage and exit.
	(do_rewrite): Driver for profile rewrite sub-command.
	(print_usage): Print gcov-info usage and exit.
	(print_version): Print gcov-info version.
	(process_args): Process arguments.
	(main): Main routine for gcov-tool.
	* gcc/Makefile.in: Build and install gcov-tool.
	* gcc/gcov-counter.def: New file split from gcov-io.h.
	* libgcc/libgcov-driver.c (gcov_max_filename): Make available
        to gcov-tool.
	* libgcc/libgcov-merge.c (__gcov_merge_add): Replace
        gcov_read_counter() with a Macro.
	(__gcov_merge_ior): Ditto.
	(__gcov_merge_time_profile): Ditto.
	(__gcov_merge_single): Ditto.
	(__gcov_merge_delta): Ditto.
	* libgcc/libgcov-util.c (void gcov_set_verbose): Set the verbose flag
        in the utility functions.
	(set_fn_ctrs): Utility function for reading gcda files to in-memory
        gcov_list object link lists.
	(tag_function): Ditto.
	(tag_blocks): Ditto.
	(tag_arcs): Ditto.
	(tag_lines): Ditto.
	(tag_counters): Ditto.
	(tag_summary): Ditto.
	(read_gcda_finalize): Ditto.
	(read_gcda_file): Ditto.
	(ftw_read_file): Ditto.
	(read_profile_dir_init): Ditto.
	(gcov_read_profile_dir): Ditto.
	(gcov_read_counter_mem): Ditto.
	(gcov_get_merge_weight): Ditto.
	(merge_wrapper): A wrapper function that calls merging handler.
	(gcov_merge): Merge two gcov_info objects with weights.
	(find_match_gcov_info): Find the matched gcov_info in the list.
	(gcov_profile_merge): Merge two gcov_info object lists.
	(__gcov_add_counter_op): Process edge profile counter values.
	(__gcov_ior_counter_op): Process IOR profile counter values.
	(__gcov_delta_counter_op): Process delta profile counter values.
	(__gcov_single_counter_op): Process single  profile counter values.
	(fp_scale): Callback function for float-point scaling.
	(int_scale): Callback function for integer fraction scaling. 
	(gcov_profile_scale): Scaling profile counters.
	(gcov_profile_normalize): Normalize profile counters.
	* libgcc/libgcov.h: Add headers and functions for gcov-tool use.
        (gcov_get_counter): New.
        (gcov_get_counter_target): Ditto.
        (struct gcov_info): Make the functions field mutable in gcov-tool
        compilation.
	* gcc/doc/gcc.texi: Include gcov-tool.texi.
	* gcc/doc/gcov-tool.texi: Document for gcov-tool.

From-SVN: r212448
2014-07-11 05:48:07 +00:00