llvm.org GIT mirror llvm / 2e3463e
Compress debug sections only when beneficial. Both ZLIB and the debug info compressed section header ("ZLIB" + the size of the uncompressed data) take some constant overhead so in some cases the compressed data is actually larger than the uncompressed data. In these cases, just don't compress or rename the section at all. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206659 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 6 years ago
2 changed file(s) with 37 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
12081208 // Include the debug info compression header:
12091209 // "ZLIB" followed by 8 bytes representing the uncompressed size of the section,
12101210 // useful for consumers to preallocate a buffer to decompress into.
1211 static void
1211 static bool
12121212 prependCompressionHeader(uint64_t Size,
12131213 SmallVectorImpl &CompressedContents) {
12141214 static const StringRef Magic = "ZLIB";
1215 if (Size <= Magic.size() + sizeof(Size) + CompressedContents.size())
1216 return false;
12151217 if (sys::IsLittleEndianHost)
12161218 Size = sys::SwapByteOrder(Size);
12171219 CompressedContents.insert(CompressedContents.begin(),
12201222 std::copy(reinterpret_cast(&Size),
12211223 reinterpret_cast(&Size + 1),
12221224 CompressedContents.begin() + Magic.size());
1225 return true;
12231226 }
12241227
12251228 // Return a single fragment containing the compressed contents of the whole
12421245 if (Success != zlib::StatusOK)
12431246 return nullptr;
12441247
1245 prependCompressionHeader(UncompressedData.size(), CompressedContents);
1248 if (!prependCompressionHeader(UncompressedData.size(), CompressedContents))
1249 return nullptr;
12461250
12471251 return CompressedFragment;
12481252 }
0 // RUN: llvm-mc -filetype=obj -compress-debug-sections -triple x86_64-pc-linux-gnu < %s -o %t
11 // RUN: llvm-objdump -s %t | FileCheck %s
2 // RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=ABBREV %s
2 // RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck --check-prefix=INFO %s
33 // RUN: llvm-mc -filetype=obj -compress-debug-sections -triple i386-pc-linux-gnu < %s \
44 // RUN: | llvm-readobj -symbols - | FileCheck --check-prefix=386-SYMBOLS %s
55
1111 // CHECK-NOT: ZLIB
1212 // CHECK: Contents of
1313
14 // CHECK: Contents of section .zdebug_abbrev:
15 // CHECK-NEXT: ZLIB
14 // Don't compress small sections, such as this simple debug_abbrev example
15 // CHECK: Contents of section .debug_abbrev:
16 // CHECK-NOT: ZLIB
17 // CHECK-NOT: Contents of
18
19 // CHECK: Contents of section .debug_info:
1620
1721 // FIXME: Handle compressing alignment fragments to support compressing debug_frame
1822 // CHECK: Contents of section .debug_frame:
2024 // CHECK: Contents of
2125
2226 // Decompress one valid dwarf section just to check that this roundtrips
23 // ABBREV: Abbrev table for offset: 0x00000000
24 // ABBREV: [1] DW_TAG_compile_unit DW_CHILDREN_no
27 // INFO: 0x00000000: Compile Unit: length = 0x0000000c version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x00000010)
2528
2629 // In x86 32 bit named symbols are used for temporary symbols in merge
2730 // sections, so make sure we handle symbols inside compressed sections
4043 .byte 14 # DW_FORM_strp
4144 .byte 0 # EOM(1)
4245 .byte 0 # EOM(2)
46
47 .section .debug_info,"",@progbits
48 .long 12 # Length of Unit
49 .short 4 # DWARF version number
50 .long .Lsection_abbrev # Offset Into Abbrev. Section
51 .byte 8 # Address Size (in bytes)
52 .byte 1 # Abbrev [1] DW_TAG_compile_unit
53 .long .Linfo_string0 # DW_AT_comp_dir
54
4355 .text
4456 foo:
4557 .cfi_startproc
4658 .file 1 "Driver.ii"
59 # pad out the line table to make sure it's big enough to warrant compression
4760 .loc 1 2 0
61 nop
62 .loc 1 3 0
63 nop
64 .loc 1 4 0
65 nop
66 .loc 1 5 0
67 nop
68 .loc 1 6 0
69 nop
70 .loc 1 7 0
71 nop
72 .loc 1 8 0
4873 nop
4974 .cfi_endproc
5075 .cfi_sections .debug_frame
5176
5277 .section .debug_str,"MS",@progbits,1
5378 .Linfo_string0:
54 .asciz "foo"
55
56 .section .debug_info,"",@progbits
57 .long 40 # Length of Unit
58 .short 4 # DWARF version number
59 .long .Lsection_abbrev # Offset Into Abbrev. Section
60 .byte 4 # Address Size (in bytes)
61 .byte 1 # Abbrev [1] DW_TAG_compile_unit
62 .long .Linfo_string0 # DW_AT_comp_dir
79 .asciz "compress this "