Index: llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -270,7 +270,7 @@ continue; PrevHash = HashValue; Asm->OutStreamer->AddComment("Offset in Bucket " + Twine(i)); - Asm->emitLabelDifference(Hash->Sym, Base, sizeof(uint32_t)); + Asm->emitLabelDifference(Hash->Sym, Base, Asm->getDwarfOffsetByteSize()); } } } @@ -366,9 +366,8 @@ assert(CompUnitCount > 0 && "Index must have at least one CU."); AsmPrinter *Asm = Ctx.Asm; - Asm->OutStreamer->AddComment("Header: unit length"); - Asm->emitLabelDifference(Ctx.ContributionEnd, Ctx.ContributionStart, - sizeof(uint32_t)); + Asm->emitDwarfUnitLength(Ctx.ContributionEnd, Ctx.ContributionStart, + "Header: unit length"); Asm->OutStreamer->emitLabel(Ctx.ContributionStart); Asm->OutStreamer->AddComment("Header: version"); Asm->emitInt16(Version); Index: llvm/test/DebugInfo/X86/debug-names-dwarf64.ll =================================================================== --- /dev/null +++ llvm/test/DebugInfo/X86/debug-names-dwarf64.ll @@ -0,0 +1,76 @@ +; This checks that .debug_names can be generated in the DWARF64 format. + +; RUN: llc -mtriple=x86_64 -dwarf64 -accel-tables=Dwarf -dwarf-version=5 -filetype=obj %s -o %t +; RUN: llvm-dwarfdump -debug-info -debug-names %t | FileCheck %s +; RUN: llvm-dwarfdump -debug-names -verify %t | FileCheck --check-prefix=VERIFY %s + +; CHECK: .debug_info contents: +; CHECK-NEXT: 0x00000000: Compile Unit: {{.+}}, format = DWARF64, +; CHECK: [[VARDIE:.+]]: DW_TAG_variable +; CHECK-NEXT: DW_AT_name ("foo") +; CHECK: [[TYPEDIE:.+]]: DW_TAG_base_type +; CHECK-NEXT: DW_AT_name ("int") + +; CHECK: .debug_names contents: +; CHECK-NEXT: Name Index @ 0x0 { +; CHECK-NEXT: Header { +; CHECK: Format: DWARF64 +; CHECK-NEXT: Version: 5 +; CHECK-NEXT: CU count: 1 +; CHECK-NEXT: Local TU count: 0 +; CHECK-NEXT: Foreign TU count: 0 +; CHECK-NEXT: Bucket count: 2 +; CHECK-NEXT: Name count: 2 +; CHECK: } +; CHECK-NEXT: Compilation Unit offsets [ +; CHECK-NEXT: CU[0]: 0x00000000 +; CHECK-NEXT: ] +; CHECK-NEXT: Abbreviations [ +; CHECK-NEXT: Abbreviation 0x34 { +; CHECK-NEXT: Tag: DW_TAG_variable +; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4 +; CHECK-NEXT: } +; CHECK-NEXT: Abbreviation 0x24 { +; CHECK-NEXT: Tag: DW_TAG_base_type +; CHECK-NEXT: DW_IDX_die_offset: DW_FORM_ref4 +; CHECK-NEXT: } +; CHECK-NEXT: ] +; CHECK-NEXT: Bucket 0 [ +; CHECK-NEXT: Name 1 { +; CHECK-NEXT: Hash: 0xB888030 +; CHECK-NEXT: String: {{.+}} "int" +; CHECK-NEXT: Entry @ {{.+}} { +; CHECK-NEXT: Abbrev: 0x24 +; CHECK-NEXT: Tag: DW_TAG_base_type +; CHECK-NEXT: DW_IDX_die_offset: [[TYPEDIE]] +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: ] +; CHECK-NEXT: Bucket 1 [ +; CHECK-NEXT: Name 2 { +; CHECK-NEXT: Hash: 0xB887389 +; CHECK-NEXT: String: {{.+}} "foo" +; CHECK-NEXT: Entry @ {{.+}} { +; CHECK-NEXT: Abbrev: 0x34 +; CHECK-NEXT: Tag: DW_TAG_variable +; CHECK-NEXT: DW_IDX_die_offset: [[VARDIE]] +; CHECK-NEXT: } +; CHECK-NEXT: } +; CHECK-NEXT: ] +; CHECK-NEXT: } + +; VERIFY: No errors. + +@foo = common dso_local global i32 0, align 4, !dbg !5 + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!0} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !DIFile(filename: "foo.c", directory: "/tmp") +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Manual", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !3, globals: !4, splitDebugInlining: false, nameTableKind: Default) +!3 = !{} +!4 = !{!5} +!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression()) +!6 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true) +!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)