[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

Dimitry Andric via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 14:20:48 PST 2017

dim added a comment.

In https://reviews.llvm.org/D28213#666269, @dim wrote:

> In https://reviews.llvm.org/D28213#666196, @mgorny wrote:
> >


>> What's the value of `__atomic_always_lock_free(sizeof(long long), 0)` for gcc and clang?
> For gcc, it is always 0, for clang (I tested 3.4.1 through 4.0.0) it is always 1.  Maybe that was always incorrect on 32-bit FreeBSD, then?

Hmm, I just noticed the following rather disappointing comment in `tools/clang/lib/Basic/Targets.cpp`:

  X86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
      : X86TargetInfo(Triple, Opts) {
    // x86-32 has atomics up to 8 bytes
    // FIXME: Check that we actually have cmpxchg8b before setting
    // MaxAtomicInlineWidth. (cmpxchg8b is an i586 instruction.)
    MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;

So this can never have worked properly for e.g. i486 and i586...



More information about the cfe-commits mailing list