[PATCH] D54291: [XRay] Add atomic fences around non-atomic reads and writes

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 18 22:47:19 PST 2018



> On 10 Nov 2018, at 15:41, JF Bastien via Phabricator via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> jfb added a comment.
> 
> In https://reviews.llvm.org/D54291#1293418, @efriedma wrote:
> 
>> What is the point of this change?  The atomic_fetch_add operations already use memory_order_acq_rel, so the explicit fences are redundant.
> 
> 
> Agreed, these are all redundant. Ideally the compiler just eliminates the fences, and your change was a no-op :-)
> 

Is it guaranteed though that non-atomic operations before the memory_order_acq_rel will have a “happens-before” relationship? It wasn’t clear that the memcpy’s before the atomic operation couldn’t be non-temporal writes (write-coalesced), and that the fences were necessary to ensure that those writes committed before the atomic operation was performed.

Is there something in the standard that I can look at to convince myself these fences are unnecessary?

Note also that these are not the same as the std::atomic<…> and family of operations (these are defined in the sanitiser common library).

Cheers

-- Dean



More information about the llvm-commits mailing list