aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-09 09:06:14 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-08-16 15:34:25 +0200
commit8cdcea51c0fd753e6a652c9b236e91b3a6e0911c (patch)
treedfcfac7563c68b9b7d4397ae649b6b8a55c2c832 /gcc/doc
parentbe024a1285840bf2fc47fcbde32375468a92ce05 (diff)
downloadgcc-8cdcea51c0fd753e6a652c9b236e91b3a6e0911c.zip
gcc-8cdcea51c0fd753e6a652c9b236e91b3a6e0911c.tar.gz
gcc-8cdcea51c0fd753e6a652c9b236e91b3a6e0911c.tar.bz2
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.
Diffstat (limited to 'gcc/doc')
-rw-r--r--gcc/doc/tm.texi11
-rw-r--r--gcc/doc/tm.texi.in2
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index a30fdcb..f68f426 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -12588,3 +12588,14 @@ Return an RTX representing @var{tagged_pointer} with its tag set to zero.
Store the result in @var{target} if convenient.
The default clears the top byte of the original pointer.
@end deftypefn
+
+@deftypefn {Target Hook} HOST_WIDE_INT TARGET_GCOV_TYPE_SIZE (void)
+Returns the gcov type size in bits. This type is used for example for
+counters incremented by profiling and code-coverage events. The default
+value is 64, if the type size of long long is greater than 32, otherwise the
+default value is 32. A 64-bit type is recommended to avoid overflows of the
+counters. If the @option{-fprofile-update=atomic} is used, then the
+counters are incremented using atomic operations. Targets not supporting
+64-bit atomic operations may override the default value and request a 32-bit
+type.
+@end deftypefn
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 611fc50..fdf16b9 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -8180,3 +8180,5 @@ maintainer is familiar with.
@hook TARGET_MEMTAG_EXTRACT_TAG
@hook TARGET_MEMTAG_UNTAGGED_POINTER
+
+@hook TARGET_GCOV_TYPE_SIZE