Skip to content

Commit dc41469

Browse files
aeubanksIcohedron
authored andcommitted
[llvm][ELF] Separate out .dwo bytes written in stats (llvm#126165)
So we can distinguish between debug info sections written to .dwo files and those written to the object file.
1 parent e0c8eb6 commit dc41469

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

llvm/lib/MC/ELFObjectWriter.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ STATISTIC(StrtabBytes, "Total size of SHT_STRTAB sections");
7171
STATISTIC(SymtabBytes, "Total size of SHT_SYMTAB sections");
7272
STATISTIC(RelocationBytes, "Total size of relocation sections");
7373
STATISTIC(DynsymBytes, "Total size of SHT_DYNSYM sections");
74-
STATISTIC(DebugBytes, "Total size of debug info sections");
74+
STATISTIC(
75+
DebugBytes,
76+
"Total size of debug info sections (not including those written to .dwo)");
7577
STATISTIC(UnwindBytes, "Total size of unwind sections");
7678
STATISTIC(OtherBytes, "Total size of uncategorized sections");
79+
STATISTIC(DwoBytes, "Total size of sections written to .dwo file");
7780

7881
} // namespace stats
7982

@@ -969,7 +972,9 @@ void ELFWriter::writeSectionHeaders(const MCAssembler &Asm) {
969972
return Section->getFlags() & Flag;
970973
};
971974

972-
if (Section->getName().starts_with(".debug")) {
975+
if (Mode == DwoOnly) {
976+
stats::DwoBytes += Size;
977+
} else if (Section->getName().starts_with(".debug")) {
973978
stats::DebugBytes += Size;
974979
} else if (Section->getName().starts_with(".eh_frame")) {
975980
stats::UnwindBytes += Size;

llvm/test/CodeGen/X86/dwo-stats.ll

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; REQUIRES: asserts
2+
; RUN: llc %s -mtriple=x86_64-linux --split-dwarf-file=%t.dwo --split-dwarf-output=%t.dwo --filetype=obj -o /dev/null -stats 2>&1 | FileCheck %s --check-prefixes=SPLIT,CHECK
3+
; RUN: llc %s -mtriple=x86_64-linux --filetype=obj -o /dev/null -stats 2>&1 | FileCheck %s --check-prefixes=NOTSPLIT,CHECK
4+
5+
; NOTSPLIT-NOT: {{[0-9]+}} elf-object-writer - Total size of sections written to .dwo file
6+
; CHECK-DAG: {{[0-9]+}} elf-object-writer - Total size of debug info sections
7+
; SPLIT-DAG: {{[0-9]+}} elf-object-writer - Total size of sections written to .dwo file
8+
; NOTSPLIT-NOT: {{[0-9]+}} elf-object-writer - Total size of sections written to .dwo file
9+
10+
define void @banana() !dbg !8 {
11+
ret void, !dbg !12
12+
}
13+
14+
!llvm.dbg.cu = !{!0}
15+
!llvm.module.flags = !{!3, !4, !5, !6}
16+
!llvm.ident = !{!7}
17+
18+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.1", isOptimized: true, runtimeVersion: 0, splitDebugFilename: "test.dwo", emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: GNU)
19+
!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp")
20+
!2 = !{}
21+
!3 = !{i32 7, !"Dwarf Version", i32 4}
22+
!4 = !{i32 2, !"Debug Info Version", i32 3}
23+
!5 = !{i32 1, !"wchar_size", i32 4}
24+
!6 = !{i32 7, !"PIC Level", i32 2}
25+
!7 = !{!"clang version 11.0.1"}
26+
!8 = distinct !DISubprogram(name: "banana", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
27+
!9 = !DIFile(filename: "test.c", directory: "/tmp")
28+
!10 = !DISubroutineType(types: !11)
29+
!11 = !{null}
30+
!12 = !DILocation(line: 1, column: 20, scope: !8)

0 commit comments

Comments
 (0)