[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 13:37:01 PDT 2020


akhuang updated this revision to Diff 281722.
akhuang added a comment.

remove change to add class types to retained types list,

also fix the test case to be a struct that previously didn't
get complete debug info.


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
@@ -1712,7 +1712,6 @@
       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.281722.patch
Type: text/x-patch
Size: 1867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200729/b6a9559c/attachment.bin>


More information about the cfe-commits mailing list