[cxx-mem-model] disallow load data races (1 of some)
Joseph S. Myers
joseph@codesourcery.com
Thu Mar 24 21:51:00 GMT 2011
On Thu, 24 Mar 2011, Aldy Hernandez wrote:
> This work is independent of the C++ memory model. It is just to prevent the
> optimizers from introducing new data races due to code movement. This initial
> pass is just to make the optimizations data race safe so that if you have a
> program which is proven to be free of data races, you can run the optimizers
> and it will still be data race free after the optimizers have been run.
>
> See the following summary by Andrew (which in turn is based on a paper by Hans
> Boehm):
>
> http://gcc.gnu.org/wiki/Atomic/GCCMM/DataRaces
But hoisting global in this case doesn't result in a data race, since the
loop always accesses global and contains no synchronisation code. If it
were only accessed conditionally, as in the examples under "Avoiding
Speculation" on that page, then there would be a race in hoisting it, but
not for the code you gave; any data races with the hoisting would still
have been present without it.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list