[RFC] Fix full memory barrier on SPARC-V8

Eric Botcazou ebotcazou@adacore.com
Tue Jun 28 08:36:00 GMT 2011

> Let's clarify something, did you run your testcase that triggered this
> bug on a v8 or a v9 machine?

Sun UltraSPARC, so V9 of course.  The point is that Solaris is TSO (TSO as 
defined for the V9 architecture, i.e. backward compatible with V8) so you have 
a V8-compatible TSO implementation, in particular not a Strong Consistency V8.

It is perfectly valid to compile with -mcpu=v8 on Solaris and expect to get a 
working program.  Now if you start to play seriously with __sync_synchronize, 
you conclude that it doesn't implement a full memory barrier with -mcpu=v8.

The V8 architecture manual is quite clear about it: TSO allows stores to be 
reordered after subsequent loads (it's the only difference in TSO with Strong 
Consistency) so you need to do something to have a full memory barrier.  As 
there is no specific instruction to that effect in V8, you need to do what is 
done for pre-SSE2 x86, i.e. use an atomic instruction.

Eric Botcazou

More information about the Gcc-patches mailing list