Commit Graph

8 Commits

Author SHA1 Message Date
Daniel Sanders 933f0a04d3 Fix test/CodeGen/atomic_ops.c failure on clang-cmake-mips builder (and others).
Not all targets generate 'store atomic' instructions for
'_Atomic(_Complex int)'. Some targets use the __atomic_store builtin instead. 

This commit makes the test accept either one.

llvm-svn: 229676
2015-02-18 15:08:37 +00:00
David Majnemer 5927e7b681 CodeGen: Relax a FileCheck line for SystemZ
llvm-svn: 229617
2015-02-18 02:28:15 +00:00
David Majnemer ce27e42d47 CodeGen: _Atomic(_Complex) shouldn't crash
We could be a little kinder if we did a compare-exchange loop instead of
an atomic-load/store pair.

llvm-svn: 229212
2015-02-14 01:48:17 +00:00
David Majnemer 6866a3c6f4 CodeGen: Correctly convert atomic bool from i8 to i1
Bools are a little tricky, they are i8 in memory and must be coerced
back to i1 before further operations can be performed on them.

This fixes PR22577.

llvm-svn: 229204
2015-02-14 01:35:07 +00:00
Alexey Bataev a47ae907e8 Fixed test/CodeGen/atomic_ops.c for compatibility with hexagon target
llvm-svn: 224231
2014-12-15 06:12:42 +00:00
David Chisnall ef78c305fa Improve C11 atomics support:
- Generate atomicrmw operations in most of the cases when it's sensible to do
  so.
- Don't crash in several common cases (and hopefully don't crash in more of
  them).
- Add some better tests.

We now generate significantly better code for things like:
_Atomic(int) x;
...
x++;

On MIPS, this now generates a 4-instruction ll/sc loop, where previously it
generated about 30 instructions in two nested loops.  On x86-64, we generate a
single lock incl, instead of a lock cmpxchgl loop (one instruction instead of
ten).

llvm-svn: 176420
2013-03-03 16:02:42 +00:00
Eli Friedman 93ee5ca805 Fix Sema and IRGen for atomic compound assignment so it has the right semantics when promotions are involved.
(As far as I can tell, this only affects some edge cases.)

llvm-svn: 158591
2012-06-16 02:19:17 +00:00
David Chisnall fa35df628a Some improvements to the handling of C11 atomic types:
- 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
2012-01-16 17:27:18 +00:00