https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108552

--- Comment #46 from rguenther at suse dot de <rguenther at suse dot de> ---
On Mon, 30 Jan 2023, jakub at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108552
> 
> --- Comment #44 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
> I guess we should try and see.
> For volatile,
> --- gcc/coverage.cc     2023-01-02 09:32:37.078072992 +0100
> +++ gcc/coverage.cc     2023-01-30 09:24:45.219951352 +0100
> @@ -774,6 +774,7 @@ build_var (tree fn_decl, tree type, int
>    TREE_STATIC (var) = 1;
>    TREE_ADDRESSABLE (var) = 1;
>    DECL_NONALIASED (var) = 1;
> +  TREE_THIS_VOLATILE (var) = 1;
>    SET_DECL_ALIGN (var, TYPE_ALIGN (type));
> 
>    return var;
> 
> would do it I think (but it should be conditional on new -fupdate-profile
> modes, single-volatile and prefer-atomic-volatile or something similar).
> Or perhaps insert asm volatile ("" : "+g" (tmp)); in between the load and 
> store
> and see how that compares to the volatile vars? Or adding another flag on the
> gcov vars next to DECL_NONALIASED and just avoid specific optimizations on it
> that somebody runs into (not as reliable but could be faster) - for now
> hoisting in LIM and sinking.

We could put an __attribute__(("semi atomic")) on them ... it all somewhat
feels like a hack.  We could make half of the update volatile only,
like only make the store volatile, not the read?

Reply via email to