- Add atomic-to/from-nonatomic cast types - Emit atomic operations for arithmetic on atomic types - Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load - Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type. This is needed for the corresponding C11 stdatomic.h function. - Enables the relevant __has_feature() checks. The feature isn't 100% complete yet, but it's done enough that we want people testing it. Still to do: - Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg. - Add a signal fence builtin - Properly set the fenv state in atomic operations on floating point values - Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context) - Fix the many remaining corner cases llvm-svn: 148242
15 lines
400 B
C
15 lines
400 B
C
// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
|
|
|
|
void foo(void)
|
|
{
|
|
_Atomic(int) i = 0;
|
|
// Check that multiply / divides on atomics produce a cmpxchg loop
|
|
i *= 2; // CHECK: cmpxchg
|
|
i /= 2; // CHECK: cmpxchg
|
|
// These should be emitting atomicrmw instructions, but they aren't yet
|
|
i += 2; // CHECK: cmpxchg
|
|
i -= 2; // CHECK: cmpxchg
|
|
i++; // CHECK: cmpxchg
|
|
i--; // CHECK: cmpxchg
|
|
}
|