2018-01-31 02:41:31 +08:00
; REQUIRES: object-emission
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj < %s | llvm-dwarfdump -v - \
; RUN: | FileCheck --check-prefix=MONOLITHIC %s
[DebugInfo] Reduce debug_str_offsets section size
Summary:
The accelerator tables use the debug_str section to store their strings.
However, they do not support the indirect method of access that is
available for the debug_info section (DW_FORM_strx et al.).
Currently our code is assuming that all strings can/will be referenced
indirectly, and puts all of them into the debug_str_offsets section.
This is generally true for regular (unsplit) dwarf, but in the DWO case,
most of the strings in the debug_str section will only be used from the
accelerator tables. Therefore the contents of the debug_str_offsets
section will be largely unused and bloating the main executable.
This patch rectifies this by teaching the DwarfStringPool to
differentiate between strings accessed directly and indirectly. When a
user inserts a string into the pool it has to declare whether that
string will be referenced directly or not. If at least one user requsts
indirect access, that string will be assigned an index ID and put into
debug_str_offsets table. Otherwise, the offset table is skipped.
This approach reduces the overall binary size (when compiled with
-gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is
shrunk by 99%).
Reviewers: probinson, dblaikie, JDevlieghere
Subscribers: aprantl, mgrang, llvm-commits
Differential Revision: https://reviews.llvm.org/D49493
llvm-svn: 339122
2018-08-07 17:54:52 +08:00
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf-file=foo.dwo -filetype=obj < %s \
2018-01-31 02:41:31 +08:00
; RUN: | llvm-dwarfdump -v - | FileCheck --check-prefix=SPLIT %s
; This basic test checks the emission of a DWARF v5 string offsets table in
; the split and non-split (monolithic) scenario.
;
; Constructed from the following source with
; clang -S -emit-llvm -gdwarf-5
;
; enum E {a, b, c};
; E glob;
;
; In the non-split scenario, check the DW_AT_str_offsets_base attribute
; in .debug_abbrev.
; MONOLITHIC: .debug_abbrev contents:
; MONOLITHIC-NOT: contents:
; MONOLITHIC: DW_TAG_compile_unit
; MONOLITHIC-NOT: DW_TAG
; MONOLITHIC: DW_AT_str_offsets_base DW_FORM_sec_offset
; Check that indexed strings come out correctly and that the DW_str_offsets_base attribute
; is there and has the right value.
; MONOLITHIC: .debug_info contents:
; MONOLITHIC-NOT: contents:
; MONOLITHIC: DW_TAG_compile_unit
; MONOLITHIC-NOT: {{DW_TAG|NULL}}
; MONOLITHIC: DW_AT_producer [DW_FORM_strx1] ( indexed (00000000) string = "clang{{.*}}")
; MONOLITHIC-NOT: {{DW_TAG|NULL}}
; MONOLITHIC: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
; MONOLITHIC-NOT: {{DW_TAG|NULL}}
; MONOLITHIC: DW_AT_comp_dir [DW_FORM_strx1] ( indexed (00000002) string = "/home/{{.*}}")
; Extract the string offsets from the .debug_str section so we can check that
; they are referenced correctly in the .debug_str_offsets section.
; MONOLITHIC: .debug_str contents:
; MONOLITHIC-NEXT: 0x00000000:
; MONOLITHIC-NEXT: 0x[[STRING2:[0-9a-f]]]
; MONOLITHIC-NEXT: 0x[[STRING3:[0-9a-f]]]
; MONOLITHIC-NEXT: 0x[[STRING4:[0-9a-f]]]
; Verify that the .debug_str_offsets section is there and that it starts
; with an 8-byte header, followed by offsets into the .debug_str section.
; MONOLITHIC: .debug_str_offsets contents:
2018-05-11 04:02:34 +08:00
; MONOLITHIC-NEXT: Contribution size = 36, Format = DWARF32, Version = 5
2018-01-31 02:41:31 +08:00
; MONOLITHIC-NEXT: 0x00000008: 00000000
; MONOLITHIC-NEXT: 0x0000000c: [[STRING2]]
; MONOLITHIC-NEXT: 0x00000010: [[STRING3]]
; MONOLITHIC-NEXT: 0x00000014: [[STRING4]]
; For split dwarf, verify that the skeleton unit has the DW_AT_str_offsets_base
; attribute and that it has the right value.
;
; SPLIT: .debug_info contents:
; SPLIT-NEXT: 0x00000000: Compile Unit:{{.*}}DW_UT_skeleton
; SPLIT-NOT: contents:
; SPLIT: DW_TAG_compile_unit
; SPLIT-NOT: {{DW_TAG|contents:}}
; SPLIT: DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
[DebugInfo] Reduce debug_str_offsets section size
Summary:
The accelerator tables use the debug_str section to store their strings.
However, they do not support the indirect method of access that is
available for the debug_info section (DW_FORM_strx et al.).
Currently our code is assuming that all strings can/will be referenced
indirectly, and puts all of them into the debug_str_offsets section.
This is generally true for regular (unsplit) dwarf, but in the DWO case,
most of the strings in the debug_str section will only be used from the
accelerator tables. Therefore the contents of the debug_str_offsets
section will be largely unused and bloating the main executable.
This patch rectifies this by teaching the DwarfStringPool to
differentiate between strings accessed directly and indirectly. When a
user inserts a string into the pool it has to declare whether that
string will be referenced directly or not. If at least one user requsts
indirect access, that string will be assigned an index ID and put into
debug_str_offsets table. Otherwise, the offset table is skipped.
This approach reduces the overall binary size (when compiled with
-gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is
shrunk by 99%).
Reviewers: probinson, dblaikie, JDevlieghere
Subscribers: aprantl, mgrang, llvm-commits
Differential Revision: https://reviews.llvm.org/D49493
llvm-svn: 339122
2018-08-07 17:54:52 +08:00
; SPLIT: DW_AT_GNU_dwo_name [DW_FORM_strx1] ( indexed (00000000) string = "foo.dwo")
; SPLIT: DW_AT_comp_dir [DW_FORM_strx1] ( indexed (00000001) string = "/home/test")
2018-01-31 02:41:31 +08:00
; Check for the split CU in .debug_info.dwo.
; SPLIT: .debug_info.dwo contents:
; SPLIT-NEXT: 0x00000000: Compile Unit:{{.*}}DW_UT_split_compile
; SPLIT-NOT: contents:
; SPLIT: DW_TAG_compile_unit
;
; Check that a couple of indexed strings are displayed correctly and that
; they have the right format (DW_FORM_strx1).
; SPLIT-NOT: contents:
; SPLIT: DW_TAG_enumerator
; SPLIT-NOT: {{DW_TAG|NULL}}
; SPLIT: DW_AT_name [DW_FORM_strx1] ( indexed (00000004) string = "a")
; SPLIT-NOT: contents:
; SPLIT: DW_TAG_enumerator
; SPLIT-NOT: {{DW_TAG|NULL}}
; SPLIT: DW_AT_name [DW_FORM_strx1] ( indexed (00000005) string = "b")
;
; Extract the string offsets referenced in the main file by the skeleton unit.
; SPLIT: .debug_str contents:
[DebugInfo] Reduce debug_str_offsets section size
Summary:
The accelerator tables use the debug_str section to store their strings.
However, they do not support the indirect method of access that is
available for the debug_info section (DW_FORM_strx et al.).
Currently our code is assuming that all strings can/will be referenced
indirectly, and puts all of them into the debug_str_offsets section.
This is generally true for regular (unsplit) dwarf, but in the DWO case,
most of the strings in the debug_str section will only be used from the
accelerator tables. Therefore the contents of the debug_str_offsets
section will be largely unused and bloating the main executable.
This patch rectifies this by teaching the DwarfStringPool to
differentiate between strings accessed directly and indirectly. When a
user inserts a string into the pool it has to declare whether that
string will be referenced directly or not. If at least one user requsts
indirect access, that string will be assigned an index ID and put into
debug_str_offsets table. Otherwise, the offset table is skipped.
This approach reduces the overall binary size (when compiled with
-gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is
shrunk by 99%).
Reviewers: probinson, dblaikie, JDevlieghere
Subscribers: aprantl, mgrang, llvm-commits
Differential Revision: https://reviews.llvm.org/D49493
llvm-svn: 339122
2018-08-07 17:54:52 +08:00
; SPLIT-NEXT: 0x00000000: "foo.dwo"
; SPLIT-NEXT: 0x[[STRING2SPLIT:[0-9a-f]*]]: "/home/test"
; SPLIT-NEXT: 0x[[STRING3SPLIT:[0-9a-f]*]]: "E"
; SPLIT-NEXT: 0x[[STRING4SPLIT:[0-9a-f]*]]: "glob"
2018-01-31 02:41:31 +08:00
;
; Extract the string offsets referenced in the .dwo file by the split unit.
; SPLIT: .debug_str.dwo contents:
; SPLIT-NEXT: 0x00000000:{{.*}}
; SPLIT-NEXT: 0x[[STRING2DWO:[0-9a-f]*]]{{.*}}
; SPLIT-NEXT: 0x[[STRING3DWO:[0-9a-f]*]]{{.*}}
;
; Check the string offsets sections in both the main and the .dwo files and
[DebugInfo] Reduce debug_str_offsets section size
Summary:
The accelerator tables use the debug_str section to store their strings.
However, they do not support the indirect method of access that is
available for the debug_info section (DW_FORM_strx et al.).
Currently our code is assuming that all strings can/will be referenced
indirectly, and puts all of them into the debug_str_offsets section.
This is generally true for regular (unsplit) dwarf, but in the DWO case,
most of the strings in the debug_str section will only be used from the
accelerator tables. Therefore the contents of the debug_str_offsets
section will be largely unused and bloating the main executable.
This patch rectifies this by teaching the DwarfStringPool to
differentiate between strings accessed directly and indirectly. When a
user inserts a string into the pool it has to declare whether that
string will be referenced directly or not. If at least one user requsts
indirect access, that string will be assigned an index ID and put into
debug_str_offsets table. Otherwise, the offset table is skipped.
This approach reduces the overall binary size (when compiled with
-gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is
shrunk by 99%).
Reviewers: probinson, dblaikie, JDevlieghere
Subscribers: aprantl, mgrang, llvm-commits
Differential Revision: https://reviews.llvm.org/D49493
llvm-svn: 339122
2018-08-07 17:54:52 +08:00
; verify that the extracted string offsets are referenced correctly. The
; sections should contain only the offsets of strings that are actually
; referenced by the debug info.
2018-01-31 02:41:31 +08:00
; SPLIT: .debug_str_offsets contents:
[DebugInfo] Reduce debug_str_offsets section size
Summary:
The accelerator tables use the debug_str section to store their strings.
However, they do not support the indirect method of access that is
available for the debug_info section (DW_FORM_strx et al.).
Currently our code is assuming that all strings can/will be referenced
indirectly, and puts all of them into the debug_str_offsets section.
This is generally true for regular (unsplit) dwarf, but in the DWO case,
most of the strings in the debug_str section will only be used from the
accelerator tables. Therefore the contents of the debug_str_offsets
section will be largely unused and bloating the main executable.
This patch rectifies this by teaching the DwarfStringPool to
differentiate between strings accessed directly and indirectly. When a
user inserts a string into the pool it has to declare whether that
string will be referenced directly or not. If at least one user requsts
indirect access, that string will be assigned an index ID and put into
debug_str_offsets table. Otherwise, the offset table is skipped.
This approach reduces the overall binary size (when compiled with
-gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is
shrunk by 99%).
Reviewers: probinson, dblaikie, JDevlieghere
Subscribers: aprantl, mgrang, llvm-commits
Differential Revision: https://reviews.llvm.org/D49493
llvm-svn: 339122
2018-08-07 17:54:52 +08:00
; SPLIT-NEXT: 0x00000000: Contribution size = 12, Format = DWARF32, Version = 5
; SPLIT-NEXT: 0x00000008: 00000000 "foo.dwo"
; SPLIT-NEXT: 0x0000000c: [[STRING2SPLIT]] "/home/test"
; SPLIT-EMPTY:
2018-01-31 02:41:31 +08:00
; SPLIT: .debug_str_offsets.dwo contents:
2018-05-11 04:02:34 +08:00
; SPLIT-NEXT: 0x00000000: Contribution size = 36, Format = DWARF32, Version = 5
2018-01-31 02:41:31 +08:00
; SPLIT-NEXT: 0x00000008: 00000000{{.*}}
; SPLIT-NEXT: 0x0000000c: [[STRING2DWO]]{{.*}}
; SPLIT-NEXT: 0x00000010: [[STRING3DWO]]
@glob = global i32 0 , align 4 , !dbg !0
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !11 , !12 , !13 }
!llvm.ident = ! { !14 }
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
!1 = distinct !DIGlobalVariable ( name: "glob" , scope: !2 , file: !3 , line: 3 , type: !5 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !3 , producer: "clang version 7.0.0 (trunk 322415)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !10 )
!3 = !DIFile ( filename: "en.cpp" , directory: "/home/test" , checksumkind: C S K _ M D 5 , checksum: "d96b2e2d618e550f0ddd0b6a49c98b02" )
!4 = ! { !5 }
!5 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "E" , file: !3 , line: 1 , size: 32 , elements: !6 , identifier: "_ZTS1E" )
!6 = ! { !7 , !8 , !9 }
!7 = !DIEnumerator ( name: "a" , value: 0 )
!8 = !DIEnumerator ( name: "b" , value: 1 )
!9 = !DIEnumerator ( name: "c" , value: 2 )
!10 = ! { !0 }
!11 = ! { i32 2 , !"Dwarf Version" , i32 5 }
!12 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!13 = ! { i32 1 , !"wchar_size" , i32 4 }
!14 = ! { !"clang version 7.0.0 (trunk 322415)" }