]> granicus.if.org Git - clang/commit
Atomics: support __c11_* calls on _Atomic struct types.
authorTim Northover <tnorthover@apple.com>
Mon, 9 Nov 2015 19:56:35 +0000 (19:56 +0000)
committerTim Northover <tnorthover@apple.com>
Mon, 9 Nov 2015 19:56:35 +0000 (19:56 +0000)
commit6a3c4de2f12eb621272f82b5185124c1806bee5e
tree29d7810a12ff0fec9ac1ffe21e90d50fbaf733ae
parent272f51152df17b16d549f37fca32fe68cb38f401
Atomics: support __c11_* calls on _Atomic struct types.

When a struct's size is not a power of 2, the corresponding _Atomic() type is
promoted to the nearest. We already correctly handled normal C++ expressions of
this form, but direct calls to the __c11_atomic_whatever builtins ended up
performing dodgy operations on the smaller non-atomic types (e.g. memcpy too
much). Later optimisations removed this as undefined behaviour.

This patch converts EmitAtomicExpr to allocate its temporaries at the full
atomic width, sidestepping the issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252507 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGAtomic.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/atomic-arm64.c
test/CodeGen/atomic-ops.c
test/CodeGen/c11atomics-ios.c
test/CodeGen/c11atomics.c