forked from OSchip/llvm-project
[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
This commit is contained in:
parent
eaa18e60eb
commit
23310a89be
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue