[llvm-branch-commits] [compiler-rt-branch] r195665 - Merging r195570:
Sergey Matveev
earthdok at google.com
Mon Nov 25 09:39:13 PST 2013
Author: smatveev
Date: Mon Nov 25 11:39:12 2013
New Revision: 195665
URL: http://llvm.org/viewvc/llvm-project?rev=195665&view=rev
Log:
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.
------------------------------------------------------------------------
Modified:
compiler-rt/branches/release_34/ (props changed)
compiler-rt/branches/release_34/lib/lsan/lsan_allocator.cc
Propchange: compiler-rt/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 25 11:39:12 2013
@@ -1 +1 @@
-/compiler-rt/trunk:195427,195433-195434,195436,195442
+/compiler-rt/trunk:195427,195433-195434,195436,195442,195570
Modified: compiler-rt/branches/release_34/lib/lsan/lsan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_34/lib/lsan/lsan_allocator.cc?rev=195665&r1=195664&r2=195665&view=diff
==============================================================================
--- compiler-rt/branches/release_34/lib/lsan/lsan_allocator.cc (original)
+++ compiler-rt/branches/release_34/lib/lsan/lsan_allocator.cc Mon Nov 25 11:39:12 2013
@@ -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,
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;
}
More information about the llvm-branch-commits
mailing list