[llvm] r338487 - [DWARF] Basic support for producing DWARFv5 .debug_addr section

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 7 16:59:47 PDT 2018


Shows how much attention I paid - but this only applies to Split DWARF so
far. Do you have plans to generalize this for non-Split DWARF cases? (where
it can be valuable for reducing relocations... a bit, at least - though
what we really need is a form that supports addrx+offset, though I vaguely
started a discussion about what form (har har) that should take & didn't
find any great conclusions (the main issue being the mix of lengths to
support - addrx{,1,2,3,4} and data{,1,2,3,4} - support all combinations?
only support the variable length versions & say to heck with fixed-size
records? etc)

On Tue, Jul 31, 2018 at 10:48 PM Victor Leschuk via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: vleschuk
> Date: Tue Jul 31 22:48:06 2018
> New Revision: 338487
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338487&view=rev
> Log:
> [DWARF] Basic support for producing DWARFv5 .debug_addr section
>
> This revision implements support for generating DWARFv5 .debug_addr
> section.
> The implementation is pretty straight-forward: we just check the dwarf
> version
> and emit section header if needed.
>
> Reviewers: aprantl, dblaikie, probinson
>
> Reviewed by: dblaikie
>
> Differential Revision: https://reviews.llvm.org/D50005
>
>
> Added:
>     llvm/trunk/test/DebugInfo/X86/debug_addr.ll
> Modified:
>     llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.h
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.cpp?rev=338487&r1=338486&r2=338487&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.cpp Tue Jul 31 22:48:06
> 2018
> @@ -24,8 +24,26 @@ unsigned AddressPool::getIndex(const MCS
>    return IterBool.first->second.Number;
>  }
>
> +
> +void AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) {
> +  static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize();
> +  Asm.OutStreamer->SwitchSection(Section);
> +
> +  uint64_t Length = sizeof(uint16_t) // version
> +                  + sizeof(uint8_t)  // address_size
> +                  + sizeof(uint8_t)  // segment_selector_size
> +                  + AddrSize * Pool.size(); // entries
> +  Asm.emitInt32(Length); // TODO: Support DWARF64 format.
> +  Asm.emitInt16(Asm.getDwarfVersion());
> +  Asm.emitInt8(AddrSize);
> +  Asm.emitInt8(0); // TODO: Support non-zero segment_selector_size.
> +}
> +
>  // Emit addresses into the section given.
>  void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
> +  if (Asm.getDwarfVersion() >= 5)
> +    emitHeader(Asm, AddrSection);
> +
>    if (Pool.empty())
>      return;
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.h?rev=338487&r1=338486&r2=338487&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AddressPool.h Tue Jul 31 22:48:06
> 2018
> @@ -50,6 +50,9 @@ public:
>    bool hasBeenUsed() const { return HasBeenUsed; }
>
>    void resetUsedFlag() { HasBeenUsed = false; }
> +
> +private:
> +  void emitHeader(AsmPrinter &Asm, MCSection *Section);
>  };
>
>  } // end namespace llvm
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=338487&r1=338486&r2=338487&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Jul 31 22:48:06
> 2018
> @@ -886,8 +886,7 @@ void DwarfDebug::endModule() {
>      emitDebugInfoDWO();
>      emitDebugAbbrevDWO();
>      emitDebugLineDWO();
> -    // Emit DWO addresses.
> -    AddrPool.emit(*Asm, Asm->getObjFileLowering().getDwarfAddrSection());
> +    emitDebugAddr();
>    }
>
>    // Emit info into the dwarf accelerator table sections.
> @@ -2297,6 +2296,12 @@ void DwarfDebug::emitDebugStrDWO() {
>                           OffSec, /* UseRelativeOffsets = */ false);
>  }
>
> +// Emit DWO addresses.
> +void DwarfDebug::emitDebugAddr() {
> +  assert(useSplitDwarf() && "No split dwarf?");
> +  AddrPool.emit(*Asm, Asm->getObjFileLowering().getDwarfAddrSection());
> +}
> +
>  MCDwarfDwoLineTable *DwarfDebug::getDwoLineTable(const DwarfCompileUnit
> &CU) {
>    if (!useSplitDwarf())
>      return nullptr;
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=338487&r1=338486&r2=338487&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Jul 31 22:48:06 2018
> @@ -447,6 +447,9 @@ class DwarfDebug : public DebugHandlerBa
>    /// Emit the debug str dwo section.
>    void emitDebugStrDWO();
>
> +  /// Emit DWO addresses.
> +  void emitDebugAddr();
> +
>    /// Flags to let the linker know we have emitted new style pubnames.
> Only
>    /// emit it here if we don't have a skeleton CU for split dwarf.
>    void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
>
> Added: llvm/trunk/test/DebugInfo/X86/debug_addr.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/debug_addr.ll?rev=338487&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/X86/debug_addr.ll (added)
> +++ llvm/trunk/test/DebugInfo/X86/debug_addr.ll Tue Jul 31 22:48:06 2018
> @@ -0,0 +1,79 @@
> +; RUN: llc -split-dwarf-file=test.dwo -dwarf-version=4 %s
> -mtriple=i386-unknown-linux-gnu -filetype=obj -o - | \
> +; RUN: llvm-dwarfdump -v - | FileCheck %s -check-prefix=DWARF4
> +
> +; RUN: llc -split-dwarf-file=test.dwo -dwarf-version=5 %s
> -mtriple=i386-unknown-linux-gnu -filetype=obj -o - | \
> +; RUN: llvm-dwarfdump -v - | FileCheck %s -check-prefix=DWARF5
> +
> +; Source:
> +; void foo() {
> +; }
> +;
> +; void bar() {
> +; }
> +
> +; DWARF4: .debug_info contents:
> +; DWARF4: Compile Unit:{{.*}}version = 0x0004
> +; DWARF4-NOT: Compile Unit
> +; DWARF4: DW_TAG_compile_unit
> +; DWARF4-NOT: DW_TAG_{{.*}}
> +; DWARF4: DW_AT_GNU_dwo_name{{.*}}test.dwo
> +; DWARF4: DW_AT_GNU_addr_base{{.*}}0x00000000
> +; DWARF4: .debug_addr contents:
> +; DWARF4-NEXT: 0x00000000: Addr Section: length = 0x00000000, version =
> 0x0004, addr_size = 0x04, seg_size = 0x00
> +; DWARF4-NEXT: Addrs: [
> +; DWARF4-NEXT: 0x00000000
> +; DWARF4-NEXT: 0x00000010
> +; DWARF4-NEXT: ]
> +
> +; DWARF5: .debug_info contents:
> +; DWARF5: Compile Unit:{{.*}}version = 0x0005
> +; DWARF5-NOT: Compile Unit
> +; DWARF5: DW_TAG_compile_unit
> +; DWARF5-NOT: DW_TAG_{{.*}}
> +; DWARF5: DW_AT_GNU_dwo_name{{.*}}test.dwo
> +; DWARF5: DW_AT_GNU_addr_base{{.*}}0x00000000
> +; DWARF5: .debug_addr contents:
> +; DWARF5-NEXT: 0x00000000: Addr Section: length = 0x0000000c, version =
> 0x0005, addr_size = 0x04, seg_size = 0x00
> +; DWARF5-NEXT: Addrs: [
> +; DWARF5-NEXT: 0x00000000
> +; DWARF5-NEXT: 0x00000010
> +; DWARF5-NEXT: ]
> +
> +; ModuleID = './test.c'
> +source_filename = "./test.c"
> +target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
> +target triple = "i386-unknown-linux-gnu"
> +
> +; Function Attrs: noinline nounwind optnone
> +define void @foo() #0 !dbg !8 {
> +entry:
> +  ret void, !dbg !12
> +}
> +
> +; Function Attrs: noinline nounwind optnone
> +define void @bar() #0 !dbg !13 {
> +entry:
> +  ret void, !dbg !14
> +}
> +
> +attributes #0 = { noinline nounwind optnone }
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4, !5, !6}
> +!llvm.ident = !{!7}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer:
> "clang version 6.0.1", isOptimized: false, runtimeVersion: 0, emissionKind:
> FullDebug, enums: !2)
> +!1 = !DIFile(filename: "test.c", directory: "/tmp")
> +!2 = !{}
> +!3 = !{i32 1, !"NumRegisterParameters", i32 0}
> +!4 = !{i32 2, !"Dwarf Version", i32 5}
> +!5 = !{i32 2, !"Debug Info Version", i32 3}
> +!6 = !{i32 1, !"wchar_size", i32 4}
> +!7 = !{!"clang version 6.0.1"}
> +!8 = distinct !DISubprogram(name: "foo", scope: !9, file: !9, line: 1,
> type: !10, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized:
> false, unit: !0)
> +!9 = !DIFile(filename: "./test.c", directory: "/tmp")
> +!10 = !DISubroutineType(types: !11)
> +!11 = !{null}
> +!12 = !DILocation(line: 2, column: 3, scope: !8)
> +!13 = distinct !DISubprogram(name: "bar", scope: !9, file: !9, line: 5,
> type: !10, isLocal: false, isDefinition: true, scopeLine: 5, isOptimized:
> false, unit: !0)
> +!14 = !DILocation(line: 6, column: 3, scope: !13)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/7fe4621e/attachment.html>


More information about the llvm-commits mailing list