diff options
author | Sergey Matveev <earthdok@google.com> | 2013-11-25 17:39:12 +0000 |
---|---|---|
committer | Sergey Matveev <earthdok@google.com> | 2013-11-25 17:39:12 +0000 |
commit | 12f610efe6f48efb2d03b985b3b2a36d4556fca7 (patch) | |
tree | 65713fc04ca5200695f90ceb3c73ea51e05bde31 | |
parent | d5c29a8584d5284ae4cf7e7176efe0692ccde5c0 (diff) | |
download | compiler-rt-12f610efe6f48efb2d03b985b3b2a36d4556fca7.tar.gz |
Merging r195570:
------------------------------------------------------------------------
r195570 | smatveev | 2013-11-24 18:28:18 +0400 (Sun, 24 Nov 2013) | 4 lines
[lsan] Use real memset to clear memory in standalone LSan.
Performance improvement. Also, the allocator was using CompactSizeClassMap for
no good reason, so I switched it to DefaultSizeClassMap.
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_34@195665 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/lsan/lsan_allocator.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/lsan/lsan_allocator.cc b/lib/lsan/lsan_allocator.cc index 1512c2e85..f7eee1314 100644 --- a/lib/lsan/lsan_allocator.cc +++ b/lib/lsan/lsan_allocator.cc @@ -20,6 +20,8 @@ #include "sanitizer_common/sanitizer_stacktrace.h" #include "lsan_common.h" +extern "C" void *memset(void *ptr, int value, uptr num); + namespace __lsan { static const uptr kMaxAllowedMallocSize = 8UL << 30; @@ -34,7 +36,7 @@ struct ChunkMetadata { }; typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, - sizeof(ChunkMetadata), CompactSizeClassMap> PrimaryAllocator; + sizeof(ChunkMetadata), DefaultSizeClassMap> PrimaryAllocator; typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache; typedef LargeMmapAllocator<> SecondaryAllocator; typedef CombinedAllocator<PrimaryAllocator, AllocatorCache, @@ -80,7 +82,10 @@ void *Allocate(const StackTrace &stack, uptr size, uptr alignment, Report("WARNING: LeakSanitizer failed to allocate %zu bytes\n", size); return 0; } - void *p = allocator.Allocate(&cache, size, alignment, cleared); + void *p = allocator.Allocate(&cache, size, alignment, false); + // Do not rely on the allocator to clear the memory (it's slow). + if (cleared && allocator.FromPrimary(p)) + memset(p, 0, size); RegisterAllocation(stack, p, size); return p; } |