[compiler-rt] r359719 - [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed May 1 12:41:54 PDT 2019
Author: vitalybuka
Date: Wed May 1 12:41:54 2019
New Revision: 359719
URL: http://llvm.org/viewvc/llvm-project?rev=359719&view=rev
Log:
[sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator
They need to have same AddressSpaceView and MapUnmapCallback.
Reviewers: eugenis
Subscribers: kubamracek, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D61168
Modified:
compiler-rt/trunk/lib/asan/asan_allocator.h
compiler-rt/trunk/lib/hwasan/hwasan_allocator.h
compiler-rt/trunk/lib/lsan/lsan_allocator.h
compiler-rt/trunk/lib/msan/msan_allocator.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
Modified: compiler-rt/trunk/lib/asan/asan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_allocator.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Wed May 1 12:41:54 2019
@@ -186,14 +186,8 @@ using PrimaryAllocator = PrimaryAllocato
static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses;
template <typename AddressSpaceView>
-using SecondaryAllocatorASVT =
- LargeMmapAllocator<AsanMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
- AddressSpaceView>;
-template <typename AddressSpaceView>
using AsanAllocatorASVT =
- CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
- SecondaryAllocatorASVT<AddressSpaceView>,
- AddressSpaceView>;
+ CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>;
using AllocatorCache = AsanAllocator::AllocatorCache;
Modified: compiler-rt/trunk/lib/hwasan/hwasan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_allocator.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_allocator.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_allocator.h Wed May 1 12:41:54 2019
@@ -61,8 +61,7 @@ struct AP64 {
static const uptr kFlags = 0;
};
typedef SizeClassAllocator64<AP64> PrimaryAllocator;
-typedef LargeMmapAllocator<HwasanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
typedef Allocator::AllocatorCache AllocatorCache;
void AllocatorSwallowThreadLocalCache(AllocatorCache *cache);
Modified: compiler-rt/trunk/lib/lsan/lsan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan_allocator.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.h (original)
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.h Wed May 1 12:41:54 2019
@@ -90,15 +90,7 @@ using PrimaryAllocator = PrimaryAllocato
#endif
template <typename AddressSpaceView>
-using SecondaryAllocatorASVT =
- LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
- AddressSpaceView>;
-
-template <typename AddressSpaceView>
-using AllocatorASVT =
- CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
- SecondaryAllocatorASVT<AddressSpaceView>,
- AddressSpaceView>;
+using AllocatorASVT = CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>>;
using Allocator = AllocatorASVT<LocalAddressSpaceView>;
using AllocatorCache = Allocator::AllocatorCache;
Modified: compiler-rt/trunk/lib/msan/msan_allocator.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan_allocator.cc?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_allocator.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_allocator.cc Wed May 1 12:41:54 2019
@@ -108,8 +108,7 @@ struct AP32 {
};
typedef SizeClassAllocator32<AP32> PrimaryAllocator;
#endif
-typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
typedef Allocator::AllocatorCache AllocatorCache;
static Allocator allocator;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_combined.h Wed May 1 12:41:54 2019
@@ -19,18 +19,15 @@
// When allocating 2^x bytes it should return 2^x aligned chunk.
// PrimaryAllocator is used via a local AllocatorCache.
// SecondaryAllocator can allocate anything, but is not efficient.
-template <class PrimaryAllocator, class SecondaryAllocator,
- typename AddressSpaceViewTy = LocalAddressSpaceView> // NOLINT
+template <class PrimaryAllocator,
+ class LargeMmapAllocatorPtrArray = DefaultLargeMmapAllocatorPtrArray>
class CombinedAllocator {
public:
using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>;
- using AddressSpaceView = AddressSpaceViewTy;
- static_assert(is_same<AddressSpaceView,
- typename PrimaryAllocator::AddressSpaceView>::value,
- "PrimaryAllocator is using wrong AddressSpaceView");
- static_assert(is_same<AddressSpaceView,
- typename SecondaryAllocator::AddressSpaceView>::value,
- "SecondaryAllocator is using wrong AddressSpaceView");
+ using SecondaryAllocator =
+ LargeMmapAllocator<typename PrimaryAllocator::MapUnmapCallback,
+ LargeMmapAllocatorPtrArray,
+ typename PrimaryAllocator::AddressSpaceView>;
void InitLinkerInitialized(s32 release_to_os_interval_ms) {
stats_.InitLinkerInitialized();
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_internal.h Wed May 1 12:41:54 2019
@@ -34,11 +34,8 @@ struct AP32 {
};
typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
-typedef LargeMmapAllocator<NoOpMapUnmapCallback,
- LargeMmapAllocatorPtrArrayStatic>
- SecondaryInternalAllocator;
-
-typedef CombinedAllocator<PrimaryInternalAllocator, SecondaryInternalAllocator>
+typedef CombinedAllocator<PrimaryInternalAllocator,
+ LargeMmapAllocatorPtrArrayStatic>
InternalAllocator;
typedef InternalAllocator::AllocatorCache InternalAllocatorCache;
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_test.cc Wed May 1 12:41:54 2019
@@ -615,9 +615,9 @@ TEST(SanitizerCommon, LargeMmapAllocator
a.Deallocate(&stats, p);
}
-template <class PrimaryAllocator, class SecondaryAllocator>
+template <class PrimaryAllocator>
void TestCombinedAllocator() {
- typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+ typedef CombinedAllocator<PrimaryAllocator> Allocator;
Allocator *a = new Allocator;
a->Init(kReleaseToOSIntervalNever);
std::mt19937 r;
@@ -683,26 +683,26 @@ void TestCombinedAllocator() {
#if SANITIZER_CAN_USE_ALLOCATOR64
TEST(SanitizerCommon, CombinedAllocator64) {
- TestCombinedAllocator<Allocator64, LargeMmapAllocator<>>();
+ TestCombinedAllocator<Allocator64>();
}
TEST(SanitizerCommon, CombinedAllocator64Dynamic) {
- TestCombinedAllocator<Allocator64Dynamic, LargeMmapAllocator<>>();
+ TestCombinedAllocator<Allocator64Dynamic>();
}
#if !SANITIZER_ANDROID
TEST(SanitizerCommon, CombinedAllocator64Compact) {
- TestCombinedAllocator<Allocator64Compact, LargeMmapAllocator<>>();
+ TestCombinedAllocator<Allocator64Compact>();
}
#endif
TEST(SanitizerCommon, CombinedAllocator64VeryCompact) {
- TestCombinedAllocator<Allocator64VeryCompact, LargeMmapAllocator<>>();
+ TestCombinedAllocator<Allocator64VeryCompact>();
}
#endif
TEST(SanitizerCommon, CombinedAllocator32Compact) {
- TestCombinedAllocator<Allocator32Compact, LargeMmapAllocator<>>();
+ TestCombinedAllocator<Allocator32Compact>();
}
template <class AllocatorCache>
Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc Wed May 1 12:41:54 2019
@@ -49,8 +49,7 @@ struct __AP64 {
namespace {
typedef SizeClassAllocator64<__AP64> PrimaryAllocator;
-typedef LargeMmapAllocator<> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
typedef Allocator::AllocatorCache AllocatorCache;
static Allocator allocator;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=359719&r1=359718&r2=359719&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Wed May 1 12:41:54 2019
@@ -79,8 +79,7 @@ struct AP64 { // Allocator64 parameters
};
typedef SizeClassAllocator64<AP64> PrimaryAllocator;
#endif
-typedef LargeMmapAllocator<MapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator> Allocator;
typedef Allocator::AllocatorCache AllocatorCache;
Allocator *allocator();
#endif
More information about the llvm-commits
mailing list