summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2019-05-01 19:41:54 +0000
committerVitaly Buka <vitalybuka@google.com>2019-05-01 19:41:54 +0000
commit20c5676416d3b1fff74ee4603d4eb1c646ae22bd (patch)
treea78ef03da6b8158c092da997349301e64910346a
parent7780f516142c7505aff1210efff5cb6c53014a9b (diff)
downloadbcm5719-llvm-20c5676416d3b1fff74ee4603d4eb1c646ae22bd.tar.gz
bcm5719-llvm-20c5676416d3b1fff74ee4603d4eb1c646ae22bd.zip
[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 llvm-svn: 359719
-rw-r--r--compiler-rt/lib/asan/asan_allocator.h8
-rw-r--r--compiler-rt/lib/hwasan/hwasan_allocator.h3
-rw-r--r--compiler-rt/lib/lsan/lsan_allocator.h10
-rw-r--r--compiler-rt/lib/msan/msan_allocator.cc3
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h15
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h7
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc14
-rw-r--r--compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc3
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.h3
9 files changed, 21 insertions, 45 deletions
diff --git a/compiler-rt/lib/asan/asan_allocator.h b/compiler-rt/lib/asan/asan_allocator.h
index 63dbfd60473..6add47be2c9 100644
--- a/compiler-rt/lib/asan/asan_allocator.h
+++ b/compiler-rt/lib/asan/asan_allocator.h
@@ -186,14 +186,8 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
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;
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.h b/compiler-rt/lib/hwasan/hwasan_allocator.h
index 2070df1502f..3a50a11f352 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.h
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -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);
diff --git a/compiler-rt/lib/lsan/lsan_allocator.h b/compiler-rt/lib/lsan/lsan_allocator.h
index bef78128d40..e1397099767 100644
--- a/compiler-rt/lib/lsan/lsan_allocator.h
+++ b/compiler-rt/lib/lsan/lsan_allocator.h
@@ -90,15 +90,7 @@ using PrimaryAllocator = PrimaryAllocatorASVT<LocalAddressSpaceView>;
#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;
diff --git a/compiler-rt/lib/msan/msan_allocator.cc b/compiler-rt/lib/msan/msan_allocator.cc
index 59c39cbef95..1816840012e 100644
--- a/compiler-rt/lib/msan/msan_allocator.cc
+++ b/compiler-rt/lib/msan/msan_allocator.cc
@@ -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;
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
index e21d7a9623b..5b3dd15df6e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h
@@ -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();
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h
index 7d5b2f3c34f..32849036fd0 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h
@@ -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;
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
index 4c4ccb5fe79..790662d9997 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc
@@ -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>
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
index 34abbe61539..e7d482fecce 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_testlib.cc
@@ -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;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index c37eab9dac1..d58c1dca472 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -79,8 +79,7 @@ struct AP64 { // Allocator64 parameters. Deliberately using a short name.
};
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
OpenPOWER on IntegriCloud