[PATCH] D95001: [CodeView] Emit function types in -gline-tables-only.

Amy Huang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 20 12:42:49 PST 2021


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

Add comments describing reason for emitting types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95001

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp


Index: clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -5,7 +5,6 @@
 
 namespace NS {
 struct C {
-public:
   void m() {}
 };
 void f() {}
@@ -14,17 +13,18 @@
 NS::C c;
 
 void test() {
-  // CHECK: ![[EMPTY:[0-9]+]] = !{}
   // CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
   // CHECK-SAME:          type: ![[F:[0-9]+]]
   // CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
-  // CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
+  // CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
+  // CHECK: ![[FTYPE]] = !{null}
   NS::f();
 
-  // CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
-  // CHECK-SAME:          type: ![[F]]
+  // CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
+  // CHECK-SAME:                                   type: ![[MTYPE:[0-9]+]]
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:                      flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
+  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
   c.m();
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2325,6 +2325,9 @@
     if (ES->hasExternalDefinitions(RD) == ExternalASTSource::EK_Always)
       return true;
 
+  // Only emit forward declarations in line tables only to keep debug info size
+  // small. This only applies to CodeView, since we don't emit types in DWARF
+  // line tables only.
   if (DebugKind == codegenoptions::DebugLineTablesOnly)
     return true;
 
@@ -3734,7 +3737,10 @@
 llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
                                                              QualType FnType,
                                                              llvm::DIFile *F) {
-  if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
+  // In CodeView, we emit the function types in line tables only because the
+  // only way to distinguish between functions is by display name and type.
+  if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
+             !CGM.getCodeGenOpts().EmitCodeView))
     // Create fake but valid subroutine type. Otherwise -verify would fail, and
     // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
     return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95001.317975.patch
Type: text/x-patch
Size: 2684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210120/6e6528e9/attachment-0001.bin>


More information about the cfe-commits mailing list