summaryrefslogtreecommitdiff
path: root/lib/lsan/lsan_allocator.cc
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-11-24 14:28:18 +0000
committerSergey Matveev <earthdok@google.com>2013-11-24 14:28:18 +0000
commit3d0deab266106ebb1fa5169deab1a545238e6b24 (patch)
treedcd38669b8312aa34442fc5b47c0517ded501e6f /lib/lsan/lsan_allocator.cc
parent3f60244d1478ea127521a4b8f0ab7ea79643603e (diff)
[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/trunk@195570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/lsan/lsan_allocator.cc')
-rw-r--r--lib/lsan/lsan_allocator.cc9
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;
}