[cfe-dev] FYI, Intel folks might be looking to add the __iso_volatile_Xxx family for MSVC STL <atomic> soon
Eli Friedman via cfe-dev
cfe-dev at lists.llvm.org
Tue Jul 30 17:21:26 PDT 2019
From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Reid Kleckner via cfe-dev
Sent: Tuesday, July 30, 2019 4:54 PM
To: Billy O'Neal (VC LIBS) <bion at microsoft.com>
Cc: cfe-dev <cfe-dev at lists.llvm.org>
Subject: [EXT] Re: [cfe-dev] FYI, Intel folks might be looking to add the __iso_volatile_Xxx family for MSVC STL <atomic> soon
On Tue, Jul 30, 2019 at 4:15 PM Billy O'Neal (VC LIBS) <bion at microsoft.com<mailto:bion at microsoft.com>> wrote:
> we can worry about optimization, perhaps using _Atomic, later
We can’t use _Atomic because it would not be ABI compatible with our std::atomic; in particular, because we put the spinlock for non-lock-free atomics inside the atomic, for instance. And because that isn’t a thing for some of our supported frontends.
It is possible that there are different intrinsics we could call for Clang that would make you folks happier, but we don’t know what those are or even if they exist at present.
I was thinking that perhaps the _Atomic_address_as template would do the necessary casts to use it when necessary without changing the storage type inside the std::atomic object.
There are actually multiple APIs to access C++11 atomics in clang, since we invented APIs in parallel with gcc. The __atomic_* builtins (https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html) don’t require the use of _Atomic types.
Using volatile loads and stores with barriers probably prevents the compiler from performing any breaking optimizations, assuming the RMW atomics are protected appropriately, and the user doesn’t call any of the clang atomic builtins directly. But it’s not a good idea; it won’t optimize well. For example, on AArch64, it will prevent the compiler from using the dedicated load-acquire and store-release instructions.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev