aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGExpr.cpp6
-rw-r--r--lib/CodeGen/CGExprAgg.cpp2
-rw-r--r--lib/CodeGen/CGExprComplex.cpp2
-rw-r--r--test/CodeGenCXX/volatile-1.cpp2
4 files changed, 7 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 011233c58f..6cc573c0cf 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1951,10 +1951,10 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
assert(E->getOpcode() == BO_Assign && "unexpected binary l-value");
if (!hasAggregateLLVMType(E->getType())) {
- // Emit the LHS as an l-value.
+ // __block variables need the RHS evaluated first.
+ RValue RV = EmitAnyExpr(E->getRHS());
LValue LV = EmitLValue(E->getLHS());
- // Store the value through the l-value.
- EmitStoreThroughLValue(EmitAnyExpr(E->getRHS()), LV, E->getType());
+ EmitStoreThroughLValue(RV, LV, E->getType());
return LV;
}
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 73bb9ef3fb..ffe1739a0e 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -389,6 +389,8 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) {
assert(CGF.getContext().hasSameUnqualifiedType(E->getLHS()->getType(),
E->getRHS()->getType())
&& "Invalid assignment");
+
+ // FIXME: __block variables need the RHS evaluated first!
LValue LHS = CGF.EmitLValue(E->getLHS());
// We have to special case property setters, otherwise we must have
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index 89a3a26ed6..7896504d86 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -602,7 +602,7 @@ LValue ComplexExprEmitter::EmitBinAssignLValue(const BinaryOperator *E,
TestAndClearIgnoreReal();
TestAndClearIgnoreImag();
- // Emit the RHS.
+ // Emit the RHS. __block variables need the RHS evaluated first.
Val = Visit(E->getRHS());
// Compute the address to store into.
diff --git a/test/CodeGenCXX/volatile-1.cpp b/test/CodeGenCXX/volatile-1.cpp
index ba43471abf..0569150101 100644
--- a/test/CodeGenCXX/volatile-1.cpp
+++ b/test/CodeGenCXX/volatile-1.cpp
@@ -346,9 +346,9 @@ void test() {
// CHECK-NEXT: volatile store {{.*}}, [[INT]]* @j
(j=k,i)=i;
+ // CHECK-NEXT: volatile load [[INT]]* @i
// CHECK-NEXT: volatile load [[INT]]* @k
// CHECK-NEXT: volatile store {{.*}}, [[INT]]* @j
- // CHECK-NEXT: volatile load [[INT]]* @i
// CHECK-NEXT: volatile store {{.*}}, [[INT]]* @i
// CHECK-NEXT: ret void