* [PATCH] gcov: Add GCOV_TYPE_SIZE target macro
@ 2021-08-09 13:58 Sebastian Huber
2021-08-09 18:34 ` Sebastian Huber
0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Huber @ 2021-08-09 13:58 UTC (permalink / raw)
To: gcc-patches
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 GCOV_TYPE_SIZE target macro.
gcc/
* config/sparc/rtemself.h (GCOV_TYPE_SIZE): Define.
* coverage.c (get_gcov_type): Use GCOV_TYPE_SIZE.
* defaults.h (GCOV_TYPE_SIZE): Define default.
* tree-profile.c (gimple_gen_edge_profiler): Use precision of
gcov_type_node.
(gimple_gen_time_profiler): Likewise.
---
gcc/config/sparc/rtemself.h | 2 ++
gcc/coverage.c | 3 +--
gcc/defaults.h | 4 ++++
gcc/tree-profile.c | 4 ++--
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/gcc/config/sparc/rtemself.h b/gcc/config/sparc/rtemself.h
index fa972af640c..ac4f70c48c4 100644
--- a/gcc/config/sparc/rtemself.h
+++ b/gcc/config/sparc/rtemself.h
@@ -40,3 +40,5 @@
/* Use the default */
#undef LINK_GCC_C_SEQUENCE_SPEC
+
+#define GCOV_TYPE_SIZE 32
diff --git a/gcc/coverage.c b/gcc/coverage.c
index ac9a9fdad22..e655c164d66 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -145,8 +145,7 @@ static void coverage_obj_finish (vec<constructor_elt, va_gc> *);
tree
get_gcov_type (void)
{
- scalar_int_mode mode
- = smallest_int_mode_for_size (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32);
+ scalar_int_mode mode = smallest_int_mode_for_size (GCOV_TYPE_SIZE);
return lang_hooks.types.type_for_mode (mode, false);
}
diff --git a/gcc/defaults.h b/gcc/defaults.h
index ba79a8e48ed..1cf06d26176 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1475,4 +1475,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
typedef TARGET_UNIT target_unit;
#endif
+#ifndef GCOV_TYPE_SIZE
+#define GCOV_TYPE_SIZE (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32)
+#endif
+
#endif /* ! GCC_DEFAULTS_H */
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 5a74cc96e13..cf46912631c 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -250,7 +250,7 @@ gimple_gen_edge_profiler (int edgeno, edge e)
{
/* __atomic_fetch_add (&counter, 1, MEMMODEL_RELAXED); */
tree addr = tree_coverage_counter_addr (GCOV_COUNTER_ARCS, edgeno);
- tree f = builtin_decl_explicit (LONG_LONG_TYPE_SIZE > 32
+ tree f = builtin_decl_explicit (TYPE_PRECISION (gcov_type_node) > 32
? BUILT_IN_ATOMIC_FETCH_ADD_8:
BUILT_IN_ATOMIC_FETCH_ADD_4);
gcall *stmt = gimple_build_call (f, 3, addr, one,
@@ -525,7 +525,7 @@ gimple_gen_time_profiler (unsigned tag)
tree_time_profiler_counter);
gassign *assign = gimple_build_assign (ptr, NOP_EXPR, addr);
gsi_insert_before (&gsi, assign, GSI_NEW_STMT);
- tree f = builtin_decl_explicit (LONG_LONG_TYPE_SIZE > 32
+ tree f = builtin_decl_explicit (TYPE_PRECISION (gcov_type_node) > 32
? BUILT_IN_ATOMIC_ADD_FETCH_8:
BUILT_IN_ATOMIC_ADD_FETCH_4);
gcall *stmt = gimple_build_call (f, 3, ptr, one,
--
2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gcov: Add GCOV_TYPE_SIZE target macro
2021-08-09 13:58 [PATCH] gcov: Add GCOV_TYPE_SIZE target macro Sebastian Huber
@ 2021-08-09 18:34 ` Sebastian Huber
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Huber @ 2021-08-09 18:34 UTC (permalink / raw)
To: gcc-patches
On 09/08/2021 15:58, Sebastian Huber wrote:
> 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 GCOV_TYPE_SIZE target macro.
>
> gcc/
>
> * config/sparc/rtemself.h (GCOV_TYPE_SIZE): Define.
> * coverage.c (get_gcov_type): Use GCOV_TYPE_SIZE.
> * defaults.h (GCOV_TYPE_SIZE): Define default.
> * tree-profile.c (gimple_gen_edge_profiler): Use precision of
> gcov_type_node.
> (gimple_gen_time_profiler): Likewise.
The patch is incorrect. With this patch the compiler view of the gcov
type doesn't match the libgcov view. I have to do some changes in
libgcov.h in this area:
#if LONG_LONG_TYPE_SIZE > 32
typedef signed gcov_type __attribute__ ((mode (DI)));
typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI)));
#else
typedef signed gcov_type __attribute__ ((mode (SI)));
typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
#endif
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-09 18:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 13:58 [PATCH] gcov: Add GCOV_TYPE_SIZE target macro Sebastian Huber
2021-08-09 18:34 ` Sebastian Huber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).