diff options
| author | Sergey Matveev <earthdok@google.com> | 2013-11-24 14:28:18 +0000 |
|---|---|---|
| committer | Sergey Matveev <earthdok@google.com> | 2013-11-24 14:28:18 +0000 |
| commit | 10548681c05db944e730e20137996e847e887061 (patch) | |
| tree | 3f8ec86fe2411c8fbfc094d7049902894a94bfdf /compiler-rt | |
| parent | a787aa2b1e6bad9b563ff448d7f48e8a5a2d5ea7 (diff) | |
| download | bcm5719-llvm-10548681c05db944e730e20137996e847e887061.tar.gz bcm5719-llvm-10548681c05db944e730e20137996e847e887061.zip | |
[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.
llvm-svn: 195570
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/lsan/lsan_allocator.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler-rt/lib/lsan/lsan_allocator.cc b/compiler-rt/lib/lsan/lsan_allocator.cc index 1512c2e85f2..f7eee1314bf 100644 --- a/compiler-rt/lib/lsan/lsan_allocator.cc +++ b/compiler-rt/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; } |

