Improve C11 atomics support:
authorDavid Chisnall <csdavec@swan.ac.uk>
Sun, 3 Mar 2013 16:02:42 +0000 (16:02 +0000)
committerDavid Chisnall <csdavec@swan.ac.uk>
Sun, 3 Mar 2013 16:02:42 +0000 (16:02 +0000)
commitef78c305faa1eee1e5a402dfd3a4d2ecb3ec7b5e
tree1ecb7f937714d2e120ee77ff71d279e280e6cd75
parente0a5c0d9142c2ad445ff87dc7061a3ecf5fa4e6b
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
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/atomic_ops.c
clang/test/CodeGen/c11atomics.c [new file with mode: 0644]