From e0c1168ec7910a1a7ed08df4d4f0c58c2fa2ecd1 Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 2 Jul 2012 23:58:38 +0000 Subject: Significantly simplify CGExprAgg's logic about ignored results: if we want to ignore a result, the Dest will be null. Otherwise, we must copy into it. This means we need to ensure a slot when loading from a volatile l-value. With all that in place, fix a bug with chained assignments into __block variables of aggregate type where we were losing insight into the actual source of the value during the second assignment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159630 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index cb446dfeb4..5f708d7a73 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -109,15 +109,18 @@ void CodeGenFunction::EmitIgnoredExpr(const Expr *E) { /// can have any type. The result is returned as an RValue struct. /// If this is an aggregate expression, AggSlot indicates where the /// result should be returned. -RValue CodeGenFunction::EmitAnyExpr(const Expr *E, AggValueSlot AggSlot, - bool IgnoreResult) { +RValue CodeGenFunction::EmitAnyExpr(const Expr *E, + AggValueSlot aggSlot, + bool ignoreResult) { if (!hasAggregateLLVMType(E->getType())) - return RValue::get(EmitScalarExpr(E, IgnoreResult)); + return RValue::get(EmitScalarExpr(E, ignoreResult)); else if (E->getType()->isAnyComplexType()) - return RValue::getComplex(EmitComplexExpr(E, IgnoreResult, IgnoreResult)); + return RValue::getComplex(EmitComplexExpr(E, ignoreResult, ignoreResult)); - EmitAggExpr(E, AggSlot, IgnoreResult); - return AggSlot.asRValue(); + if (!ignoreResult && aggSlot.isIgnored()) + aggSlot = CreateAggTemp(E->getType(), "agg-temp"); + EmitAggExpr(E, aggSlot); + return aggSlot.asRValue(); } /// EmitAnyExprToTemp - Similary to EmitAnyExpr(), however, the result will -- cgit v1.2.3-70-g09d2