forked from OSchip/llvm-project
CodeGen: _Atomic(_Complex) shouldn't crash
We could be a little kinder if we did a compare-exchange loop instead of an atomic-load/store pair. llvm-svn: 229212
This commit is contained in:
parent
7ddf832e0e
commit
ce27e42d47
|
@ -820,10 +820,14 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
|||
return EmitObjCIsaExpr(cast<ObjCIsaExpr>(E));
|
||||
case Expr::BinaryOperatorClass:
|
||||
return EmitBinaryOperatorLValue(cast<BinaryOperator>(E));
|
||||
case Expr::CompoundAssignOperatorClass:
|
||||
if (!E->getType()->isAnyComplexType())
|
||||
case Expr::CompoundAssignOperatorClass: {
|
||||
QualType Ty = E->getType();
|
||||
if (const AtomicType *AT = Ty->getAs<AtomicType>())
|
||||
Ty = AT->getValueType();
|
||||
if (!Ty->isAnyComplexType())
|
||||
return EmitCompoundAssignmentLValue(cast<CompoundAssignOperator>(E));
|
||||
return EmitComplexCompoundAssignmentLValue(cast<CompoundAssignOperator>(E));
|
||||
}
|
||||
case Expr::CallExprClass:
|
||||
case Expr::CXXMemberCallExprClass:
|
||||
case Expr::CXXOperatorCallExprClass:
|
||||
|
|
|
@ -820,6 +820,8 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
|
|||
TestAndClearIgnoreReal();
|
||||
TestAndClearIgnoreImag();
|
||||
QualType LHSTy = E->getLHS()->getType();
|
||||
if (const AtomicType *AT = LHSTy->getAs<AtomicType>())
|
||||
LHSTy = AT->getValueType();
|
||||
|
||||
BinOpInfo OpInfo;
|
||||
|
||||
|
|
|
@ -26,3 +26,11 @@ _Bool bar() {
|
|||
// CHECK: ret i1 %[[tobool]]
|
||||
return b;
|
||||
}
|
||||
|
||||
extern _Atomic(_Complex int) x;
|
||||
|
||||
void baz(int y) {
|
||||
// CHECK-LABEL: @baz
|
||||
// CHECK: store atomic
|
||||
x += y;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue