[PATCH] D84870: [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.
Amy Huang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 09:55:38 PDT 2020
akhuang created this revision.
akhuang added a reviewer: dblaikie.
Herald added subscribers: cfe-commits, aprantl.
Herald added a project: clang.
akhuang requested review of this revision.
Previously ctor homing was omitting debug info for classes if they
have both trival and nontrivial constructors, but we should only omit debug
info if the class doesn't have any trivial constructors.
Also change to use completeUnusedClass so the debug info is added to the
retained types list.
bug: https://bugs.llvm.org/show_bug.cgi?id=46537
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84870
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -24,3 +24,9 @@
struct E {
constexpr E(){};
} TestE;
+
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
+struct F {
+ F() = default;
+ F(int) {}
+} TestF;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1705,14 +1705,13 @@
// info is emitted.
if (DebugKind == codegenoptions::DebugInfoConstructor)
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
- completeClass(CD->getParent());
+ completeUnusedClass(*CD->getParent());
llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
llvm::DISubprogram *SP = DBuilder.createMethod(
RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
TParamsArray.get());
-
SPCache[Method->getCanonicalDecl()].reset(SP);
return SP;
@@ -2296,12 +2295,19 @@
// 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))
+ !isClassOrMethodDLLImport(CXXDecl)) {
+ if (CXXDecl->ctors().empty())
+ return false;
for (const auto *Ctor : CXXDecl->ctors())
- if (Ctor->isUserProvided())
- return true;
+ if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
+ return false;
+ return true;
+ }
TemplateSpecializationKind Spec = TSK_Undeclared;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84870.281645.patch
Type: text/x-patch
Size: 2236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200729/3479d75a/attachment-0001.bin>
More information about the cfe-commits
mailing list