diff options
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 147e7276bc..0c33fb5371 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/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 { |