[cfe-commits] r137086 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/reference-cast.cpp
Douglas Gregor
dgregor at apple.com
Mon Aug 8 17:37:14 PDT 2011
Author: dgregor
Date: Mon Aug 8 19:37:14 2011
New Revision: 137086
URL: http://llvm.org/viewvc/llvm-project?rev=137086&view=rev
Log:
Hand materialization of temporary expressions when emitting a scalar
expression. Fxies PR10592.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGenCXX/reference-cast.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=137086&r1=137085&r2=137086&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Aug 8 19:37:14 2011
@@ -343,6 +343,11 @@
}
// C++
+ Value *VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E) {
+ RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E->GetTemporaryExpr()));
+ return RV.getScalarVal();
+ }
+
Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
return Visit(DAE->getExpr());
}
Modified: cfe/trunk/test/CodeGenCXX/reference-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/reference-cast.cpp?rev=137086&r1=137085&r2=137086&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/reference-cast.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/reference-cast.cpp Mon Aug 8 19:37:14 2011
@@ -168,3 +168,16 @@
// CHECK: store float
return get_complex_double();
}
+
+// CHECK: define i32 @_Z7pr10592RKi(i32*
+unsigned pr10592(const int &v) {
+ // CHECK: [[VADDR:%[a-zA-Z0-9.]+]] = alloca i32*
+ // CHECK-NEXT: [[REFTMP:%[a-zA-Z0-9.]+]] = alloca i32
+ // CHECK-NEXT: store i32* [[V:%[a-zA-Z0-9.]+]], i32** [[VADDR]]
+ // CHECK-NEXT: [[VADDR_1:%[a-zA-Z0-9.]+]] = load i32** [[VADDR]]
+ // CHECK-NEXT: [[VVAL:%[a-zA-Z0-9.]+]] = load i32* [[VADDR_1]]
+ // CHECK-NEXT: store i32 [[VVAL]], i32* [[REFTMP]]
+ // CHECK-NEXT: [[VVAL_I:%[a-zA-Z0-9.]+]] = load i32* [[REFTMP]]
+ // CHECK-NEXT: ret i32 [[VVAL_I]]
+ return static_cast<const unsigned &>(v);
+}
More information about the cfe-commits
mailing list