[cfe-commits] r92151 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/copy-constructor-elim-2.cpp
Eli Friedman
eli.friedman at gmail.com
Thu Dec 24 15:33:34 PST 2009
Author: efriedma
Date: Thu Dec 24 17:33:34 2009
New Revision: 92151
URL: http://llvm.org/viewvc/llvm-project?rev=92151&view=rev
Log:
Make copy constructor elimination work in more cases; the case in question
here affects clang-on-clang.
Added:
cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=92151&r1=92150&r2=92151&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Thu Dec 24 17:33:34 2009
@@ -590,6 +590,9 @@
Arg = ICE->getSubExpr();
}
+ if (const CXXFunctionalCastExpr *FCE = dyn_cast<CXXFunctionalCastExpr>(Arg))
+ Arg = FCE->getSubExpr();
+
if (const CXXBindTemporaryExpr *BindExpr =
dyn_cast<CXXBindTemporaryExpr>(Arg))
Arg = BindExpr->getSubExpr();
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=92151&r1=92150&r2=92151&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Dec 24 17:33:34 2009
@@ -3793,6 +3793,8 @@
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
if (ICE->getCastKind() == CastExpr::CK_NoOp)
E = ICE->getSubExpr();
+ if (CXXFunctionalCastExpr *FCE = dyn_cast<CXXFunctionalCastExpr>(E))
+ E = FCE->getSubExpr();
while (CXXBindTemporaryExpr *BE = dyn_cast<CXXBindTemporaryExpr>(E))
E = BE->getSubExpr();
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E))
@@ -3803,6 +3805,8 @@
Elidable = !CE->getCallReturnType()->isReferenceType();
else if (isa<CXXTemporaryObjectExpr>(E))
Elidable = true;
+ else if (isa<CXXConstructExpr>(E))
+ Elidable = true;
}
return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
Added: cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp?rev=92151&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp Thu Dec 24 17:33:34 2009
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+
+struct A { int x; A(int); ~A(); };
+A f() { return A(0); }
+// CHECK: define void @_Z1fv
+// CHECK: call void @_ZN1AC1Ei
+// CHECK-NEXT: ret void
More information about the cfe-commits
mailing list