aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprScalar.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-11-19 09:36:46 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-11-19 09:36:46 +0000
commited3849b456d64d124bddc7ac044f3ce590bd9d69 (patch)
tree193bbf25cb13d521e5b32f8e680d2a215f8b4153 /lib/CodeGen/CGExprScalar.cpp
parent8fbc1540966901a0b2b033c92f4c4257c08621f8 (diff)
Fix redundant load of bit-fields on assignment (to get the updated
value). - Use extra argument to EmitStoreThroughLValue to provide place to write update bit-field value if caller requires it. - This fixes several FIXMEs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r--lib/CodeGen/CGExprScalar.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index d87edc3e7b..b236a6ad31 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -786,15 +786,14 @@ Value *ScalarExprEmitter::EmitCompoundAssign(const CompoundAssignOperator *E,
// Convert the result back to the LHS type.
Result = EmitScalarConversion(Result, ResultTy, LHSTy);
- // Store the result value into the LHS lvalue.
- CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, LHSTy);
-
- // For bitfields, we need the value in the bitfield. Note that
- // property references do not reload their value (even though the
- // setter may have changed it).
- // FIXME: This adds an extra bitfield load
+ // Store the result value into the LHS lvalue. Bit-fields are
+ // handled specially because the result is altered by the store.
if (LHSLV.isBitfield())
- Result = EmitLoadOfLValue(LHSLV, LHSTy);
+ CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, LHSTy,
+ &Result);
+ else
+ CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, LHSTy);
+
return Result;
}
@@ -1003,16 +1002,14 @@ Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
LValue LHS = EmitLValue(E->getLHS());
Value *RHS = Visit(E->getRHS());
- // Store the value into the LHS.
+ // Store the value into the LHS. Bit-fields are handled specially
+ // because the result is altered by the store.
// FIXME: Volatility!
- CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType());
-
- // For bitfields, we need the value in the bitfield. Note that
- // property references do not reload their value (even though the
- // setter may have changed it).
- // FIXME: This adds an extra bitfield load
if (LHS.isBitfield())
- return EmitLoadOfLValue(LHS, E->getLHS()->getType());
+ CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, E->getType(),
+ &RHS);
+ else
+ CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType());
// Return the RHS.
return RHS;