Skip to content

Commit 3445ec9

Browse files
committed
[DebugInfo] Emit a 1-byte value as a terminator of entries list in the name index.
As stated in section 6.1.1.2, DWARFv5, p. 142, | The last entry for each name is followed by a zero byte that | terminates the list. There may be gaps between the lists. The patch changes emitting a 4-byte zero value to a 1-byte one, which effectively removes the gap between entry lists, and thus saves approximately 3 bytes per name; the calculation is not exact because the total size of the table is aligned to 4. Differential Revision: https://reviews.llvm.org/D86927
1 parent 71eed48 commit 3445ec9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emitData() const {
505505
for (const auto *Value : Hash->Values)
506506
emitEntry(*static_cast<const DataT *>(Value));
507507
Asm->OutStreamer->AddComment("End of list: " + Hash->Name.getString());
508-
Asm->emitInt32(0);
508+
Asm->emitInt8(0);
509509
}
510510
}
511511
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; This checks that the list of index entries in the name index is terminated
2+
; with a 1-byte value.
3+
4+
; RUN: llc -mtriple x86_64 -accel-tables=Dwarf -dwarf-version=5 -filetype=asm %s -o - | \
5+
; RUN: FileCheck %s
6+
7+
; CHECK: .section .debug_names,"",@progbits
8+
; CHECK: .Lnames_entries0:
9+
; CHECK: .byte 0 # End of list: int
10+
; CHECK: .byte 0 # End of list: foo
11+
12+
@foo = common dso_local global i32 0, align 4, !dbg !5
13+
14+
!llvm.dbg.cu = !{!2}
15+
!llvm.module.flags = !{!0}
16+
17+
!0 = !{i32 2, !"Debug Info Version", i32 3}
18+
!1 = !DIFile(filename: "foo.c", directory: "/tmp")
19+
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Manual", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4)
20+
!3 = !{}
21+
!4 = !{!5}
22+
!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
23+
!6 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true)
24+
!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)

0 commit comments

Comments
 (0)