akhuang created this revision.
Herald added subscribers: lldb-commits, cfe-commits, aprantl.
Herald added projects: clang, LLDB.

There will be an RFC for this in cfe-dev.
This reduces the amount of class debug info emitted in Limited debug info mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79147

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
  clang/test/CodeGenCXX/debug-lambda-this.cpp
  lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp

Index: lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
===================================================================
--- lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
+++ lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp
@@ -106,6 +106,7 @@
 int main() {
   MemberTest::Base B1;
   B1.Get();
+  MemberTest::Class C1;
   MemberTest::Class::StaticMemberFunc(1, 10, 2);
   return 0;
 }
Index: clang/test/CodeGenCXX/debug-lambda-this.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-lambda-this.cpp
+++ clang/test/CodeGenCXX/debug-lambda-this.cpp
@@ -1,8 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -debug-info-kind=limited | FileCheck %s
 
 struct D {
-  D();
-  D(const D&);
   int x;
   int d(int x);
 };
@@ -15,7 +13,7 @@
 // CHECK: ![[D:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D",
 // CHECK: ![[POINTER:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[D]], size: 64)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "this",
-// CHECK-SAME:           line: 11
+// CHECK-SAME:           line: 9
 // CHECK-SAME:           baseType: ![[POINTER]]
 // CHECK-SAME:           size: 64
 // CHECK-NOT:            offset: 0
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
@@ -1,4 +1,4 @@
-// RUN: %clang -cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang -cc1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "A"{{.*}}DIFlagTypePassByValue
 struct A {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -727,7 +727,6 @@
         llvm::StringSwitch<unsigned>(A->getValue())
             .Case("line-tables-only", codegenoptions::DebugLineTablesOnly)
             .Case("line-directives-only", codegenoptions::DebugDirectivesOnly)
-            .Case("constructor", codegenoptions::DebugInfoConstructor)
             .Case("limited", codegenoptions::LimitedDebugInfo)
             .Case("standalone", codegenoptions::FullDebugInfo)
             .Default(~0U);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1004,9 +1004,6 @@
   case codegenoptions::DebugLineTablesOnly:
     CmdArgs.push_back("-debug-info-kind=line-tables-only");
     break;
-  case codegenoptions::DebugInfoConstructor:
-    CmdArgs.push_back("-debug-info-kind=constructor");
-    break;
   case codegenoptions::LimitedDebugInfo:
     CmdArgs.push_back("-debug-info-kind=limited");
     break;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -592,7 +592,6 @@
   case codegenoptions::DebugDirectivesOnly:
     EmissionKind = llvm::DICompileUnit::DebugDirectivesOnly;
     break;
-  case codegenoptions::DebugInfoConstructor:
   case codegenoptions::LimitedDebugInfo:
   case codegenoptions::FullDebugInfo:
     EmissionKind = llvm::DICompileUnit::FullDebug;
@@ -1689,9 +1688,8 @@
   if (CGM.getLangOpts().Optimize)
     SPFlags |= llvm::DISubprogram::SPFlagOptimized;
 
-  // In this debug mode, emit type info for a class when its constructor type
-  // info is emitted.
-  if (DebugKind == codegenoptions::DebugInfoConstructor)
+  // Emit class type info when its constructor is emitted.
+  if (DebugKind == codegenoptions::LimitedDebugInfo)
     if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
       completeClass(CD->getParent());
 
@@ -2280,10 +2278,10 @@
       !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.
-  if (DebugKind == codegenoptions::DebugInfoConstructor &&
+  // Only emit complete debug info for a class with a user-defined constructor
+  // when its constructor is emitted. Skip this optimization if the class or
+  // any of its methods are marked dllimport.
+  if (DebugKind == codegenoptions::LimitedDebugInfo &&
       !CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
       !isClassOrMethodDLLImport(CXXDecl))
     for (const auto *Ctor : CXXDecl->ctors())
Index: clang/include/clang/Basic/DebugInfoOptions.h
===================================================================
--- clang/include/clang/Basic/DebugInfoOptions.h
+++ clang/include/clang/Basic/DebugInfoOptions.h
@@ -34,15 +34,12 @@
   /// (-gline-tables-only).
   DebugLineTablesOnly,
 
-  /// Limit generated debug info for classes to reduce size. This emits class
-  /// type info only where the constructor is emitted, if it is a class that
-  /// has a constructor.
-  DebugInfoConstructor,
-
   /// Limit generated debug info to reduce size (-fno-standalone-debug). This
   /// emits forward decls for types that could be replaced with forward decls in
   /// the source code. For dynamic C++ classes type info is only emitted into
-  /// the module that contains the classe's vtable.
+  /// the module that contains the classe's vtable. For classes with
+  /// nontrivial, user-defined constructors, the type info is only emitted in
+  /// the module that contains a constructor.
   LimitedDebugInfo,
 
   /// Generate complete debug info.
Index: clang/include/clang/Basic/CodeGenOptions.h
===================================================================
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -365,7 +365,7 @@
 
   /// Check if type and variable info should be emitted.
   bool hasReducedDebugInfo() const {
-    return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
+    return getDebugInfo() >= codegenoptions::LimitedDebugInfo;
   }
 };
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to