[cfe-commits] r72273 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGen/blocks-seq.c
Mike Stump
mrs at apple.com
Fri May 22 12:07:21 PDT 2009
Author: mrs
Date: Fri May 22 14:07:20 2009
New Revision: 72273
URL: http://llvm.org/viewvc/llvm-project?rev=72273&view=rev
Log:
Fixup codegen for __block int i; i += rhs();. Should also slightly
improve codegen in some cases.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/blocks-seq.c
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=72273&r1=72272&r2=72273&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri May 22 14:07:20 2009
@@ -803,15 +803,16 @@
return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
}
+ // Emit the RHS first. __block variables need to have the rhs evaluated
+ // first, plus this should improve codegen a little.
+ OpInfo.RHS = Visit(E->getRHS());
+ OpInfo.Ty = E->getComputationResultType();
+ OpInfo.E = E;
// Load/convert the LHS.
LValue LHSLV = EmitLValue(E->getLHS());
OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy);
OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy,
E->getComputationLHSType());
- // Emit the RHS.
- OpInfo.RHS = Visit(E->getRHS());
- OpInfo.Ty = E->getComputationResultType();
- OpInfo.E = E;
// Expand the binary operator.
Value *Result = (this->*Func)(OpInfo);
Modified: cfe/trunk/test/CodeGen/blocks-seq.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks-seq.c?rev=72273&r1=72272&r2=72273&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/blocks-seq.c (original)
+++ cfe/trunk/test/CodeGen/blocks-seq.c Fri May 22 14:07:20 2009
@@ -1,13 +1,18 @@
// RUN: clang-cc -fblocks -triple x86_64-apple-darwin10 -emit-llvm -o %t %s &&
// RUN: grep '%call = call i32 (...)\* @rhs()' %t | count 1 &&
-// If this fails, see about sliding %4 and %5...
+// If this fails, see about sliding %4, %5, %6 and %7...
// RUN: grep '%forwarding1 = getelementptr %0\* %i, i32 0, i32 1' %t | count 1 &&
// RUN: grep '%4 = bitcast i8\*\* %forwarding1 to %0\*\*' %t | count 1 &&
-// RUN: grep '%5 = load %0\*\* %4' %t | count 1
+// RUN: grep '%5 = load %0\*\* %4' %t | count 1 &&
+// RUN: grep '%call2 = call i32 (...)\* @rhs()' %t | count 1 &&
+// RUN: grep '%forwarding3 = getelementptr %0\* %i, i32 0, i32 1' %t | count 1 &&
+// RUN: grep '%6 = bitcast i8\*\* %forwarding3 to %0\*\*' %t | count 1 &&
+// RUN: grep '%7 = load %0\*\* %6' %t | count 1
int rhs();
void foo() {
__block int i;
i = rhs();
+ i += rhs();
}
More information about the cfe-commits
mailing list