================
@@ -3239,18 +3239,36 @@ static bool canUseCtorHoming(const CXXRecordDecl *RD) {
if (isClassOrMethodDLLImport(RD))
return false;
- if (RD->isLambda() || RD->isAggregate() ||
- RD->hasTrivialDefaultConstructor() ||
- RD->hasConstexprNonCopyMoveConstructor())
+ if (RD->isLambda() || RD->isAggregate() ||
RD->hasTrivialDefaultConstructor())
return false;
+ // Skip this optimization if the class has a constexpr default constructor,
+ // since those constructors can be invoked without emitting type information
+ // for the constructor.
+ if (RD->needsImplicitDefaultConstructor() &&
+ RD->defaultedDefaultConstructorIsConstexpr())
+ return false;
+
+ bool HasNonDeletedCtor = false;
for (const CXXConstructorDecl *Ctor : RD->ctors()) {
if (Ctor->isCopyOrMoveConstructor())
continue;
+ const FunctionDecl *Def = nullptr;
+ if (Ctor->isDefined(Def)) {
+ const auto *CtorDef = cast<CXXConstructorDecl>(Def);
+ // Ignore delegating constructors, the target constructor's definition
+ // will emit the type info.
+ if (CtorDef->isDelegatingConstructor())
+ continue;
----------------
ClaytonKnittel wrote:
I was writing up an argument to why it was not necessary, but I realized
delegating-to-copy-ctor (or move ctor) should not enable this optimization, so
we do need to check for delegating constructors in
https://github.com/llvm/llvm-project/pull/218807. I updated that PR, and added
two tests for delegating to copy/move ctors.
https://github.com/llvm/llvm-project/pull/218165
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits