summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDavid Chisnall <csdavec@swan.ac.uk>2012-04-11 17:24:05 +0000
committerDavid Chisnall <csdavec@swan.ac.uk>2012-04-11 17:24:05 +0000
commit5d70cfddc8a8a450d1425e190f10512a51352e5d (patch)
tree9154298ae7aab4b2eee68413d5c15fcdb2ce6345 /lib
parentadf7c854380cecb649e64a6ea1b5dbaf166a4365 (diff)
Make __atomic_init() (soon to be __c11_atomic_init()) work with non-scalar types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154507 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/CGExpr.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index dbf41f38b8..260fa5b529 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -2786,10 +2786,21 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) {
if (E->getOp() == AtomicExpr::Init) {
assert(!Dest && "Init does not return a value");
- Val1 = EmitScalarExpr(E->getVal1());
- llvm::StoreInst *Store = Builder.CreateStore(Val1, Ptr);
- Store->setAlignment(Size);
- Store->setVolatile(E->isVolatile());
+ if (!hasAggregateLLVMType(E->getVal1()->getType())) {
+ llvm::StoreInst *Store =
+ Builder.CreateStore(EmitScalarExpr(E->getVal1()), Ptr);
+ Store->setAlignment(Size);
+ Store->setVolatile(E->isVolatile());
+ } else if (E->getType()->isAnyComplexType()) {
+ EmitComplexExprIntoAddr(E->getVal1(), Ptr, E->isVolatile());
+ } else {
+ AggValueSlot Slot = AggValueSlot::forAddr(Ptr, alignChars,
+ AtomicTy.getQualifiers(),
+ AggValueSlot::IsNotDestructed,
+ AggValueSlot::DoesNotNeedGCBarriers,
+ AggValueSlot::IsNotAliased);
+ EmitAggExpr(E->getVal1(), Slot);
+ }
return RValue::get(0);
}