diff options
author | Fangrui Song <maskray@google.com> | 2018-08-03 19:37:49 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-08-03 19:37:49 +0000 |
commit | 23310a89be17e44babd54650d76ef1a236b8a879 (patch) | |
tree | 61f1835c9b77ea0c3d85058f369eecb3f9d5512c /llvm/lib/Support/Compression.cpp | |
parent | eaa18e60ebe22b9b7cb76562a313f0c3e1cb1810 (diff) | |
download | bcm5719-llvm-23310a89be17e44babd54650d76ef1a236b8a879.tar.gz bcm5719-llvm-23310a89be17e44babd54650d76ef1a236b8a879.zip |
[Support] Don't initialize compressed buffer allocated by zlib::compress
resize() (zeroing) makes every allocated page resident. The actual size of the compressed buffer is usually much
smaller. Making every page resident is wasteful.
When linking a test binary with ~1.9GiB uncompressed debug info with LLD, this optimization decreases max RSS by ~1.5GiB.
Differential Revision: https://reviews.llvm.org/50223
llvm-svn: 338913
Diffstat (limited to 'llvm/lib/Support/Compression.cpp')
-rw-r--r-- | llvm/lib/Support/Compression.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/Compression.cpp b/llvm/lib/Support/Compression.cpp index c279d10f6c6..05bd7b58e08 100644 --- a/llvm/lib/Support/Compression.cpp +++ b/llvm/lib/Support/Compression.cpp @@ -61,7 +61,7 @@ Error zlib::compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer, CompressionLevel Level) { unsigned long CompressedSize = ::compressBound(InputBuffer.size()); - CompressedBuffer.resize(CompressedSize); + CompressedBuffer.reserve(CompressedSize); int CLevel = encodeZlibCompressionLevel(Level); int Res = ::compress2((Bytef *)CompressedBuffer.data(), &CompressedSize, (const Bytef *)InputBuffer.data(), InputBuffer.size(), @@ -69,7 +69,7 @@ Error zlib::compress(StringRef InputBuffer, // Tell MemorySanitizer that zlib output buffer is fully initialized. // This avoids a false report when running LLVM with uninstrumented ZLib. __msan_unpoison(CompressedBuffer.data(), CompressedSize); - CompressedBuffer.resize(CompressedSize); + CompressedBuffer.set_size(CompressedSize); return Res ? createError(convertZlibCodeToString(Res)) : Error::success(); } |