Commit Graph

4 Commits

Author SHA1 Message Date
Fangrui Song 81cebfd008 [ELF][test] Change -o %t to -o /dev/null if the output is not needed 2020-02-12 21:54:50 -08:00
Rui Ueyama e28c146423 Avoid unnecessary buffer allocation and memcpy for compressed sections.
Previously, we uncompress all compressed sections before doing anything.
That works, and that is conceptually simple, but that could results in
a waste of CPU time and memory if uncompressed sections are then
discarded or just copied to the output buffer.

In particular, if .debug_gnu_pub{names,types} are compressed and if no
-gdb-index option is given, we wasted CPU and memory because we
uncompress them into newly allocated bufers and then memcpy the buffers
to the output buffer. That temporary buffer was redundant.

This patch changes how to uncompress sections. Now, compressed sections
are uncompressed lazily. To do that, `Data` member of `InputSectionBase`
is now hidden from outside, and `data()` accessor automatically expands
an compressed buffer if necessary.

If no one calls `data()`, then `writeTo()` directly uncompresses
compressed data into the output buffer. That eliminates the redundant
memory allocation and redundant memcpy.

This patch significantly reduces memory consumption (20 GiB max RSS to
15 Gib) for an executable whose .debug_gnu_pub{names,types} are in total
5 GiB in an uncompressed form.

Differential Revision: https://reviews.llvm.org/D52917

llvm-svn: 343979
2018-10-08 16:58:59 +00:00
George Rimar ea5d3f23e0 [ELF] - Fix BB. 'Filecheck' -> 'FileCheck'.
llvm-svn: 337254
2018-07-17 09:10:16 +00:00
George Rimar ff71afe809 [ELF] - Check we are able to report zlib decompressor errors.
This test case adds a check for the following line of the code:
https://github.com/llvm-mirror/lld/blob/master/ELF/InputSection.cpp#L194

llvm-svn: 337252
2018-07-17 08:42:42 +00:00