]> granicus.if.org Git - clang/commit
Add __sync_fetch_and_nand (again)
authorHal Finkel <hfinkel@anl.gov>
Thu, 2 Oct 2014 20:53:50 +0000 (20:53 +0000)
committerHal Finkel <hfinkel@anl.gov>
Thu, 2 Oct 2014 20:53:50 +0000 (20:53 +0000)
commit536d2778eb33a3ad41018dd6272a892538bad890
tree361202baff0ff0bc78402235decb7f57f99f8ffd
parent328cf9877b2f75c273ee1e8b4a62d27496131cbd
Add __sync_fetch_and_nand (again)

Prior to GCC 4.4, __sync_fetch_and_nand was implemented as:

  { tmp = *ptr; *ptr = ~tmp & value; return tmp; }

but this was changed in GCC 4.4 to be:

  { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }

in response to this change, support for sync_fetch_and_nand (and
sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code
depending on the old semantics. However, at this point:

  1. Many years have passed, and the amount of code relying on the old
     semantics is likely smaller.

  2. Through the work of many contributors, all LLVM backends have been updated
     such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process
     was complete July of 2014 (added to the release notes in r212635).

  3. The lack of this intrinsic is now a needless impediment to porting codes
     from GCC to Clang (I've now seen several examples of this).

It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC
4.2). To compensate for this, and to address the original concern regarding
code relying on the old semantics, I've added a warning that specifically
details the fact that the semantics have changed and that we provide the newer
semantics.

Fixes PR8842.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218905 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/Builtins.def
include/clang/Basic/DiagnosticSemaKinds.td
lib/CodeGen/CGBuiltin.cpp
lib/Sema/SemaChecking.cpp
test/CodeGen/Atomics.c
test/CodeGen/atomic.c
test/Sema/builtins.c