[llvm-commits] [llvm] r137145 - /llvm/trunk/docs/Atomics.html

Jeffrey Yasskin jyasskin at google.com
Wed Aug 10 14:15:21 PDT 2011


On Wed, Aug 10, 2011 at 1:17 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Wed, Aug 10, 2011 at 10:05 AM, Jeffrey Yasskin <jyasskin at google.com> wrote:
>> On Tue, Aug 9, 2011 at 2:07 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>>> +<p>Monotonic is the weakest level of atomicity that can be used in
>>> +   synchronization primitives, although it does not provide any general
>>> +   synchronization. It essentially guarantees that if you take all the
>>> +   operations affecting a specific address, a consistent ordering exists.
>>> +   This corresponds to the C++0x/C1x <code>memory_order_relaxed</code>; see
>>> +   those standards for the exact definition.  If you are writing a frontend, do
>>> +   not use the low-level synchronization primitives unless you are compiling
>>> +   a language which requires it or are sure a given pattern is correct. In
>>> +   terms of the optimizer, this can be treated as a read+write on the relevant
>>> +   memory location (and alias analysis will take advantage of that).  In
>>> +   addition, it is legal to reorder non-atomic and Unordered loads around
>>> +   Monotonic loads. CSE/DSE and a few other optimizations are allowed, but
>>
>> It's also legal to reorder monotonic operations around each other as
>> long as you can prove they don't alias. (Think 'load a; load b; load
>> a" -> Normally it'd be fine to collapse the two  'load a's with no
>> aliasing check, but with monotonic atomics, you can only do that if
>> a!=b.)
>
> I though that was implied by "can be treated as a read+write on the relevant
> memory location".

Ah, ok. That makes sense.




More information about the llvm-commits mailing list