This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Detect whether target can use -fprofile-update=atomic
On Tue, Sep 06, 2016 at 02:45:32PM +0200, Martin Liška wrote:
> --- a/gcc/tree-profile.c
> +++ b/gcc/tree-profile.c
> @@ -528,6 +528,13 @@ gimple_gen_ior_profiler (histogram_value value, unsigned tag, unsigned base)
> gsi_insert_before (&gsi, call, GSI_NEW_STMT);
> }
>
> +#ifndef HAVE_sync_compare_and_swapsi
> +#define HAVE_sync_compare_and_swapsi 0
> +#endif
> +#ifndef HAVE_atomic_compare_and_swapsi
> +#define HAVE_atomic_compare_and_swapsi 0
> +#endif
> +
> /* Profile all functions in the callgraph. */
>
> static unsigned int
> @@ -535,6 +542,16 @@ tree_profiling (void)
> {
> struct cgraph_node *node;
>
> + /* Verify whether we can utilize atomic update operations. */
> + if (flag_profile_update == PROFILE_UPDATE_ATOMIC
> + && !HAVE_sync_compare_and_swapsi
> + && !HAVE_atomic_compare_and_swapsi)
This isn't in sync with:
> +/* Detect whether target can support atomic update of profilers. */
> +#if LONG_LONG_TYPE_SIZE <= 32 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
> +#define GCOV_SUPPORTS_ATOMIC 1
> +#else
> +#if LONG_LONG_TYPE_SIZE > 32 && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
> +#define GCOV_SUPPORTS_ATOMIC 1
> +#else
> +#define GCOV_SUPPORTS_ATOMIC 0
> +#endif
> +#endif
this. Either you implement the poor man's 64-bit atomics with 32-bit cas
and adjust the latter, or the former needs to look at the target's gcov type
(long long always?) and depending on its size either test the HAVE_*si or
HAVE_*di macros.
Jakub