Skip to content

Commit a3d7cee

Browse files
committed
[CodeView] Emit function types in -gline-tables-only.
This change adds function types to further differentiate between FUNC_IDs in -gline-tables-only. Size increase of object files in clang are Before: 917990 kb After: 999312 kb Bug: https://bugs.llvm.org/show_bug.cgi?id=48432 Differential Revision: https://reviews.llvm.org/D95001
1 parent 0996b59 commit a3d7cee

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,9 @@ static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
23172317
if (ES->hasExternalDefinitions(RD) == ExternalASTSource::EK_Always)
23182318
return true;
23192319

2320+
// Only emit forward declarations in line tables only to keep debug info size
2321+
// small. This only applies to CodeView, since we don't emit types in DWARF
2322+
// line tables only.
23202323
if (DebugKind == codegenoptions::DebugLineTablesOnly)
23212324
return true;
23222325

@@ -3726,7 +3729,10 @@ llvm::DISubprogram *CGDebugInfo::getObjCMethodDeclaration(
37263729
llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
37273730
QualType FnType,
37283731
llvm::DIFile *F) {
3729-
if (!D || DebugKind <= codegenoptions::DebugLineTablesOnly)
3732+
// In CodeView, we emit the function types in line tables only because the
3733+
// only way to distinguish between functions is by display name and type.
3734+
if (!D || (DebugKind <= codegenoptions::DebugLineTablesOnly &&
3735+
!CGM.getCodeGenOpts().EmitCodeView))
37303736
// Create fake but valid subroutine type. Otherwise -verify would fail, and
37313737
// subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
37323738
return DBuilder.createSubroutineType(DBuilder.getOrCreateTypeArray(None));

clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace NS {
77
struct C {
8-
public:
98
void m() {}
109
};
1110
void f() {}
@@ -14,17 +13,18 @@ void f() {}
1413
NS::C c;
1514

1615
void test() {
17-
// CHECK: ![[EMPTY:[0-9]+]] = !{}
1816
// CHECK: !DISubprogram(name: "f", scope: ![[NS:[0-9]+]],
1917
// CHECK-SAME: type: ![[F:[0-9]+]]
2018
// CHECK: ![[NS]] = !DINamespace(name: "NS", scope: null)
21-
// CHECK: ![[F]] = !DISubroutineType(types: ![[EMPTY]])
19+
// CHECK: ![[F]] = !DISubroutineType(types: ![[FTYPE:[0-9]+]])
20+
// CHECK: ![[FTYPE]] = !{null}
2221
NS::f();
2322

24-
// CHECK: !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
25-
// CHECK-SAME: type: ![[F]]
23+
// CHECK: ![[M:[0-9]+]] = distinct !DISubprogram(name: "m", scope: ![[C:[0-9]+]],
24+
// CHECK-SAME: type: ![[MTYPE:[0-9]+]]
2625
// CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
2726
// CHECK-SAME: flags: DIFlagFwdDecl
2827
// CHECK-NOT: identifier
28+
// CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
2929
c.m();
3030
}

0 commit comments

Comments
 (0)