diff options
| author | David Chisnall <csdavec@swan.ac.uk> | 2012-01-16 17:27:18 +0000 |
|---|---|---|
| committer | David Chisnall <csdavec@swan.ac.uk> | 2012-01-16 17:27:18 +0000 |
| commit | fa35df628a4ab331347dc448ccde573d6a7fa81d (patch) | |
| tree | bfd08bb857ccb2b66b87541d23e8a439ab0b336e /clang/lib/CodeGen/CGDecl.cpp | |
| parent | 44a2895a0369ba2149f6ed4dc5f90197e854b5be (diff) | |
| download | bcm5719-llvm-fa35df628a4ab331347dc448ccde573d6a7fa81d.tar.gz bcm5719-llvm-fa35df628a4ab331347dc448ccde573d6a7fa81d.zip | |
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
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index dd7cdb69a81..7c7501ba946 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -494,7 +494,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, llvm::Value *value = EmitScalarExpr(init); if (capturedByInit) drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D)); - EmitStoreThroughLValue(RValue::get(value), lvalue); + EmitStoreThroughLValue(RValue::get(value), lvalue, true); return; } @@ -535,7 +535,7 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, // Otherwise just do a simple store. else - EmitStoreOfScalar(zero, tempLV); + EmitStoreOfScalar(zero, tempLV, /* isInitialization */ true); } // Emit the initializer. @@ -581,19 +581,19 @@ void CodeGenFunction::EmitScalarInit(const Expr *init, // both __weak and __strong, but __weak got filtered out above. if (accessedByInit && lifetime == Qualifiers::OCL_Strong) { llvm::Value *oldValue = EmitLoadOfScalar(lvalue); - EmitStoreOfScalar(value, lvalue); + EmitStoreOfScalar(value, lvalue, /* isInitialization */ true); EmitARCRelease(oldValue, /*precise*/ false); return; } - EmitStoreOfScalar(value, lvalue); + EmitStoreOfScalar(value, lvalue, /* isInitialization */ true); } /// EmitScalarInit - Initialize the given lvalue with the given object. void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) { Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime(); if (!lifetime) - return EmitStoreThroughLValue(RValue::get(init), lvalue); + return EmitStoreThroughLValue(RValue::get(init), lvalue, true); switch (lifetime) { case Qualifiers::OCL_None: @@ -617,7 +617,7 @@ void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) { break; } - EmitStoreOfScalar(init, lvalue); + EmitStoreOfScalar(init, lvalue, /* isInitialization */ true); } /// canEmitInitWithFewStoresAfterMemset - Decide whether we can emit the @@ -1045,7 +1045,7 @@ void CodeGenFunction::EmitExprAsInit(const Expr *init, RValue rvalue = EmitReferenceBindingToExpr(init, D); if (capturedByInit) drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D)); - EmitStoreThroughLValue(rvalue, lvalue); + EmitStoreThroughLValue(rvalue, lvalue, true); } else if (!hasAggregateLLVMType(type)) { EmitScalarInit(init, D, lvalue, capturedByInit); } else if (type->isAnyComplexType()) { @@ -1505,7 +1505,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg, if (doStore) { LValue lv = MakeAddrLValue(DeclPtr, Ty, getContext().getDeclAlign(&D)); - EmitStoreOfScalar(Arg, lv); + EmitStoreOfScalar(Arg, lv, /* isInitialization */ true); } } |

