[PATCH] D86491: [DebugInfo] Move constructor homing case in shouldOmitDefinition.
Amy Huang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 20:18:33 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG589ce5f7050d: [DebugInfo] Move constructor homing case in shouldOmitDefinition. (authored by akhuang).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86491/new/
https://reviews.llvm.org/D86491
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
Index: clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited %s -o - | FileCheck %
+
+// Make sure this still works with constructor homing.
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=constructor %s -o - | FileCheck %s
// Run again with -gline-tables-only or -gline-directives-only and verify we don't crash. We won't output
// type info at all.
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2260,6 +2260,25 @@
return false;
}
+static bool canUseCtorHoming(const CXXRecordDecl *RD) {
+ // Constructor homing can be used for classes that have at least one
+ // constructor and have no trivial or constexpr constructors.
+ // Skip this optimization if the class or any of its methods are marked
+ // dllimport.
+ if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
+ isClassOrMethodDLLImport(RD))
+ return false;
+
+ if (RD->ctors().empty())
+ return false;
+
+ for (const auto *Ctor : RD->ctors())
+ if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
+ return false;
+
+ return true;
+}
+
static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
bool DebugTypeExtRefs, const RecordDecl *RD,
const LangOptions &LangOpts) {
@@ -2294,23 +2313,6 @@
!isClassOrMethodDLLImport(CXXDecl))
return true;
- // In constructor debug mode, only emit debug info for a class when its
- // constructor is emitted. Skip this optimization if the class or any of
- // its methods are marked dllimport.
- //
- // This applies to classes that don't have any trivial constructors and have
- // at least one constructor.
- if (DebugKind == codegenoptions::DebugInfoConstructor &&
- !CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
- !isClassOrMethodDLLImport(CXXDecl)) {
- if (CXXDecl->ctors().empty())
- return false;
- for (const auto *Ctor : CXXDecl->ctors())
- if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
- return false;
- return true;
- }
-
TemplateSpecializationKind Spec = TSK_Undeclared;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
Spec = SD->getSpecializationKind();
@@ -2320,6 +2322,12 @@
CXXDecl->method_end()))
return true;
+ // In constructor homing mode, only emit complete debug info for a class
+ // when its constructor is emitted.
+ if ((DebugKind != codegenoptions::DebugInfoConstructor) &&
+ canUseCtorHoming(CXXDecl))
+ return true;
+
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86491.287551.patch
Type: text/x-patch
Size: 3200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200825/b3fb26b0/attachment.bin>
More information about the cfe-commits
mailing list