[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 19:55:49 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGf71deb43abea: [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors. (authored by akhuang).

Changed prior to commit:
  https://reviews.llvm.org/D84870?vs=281722&id=281785#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84870/new/

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,10 @@
 struct E {
   constexpr E(){};
 } TestE;
+
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
+struct F {
+  F() = default;
+  F(int) {}
+  int i;
+} TestF;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2296,12 +2296,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.281785.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200730/6c9e718a/attachment.bin>


More information about the cfe-commits mailing list