From 9ccb103c6f777fc42343b23b19a8c2c9a740e6e8 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Sat, 23 May 2009 22:01:27 +0000 Subject: [PATCH] Fix thinko, and implement aggregate volatile reads. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72347 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 951a5f0e39..3b7871390c 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -131,9 +131,14 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src) { assert(Src.isAggregate() && "value must be aggregate value!"); // If the result is ignored, don't copy from the value. - if (DestPtr == 0) - // FIXME: If the source is volatile, we must read from it. - return; + if (DestPtr == 0) { + if (Src.isVolatileQualified()) + // If the source is volatile, we must read from it; to do that, we need + // some place to put it. + DestPtr = CGF.CreateTempAlloca(CGF.ConvertType(E->getType()), "agg.tmp"); + else + return; + } // If the result of the assignment is used, copy the LHS there also. // FIXME: Pass VolatileDest as well. I think we also need to merge volatile @@ -197,7 +202,7 @@ void AggExprEmitter::VisitObjCKVCRefExpr(ObjCKVCRefExpr *E) { } void AggExprEmitter::VisitBinComma(const BinaryOperator *E) { - CGF.EmitAnyExprToTemp(E->getLHS(), 0, VolatileDest); + CGF.EmitAnyExpr(E->getLHS()); CGF.EmitAggExpr(E->getRHS(), DestPtr, VolatileDest); } -- 2.50.1