This is the mail archive of the
mailing list for the GCC project.
Re: volatile access optimization (C++ / x86_64)
- From: Torvald Riegel <triegel at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: Matt Godbolt <matt at godbolt dot org>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Tue, 30 Dec 2014 11:55:16 +0100
- Subject: Re: volatile access optimization (C++ / x86_64)
- Authentication-results: sourceware.org; auth=none
- References: <CAFWXXN3quEdSnaoWuPcQn2k-F99Yaw+6=NqgFgcu9ABpv5ZD3Q at mail dot gmail dot com> <549DE09B dot 8060502 at redhat dot com> <CAFWXXN0V9yvNTpcz54DCK237KPURQs1XkaHcQZK5Eoj_VCj0OA at mail dot gmail dot com> <549DED1B dot 3070006 at redhat dot com>
On Fri, 2014-12-26 at 23:19 +0000, Andrew Haley wrote:
> On 26/12/14 22:49, Matt Godbolt wrote:
> > At the moment I think the best I can do is to use an inline assembly
> > version of the increment which prevents GCC from doing any
> > optimisation upon it. That seems rather ugly though, and if anyone has
> > any better suggestions I'd be very grateful.
> Well, that's the problem: do you want a barrier or not? With no
> barrier there is no guarantee that the data will ever be written to
> memory. Do you only care about x86 processors?
The C++11 memory model guarantees the following though (1.10p25):
An implementation should ensure that the last value (in modification
order) assigned by an atomic or synchronization operation will become
visible to all other threads in a finite period of time.