зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
70101ce87f
Коммит
1cf9ff87ee
|
@ -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,
|
||||
|
|
|
@ -911,8 +911,10 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
assert(!ToType->isReferenceType());
|
||||
|
||||
// FIXME: Keep track of whether the copy constructor is elidable or not.
|
||||
From = BuildCXXConstructExpr(Context,
|
||||
ToType, SCS.CopyConstructor, false, &From, 1);
|
||||
bool Elidable = (isa<CallExpr>(From) ||
|
||||
isa<CXXTemporaryObjectExpr>(From));
|
||||
From = BuildCXXConstructExpr(Context, ToType,
|
||||
SCS.CopyConstructor, Elidable, &From, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,9 +176,10 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType,
|
|||
DirectInit? IK_Direct : IK_Copy);
|
||||
if (!Constructor)
|
||||
return true;
|
||||
|
||||
bool Elidable = (isa<CallExpr>(Init) ||
|
||||
isa<CXXTemporaryObjectExpr>(Init));
|
||||
Init = BuildCXXConstructExpr(Context,
|
||||
DeclType, Constructor, false, &Init, 1);
|
||||
DeclType, Constructor, Elidable, &Init, 1);
|
||||
Init = MaybeCreateCXXExprWithTemporaries(Init, /*DestroyTemps=*/true);
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче