diff options
| author | Douglas Gregor <dgregor@apple.com> | 2012-04-12 20:42:30 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2012-04-12 20:42:30 +0000 |
| commit | 298f43df1498476155f3f9f4da6134e185ff6b48 (patch) | |
| tree | e0a03bc5b675f1b37a011c40cb86043ba79b6bbd /clang/lib/CodeGen | |
| parent | da76a94bcb607d5414959f7285be3f8daf762f53 (diff) | |
| download | bcm5719-llvm-298f43df1498476155f3f9f4da6134e185ff6b48.tar.gz bcm5719-llvm-298f43df1498476155f3f9f4da6134e185ff6b48.zip | |
Fix some i1/i8 confusion within _Atomic(bool) in IR generation, both
in general (such an atomic has boolean representation) and
specifically for IR generation of __c11_atomic_init. The latter also
means actually using initialization semantics for this initialization,
rather than just creating a store.
On a related note, make sure we actually put in non-atomic-to-atomic
conversions when performing an implicit conversion sequence. IR
generation is far too kind here, but we still want the ASTs to make
sense.
llvm-svn: 154612
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenTypes.cpp | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 147e7276bc4..0c33fb53711 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -867,6 +867,9 @@ static bool hasBooleanRepresentation(QualType Ty) { if (const EnumType *ET = Ty->getAs<EnumType>()) return ET->getDecl()->getIntegerType()->isBooleanType(); + if (const AtomicType *AT = Ty->getAs<AtomicType>()) + return hasBooleanRepresentation(AT->getValueType()); + return false; } @@ -1227,7 +1230,7 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, // Get the source value, truncated to the width of the bit-field. llvm::Value *SrcVal = Src.getScalarVal(); - if (Dst.getType()->isBooleanType()) + if (hasBooleanRepresentation(Dst.getType())) SrcVal = Builder.CreateIntCast(SrcVal, ResLTy, /*IsSigned=*/false); SrcVal = Builder.CreateAnd(SrcVal, llvm::APInt::getLowBitsSet(ResSizeInBits, @@ -2843,10 +2846,11 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { if (E->getOp() == AtomicExpr::AO__c11_atomic_init) { assert(!Dest && "Init does not return a value"); if (!hasAggregateLLVMType(E->getVal1()->getType())) { - llvm::StoreInst *Store = - Builder.CreateStore(EmitScalarExpr(E->getVal1()), Ptr); - Store->setAlignment(Size); - Store->setVolatile(E->isVolatile()); + QualType PointeeType + = E->getPtr()->getType()->getAs<PointerType>()->getPointeeType(); + EmitScalarInit(EmitScalarExpr(E->getVal1()), + LValue::MakeAddr(Ptr, PointeeType, alignChars, + getContext())); } else if (E->getType()->isAnyComplexType()) { EmitComplexExprIntoAddr(E->getVal1(), Ptr, E->isVolatile()); } else { diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index b47da73c1d6..41fd536b5cc 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -556,7 +556,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { } case Type::Atomic: { - ResultType = ConvertTypeForMem(cast<AtomicType>(Ty)->getValueType()); + ResultType = ConvertType(cast<AtomicType>(Ty)->getValueType()); break; } } |

