[PATCH] D72427: [DebugInfo] Add option to clang to limit debug info that is emitted for classes.
Amy Huang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 14 12:50:28 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG651128f55722: [DebugInfo] Add option to clang to limit debug info that is emitted for classes. (authored by akhuang).
Changed prior to commit:
https://reviews.llvm.org/D72427?vs=237811&id=238077#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72427/new/
https://reviews.llvm.org/D72427
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang -cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A"
+// CHECK-NOT: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+struct A {};
+void TestA() { A a; }
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "B"
+// CHECK-SAME: flags: DIFlagFwdDecl
+struct B {
+ B();
+};
+void TestB() { B b; }
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "C"
+// CHECK-NOT: flags: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+struct C {
+ C() {}
+};
+void TestC() { C c; }
+
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "D"
+// CHECK-NOT: flags: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+struct D {
+ D();
+};
+D::D() {}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1648,6 +1648,12 @@
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)
+ if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
+ completeClass(CD->getParent());
+
llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
llvm::DISubprogram *SP = DBuilder.createMethod(
RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
@@ -2211,6 +2217,17 @@
!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 &&
+ !CXXDecl->isLambda() && !isClassOrMethodDLLImport(CXXDecl)) {
+ for (const auto *Ctor : CXXDecl->ctors()) {
+ if (Ctor->isUserProvided())
+ return true;
+ }
+ }
+
TemplateSpecializationKind Spec = TSK_Undeclared;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
Spec = SD->getSpecializationKind();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72427.238077.patch
Type: text/x-patch
Size: 2503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200114/d15db7c1/attachment.bin>
More information about the cfe-commits
mailing list