aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-06 19:12:38 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-06 19:12:38 +0000
commit1cf9ff87ee235ad252332a96699abdb32bd6facb (patch)
tree370e9e0a0f71cbec27755371e579451693e2ffdb /lib/CodeGen/CGCXX.cpp
parent70101ce87ff1d73ac90e4d99a3af0ae509e5934f (diff)
Set and use Elidable in elimination of copy ctors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 567c58373c..0d51c03bab 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -258,16 +258,10 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest,
// Code gen optimization to eliminate copy constructor and return
// its first argument instead.
- const CXXConstructorDecl *CDecl = E->getConstructor();
- if (E->getNumArgs() == 1 &&
- CDecl->isCopyConstructor(getContext())) {
+ if (E->isElidable()) {
CXXConstructExpr::const_arg_iterator i = E->arg_begin();
- const Expr *SubExpr = (*i);
- // FIXME. Any other cases can be optimized away?
- if (isa<CallExpr>(SubExpr) || isa<CXXTemporaryObjectExpr>(SubExpr)) {
- EmitAggExpr(SubExpr, Dest, false);
- return;
- }
+ EmitAggExpr((*i), Dest, false);
+ return;
}
// Call the constructor.
EmitCXXConstructorCall(E->getConstructor(), Ctor_Complete, Dest,