r229212 - CodeGen: _Atomic(_Complex) shouldn't crash
David Majnemer
david.majnemer at gmail.com
Fri Feb 13 17:48:17 PST 2015
Author: majnemer
Date: Fri Feb 13 19:48:17 2015
New Revision: 229212
URL: http://llvm.org/viewvc/llvm-project?rev=229212&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/test/CodeGen/atomic_ops.c
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=229212&r1=229211&r2=229212&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Feb 13 19:48:17 2015
@@ -820,10 +820,14 @@ LValue CodeGenFunction::EmitLValue(const
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:
Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=229212&r1=229211&r2=229212&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Fri Feb 13 19:48:17 2015
@@ -820,6 +820,8 @@ EmitCompoundAssignLValue(const CompoundA
TestAndClearIgnoreReal();
TestAndClearIgnoreImag();
QualType LHSTy = E->getLHS()->getType();
+ if (const AtomicType *AT = LHSTy->getAs<AtomicType>())
+ LHSTy = AT->getValueType();
BinOpInfo OpInfo;
Modified: cfe/trunk/test/CodeGen/atomic_ops.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/atomic_ops.c?rev=229212&r1=229211&r2=229212&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/atomic_ops.c (original)
+++ cfe/trunk/test/CodeGen/atomic_ops.c Fri Feb 13 19:48:17 2015
@@ -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;
+}
More information about the cfe-commits
mailing list