@@ -1450,6 +1450,8 @@ c_cpp_builtins (cpp_reader *pfile)
/* For libgcov. */
builtin_define_with_int_value ("__LIBGCC_VTABLE_USES_DESCRIPTORS__",
TARGET_VTABLE_USES_DESCRIPTORS);
+ builtin_define_with_int_value ("__LIBGCC_GCOV_TYPE_SIZE",
+ TARGET_GCOV_TYPE_SIZE);
}
/* For use in assembly language. */
@@ -40,3 +40,6 @@
/* Use the default */
#undef LINK_GCC_C_SEQUENCE_SPEC
+
+#undef TARGET_GCOV_TYPE_SIZE
+#define TARGET_GCOV_TYPE_SIZE 32
@@ -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 (targetm.gcov_type_size);
return lang_hooks.types.type_for_mode (mode, false);
}
@@ -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
+
+@deftypevr {Target Hook} HOST_WIDE_INT TARGET_GCOV_TYPE_SIZE
+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 deftypevr
@@ -8180,3 +8180,5 @@ maintainer is familiar with.
@hook TARGET_MEMTAG_EXTRACT_TAG
@hook TARGET_MEMTAG_UNTAGGED_POINTER
+
+@hook TARGET_GCOV_TYPE_SIZE
@@ -7104,6 +7104,18 @@ DEFHOOK
void, (void),
NULL)
+DEFHOOKPOD
+(gcov_type_size,
+ "The gcov type size in bits. This type is used for example for counters\n\
+incremented by profiling and code-coverage events. The default value is 64,\n\
+if the type size of long long is greater than 32, otherwise the default\n\
+value is 32. A 64-bit type is recommended to avoid overflows of the\n\
+counters. If the @option{-fprofile-update=atomic} is used, then the\n\
+counters are incremented using atomic operations. Targets not supporting\n\
+64-bit atomic operations may override the default value and request a 32-bit\n\
+type.",
+ HOST_WIDE_INT, (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32))
+
/* Close the 'struct gcc_target' definition. */
HOOK_VECTOR_END (C90_EMPTY_HACK)
@@ -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,
@@ -52,7 +52,7 @@
#if __CHAR_BIT__ == 8
typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI)));
typedef unsigned gcov_position_t __attribute__ ((mode (SI)));
-#if LONG_LONG_TYPE_SIZE > 32
+#if __LIBGCC_GCOV_TYPE_SIZE > 32
typedef signed gcov_type __attribute__ ((mode (DI)));
typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI)));
#else
@@ -63,7 +63,7 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
#if __CHAR_BIT__ == 16
typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI)));
typedef unsigned gcov_position_t __attribute__ ((mode (HI)));
-#if LONG_LONG_TYPE_SIZE > 32
+#if __LIBGCC_GCOV_TYPE_SIZE > 32
typedef signed gcov_type __attribute__ ((mode (SI)));
typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI)));
#else
@@ -73,7 +73,7 @@ typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
#else
typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI)));
typedef unsigned gcov_position_t __attribute__ ((mode (QI)));
-#if LONG_LONG_TYPE_SIZE > 32
+#if __LIBGCC_GCOV_TYPE_SIZE > 32
typedef signed gcov_type __attribute__ ((mode (HI)));
typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI)));
#else