[cfe-dev] RFC: __atomic_* support for gcc 4.7 compatibility

Richard Smith richard at metafoo.co.uk
Tue Apr 10 12:22:57 PDT 2012


Hi,

I'm looking into adding support for gcc 4.7's __atomic_* builtins for the
clang 3.1 release (these are necessary to support various parts of
libstdc++4.7). Our current set of __atomic_* builtins is incompatible with
gcc 4.7's builtins in a few ways:

1) In clang, the builtins produce results by value, whereas in gcc, a
pointer is passed indicating where the result should be written.
2) In clang, the argument type must be an _Atomic. gcc does not have this
restriction (but also fails to require that the type is trivially copyable,
which is probably a bug).
3) Clang is missing the __atomic_*_n, __atomic_always_lock_free and
__atomic_fetch_nand builtins.
4) Clang is missing the __atomic_compare_exchange builtin, and instead
provides __atomic_compare_exchange_strong and
__atomic_compare_exchange_weak.
5) Clang provides an __atomic_init builtin, which gcc does not provide, and
which crashes during CodeGen.

My current plan is:

For (1), add support for the gcc-style arguments, then port libc++ over to
them, then remove support for the current arguments.
For (2), relax the requirement to the type being either _Atomic or
trivially copyable.
For (3) and (4), add the missing builtins. I don't intend to remove the
__atomic_compare_exchange_strong/__atomic_compare_exchange_weak builtins,
but will do so if anyone particularly wants to see them gone.
For (5), remove this builtin.

Please shout now if any part of this displeases you! In particular, if you
have code depending on clang's current pass-by-value atomics and you'd like
to see them left in until after the clang 3.1 release to give you more time
to move to the portable forms (or indeed you believe they should be left
in-place forever), please say so.

Thanks!
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120410/2012a884/attachment.html>


More information about the cfe-dev mailing list