diff options
author | Martin Liska <mliska@suse.cz> | 2020-10-19 17:40:00 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2020-10-27 11:49:54 +0100 |
commit | 14e19b82c1e67ead60c3095ac23347317298904b (patch) | |
tree | fde313742d6dd32a455e4246f7d5535178d5e30c /libgcc | |
parent | 21508c47f9a51f5b7dce35baee08fe95053ea85b (diff) | |
download | gcc-14e19b82c1e67ead60c3095ac23347317298904b.zip gcc-14e19b82c1e67ead60c3095ac23347317298904b.tar.gz gcc-14e19b82c1e67ead60c3095ac23347317298904b.tar.bz2 |
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.
Diffstat (limited to 'libgcc')
-rw-r--r-- | libgcc/libgcov.h | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h index 8be5beb..e70cf63 100644 --- a/libgcc/libgcov.h +++ b/libgcc/libgcov.h @@ -404,22 +404,16 @@ gcov_counter_add (gcov_type *counter, gcov_type value, *counter += value; } -/* Allocate gcov_kvp from heap. If we are recursively called, then allocate - it from a list of pre-allocated pool. */ +/* Allocate gcov_kvp from statically pre-allocated pool, + or use heap otherwise. */ static inline struct gcov_kvp * allocate_gcov_kvp (void) { struct gcov_kvp *new_node = NULL; - static -#if defined(HAVE_CC_TLS) -__thread -#endif - volatile unsigned in_recursion ATTRIBUTE_UNUSED = 0; - #if !defined(IN_GCOV_TOOL) && !defined(L_gcov_merge_topn) - if (__builtin_expect (in_recursion, 0)) + if (__gcov_kvp_pool_index < GCOV_PREALLOCATED_KVP) { unsigned index; #if GCOV_SUPPORTS_ATOMIC @@ -430,17 +424,11 @@ __thread #endif if (index < GCOV_PREALLOCATED_KVP) new_node = &__gcov_kvp_pool[index]; - else - /* Do not crash in the situation. */ - return NULL; } - else #endif - { - in_recursion = 1; - new_node = (struct gcov_kvp *)xcalloc (1, sizeof (struct gcov_kvp)); - in_recursion = 0; - } + + if (new_node == NULL) + new_node = (struct gcov_kvp *)xcalloc (1, sizeof (struct gcov_kvp)); return new_node; } |