[compiler-rt] r359715 - [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 12:30:49 PDT 2019


Author: vitalybuka
Date: Wed May  1 12:30:49 2019
New Revision: 359715

URL: http://llvm.org/viewvc/llvm-project?rev=359715&view=rev
Log:
[sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator

Reviewers: eugenis, cryptoad, kcc

Reviewed By: kcc

Subscribers: kcc, kubamracek, #sanitizers, llvm-commits

Tags: #sanitizers, #llvm

Differential Revision: https://reviews.llvm.org/D61155

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/scudo/scudo_allocator.h
    compiler-rt/trunk/lib/scudo/scudo_allocator_combined.h
    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=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_allocator.h (original)
+++ compiler-rt/trunk/lib/asan/asan_allocator.h Wed May  1 12:30:49 2019
@@ -184,10 +184,6 @@ using PrimaryAllocator = PrimaryAllocato
 #endif  // SANITIZER_CAN_USE_ALLOCATOR64
 
 static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses;
-template <typename AddressSpaceView>
-using AllocatorCacheASVT =
-    SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>;
-using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>;
 
 template <typename AddressSpaceView>
 using SecondaryAllocatorASVT =
@@ -196,10 +192,10 @@ using SecondaryAllocatorASVT =
 template <typename AddressSpaceView>
 using AsanAllocatorASVT =
     CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
-                      AllocatorCacheASVT<AddressSpaceView>,
                       SecondaryAllocatorASVT<AddressSpaceView>,
                       AddressSpaceView>;
 using AsanAllocator = AsanAllocatorASVT<LocalAddressSpaceView>;
+using AllocatorCache = AsanAllocator::AllocatorCache;
 
 struct AsanThreadLocalMallocStorage {
   uptr quarantine_cache[16];

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=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_allocator.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_allocator.h Wed May  1 12:30:49 2019
@@ -61,10 +61,9 @@ struct AP64 {
   static const uptr kFlags = 0;
 };
 typedef SizeClassAllocator64<AP64> PrimaryAllocator;
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
 typedef LargeMmapAllocator<HwasanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
-                          SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> 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=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan_allocator.h (original)
+++ compiler-rt/trunk/lib/lsan/lsan_allocator.h Wed May  1 12:30:49 2019
@@ -90,11 +90,6 @@ using PrimaryAllocator = PrimaryAllocato
 #endif
 
 template <typename AddressSpaceView>
-using AllocatorCacheASVT =
-    SizeClassAllocatorLocalCache<PrimaryAllocatorASVT<AddressSpaceView>>;
-using AllocatorCache = AllocatorCacheASVT<LocalAddressSpaceView>;
-
-template <typename AddressSpaceView>
 using SecondaryAllocatorASVT =
     LargeMmapAllocator<NoOpMapUnmapCallback, DefaultLargeMmapAllocatorPtrArray,
                        AddressSpaceView>;
@@ -102,12 +97,12 @@ using SecondaryAllocatorASVT =
 template <typename AddressSpaceView>
 using AllocatorASVT =
     CombinedAllocator<PrimaryAllocatorASVT<AddressSpaceView>,
-                      AllocatorCacheASVT<AddressSpaceView>,
                       SecondaryAllocatorASVT<AddressSpaceView>,
                       AddressSpaceView>;
 using Allocator = AllocatorASVT<LocalAddressSpaceView>;
+using AllocatorCache = Allocator::AllocatorCache;
 
-AllocatorCache *GetAllocatorCache();
+Allocator::AllocatorCache *GetAllocatorCache();
 
 int lsan_posix_memalign(void **memptr, uptr alignment, uptr size,
                         const StackTrace &stack);

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=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan_allocator.cc (original)
+++ compiler-rt/trunk/lib/msan/msan_allocator.cc Wed May  1 12:30:49 2019
@@ -108,10 +108,9 @@ struct AP32 {
 };
 typedef SizeClassAllocator32<AP32> PrimaryAllocator;
 #endif
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
 typedef LargeMmapAllocator<MsanMapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
-                          SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef Allocator::AllocatorCache AllocatorCache;
 
 static Allocator allocator;
 static AllocatorCache fallback_allocator_cache;

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=359715&r1=359714&r2=359715&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:30:49 2019
@@ -19,11 +19,11 @@
 //  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 AllocatorCache,
-          class SecondaryAllocator,
+template <class PrimaryAllocator, class SecondaryAllocator,
           typename AddressSpaceViewTy = LocalAddressSpaceView>  // NOLINT
 class CombinedAllocator {
  public:
+  using AllocatorCache = SizeClassAllocatorLocalCache<PrimaryAllocator>;
   using AddressSpaceView = AddressSpaceViewTy;
   static_assert(is_same<AddressSpaceView,
                         typename PrimaryAllocator::AddressSpaceView>::value,

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=359715&r1=359714&r2=359715&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:30:49 2019
@@ -34,15 +34,13 @@ struct AP32 {
 };
 typedef SizeClassAllocator32<AP32> PrimaryInternalAllocator;
 
-typedef SizeClassAllocatorLocalCache<PrimaryInternalAllocator>
-    InternalAllocatorCache;
-
 typedef LargeMmapAllocator<NoOpMapUnmapCallback,
                            LargeMmapAllocatorPtrArrayStatic>
     SecondaryInternalAllocator;
 
-typedef CombinedAllocator<PrimaryInternalAllocator, InternalAllocatorCache,
-                          SecondaryInternalAllocator> InternalAllocator;
+typedef CombinedAllocator<PrimaryInternalAllocator, SecondaryInternalAllocator>
+    InternalAllocator;
+typedef InternalAllocator::AllocatorCache InternalAllocatorCache;
 
 void *InternalAlloc(uptr size, InternalAllocatorCache *cache = nullptr,
                     uptr alignment = 0);

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=359715&r1=359714&r2=359715&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:30:49 2019
@@ -615,17 +615,14 @@ TEST(SanitizerCommon, LargeMmapAllocator
   a.Deallocate(&stats, p);
 }
 
-template
-<class PrimaryAllocator, class SecondaryAllocator, class AllocatorCache>
+template <class PrimaryAllocator, class SecondaryAllocator>
 void TestCombinedAllocator() {
-  typedef
-      CombinedAllocator<PrimaryAllocator, AllocatorCache, SecondaryAllocator>
-      Allocator;
+  typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
   Allocator *a = new Allocator;
   a->Init(kReleaseToOSIntervalNever);
   std::mt19937 r;
 
-  AllocatorCache cache;
+  typename Allocator::AllocatorCache cache;
   memset(&cache, 0, sizeof(cache));
   a->InitCache(&cache);
 
@@ -686,36 +683,26 @@ void TestCombinedAllocator() {
 
 #if SANITIZER_CAN_USE_ALLOCATOR64
 TEST(SanitizerCommon, CombinedAllocator64) {
-  TestCombinedAllocator<Allocator64,
-      LargeMmapAllocator<>,
-      SizeClassAllocatorLocalCache<Allocator64> > ();
+  TestCombinedAllocator<Allocator64, LargeMmapAllocator<>>();
 }
 
 TEST(SanitizerCommon, CombinedAllocator64Dynamic) {
-  TestCombinedAllocator<Allocator64Dynamic,
-      LargeMmapAllocator<>,
-      SizeClassAllocatorLocalCache<Allocator64Dynamic> > ();
+  TestCombinedAllocator<Allocator64Dynamic, LargeMmapAllocator<>>();
 }
 
 #if !SANITIZER_ANDROID
 TEST(SanitizerCommon, CombinedAllocator64Compact) {
-  TestCombinedAllocator<Allocator64Compact,
-      LargeMmapAllocator<>,
-      SizeClassAllocatorLocalCache<Allocator64Compact> > ();
+  TestCombinedAllocator<Allocator64Compact, LargeMmapAllocator<>>();
 }
 #endif
 
 TEST(SanitizerCommon, CombinedAllocator64VeryCompact) {
-  TestCombinedAllocator<Allocator64VeryCompact,
-      LargeMmapAllocator<>,
-      SizeClassAllocatorLocalCache<Allocator64VeryCompact> > ();
+  TestCombinedAllocator<Allocator64VeryCompact, LargeMmapAllocator<>>();
 }
 #endif
 
 TEST(SanitizerCommon, CombinedAllocator32Compact) {
-  TestCombinedAllocator<Allocator32Compact,
-      LargeMmapAllocator<>,
-      SizeClassAllocatorLocalCache<Allocator32Compact> > ();
+  TestCombinedAllocator<Allocator32Compact, LargeMmapAllocator<>>();
 }
 
 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=359715&r1=359714&r2=359715&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:30:49 2019
@@ -49,10 +49,9 @@ struct __AP64 {
 namespace {
 
 typedef SizeClassAllocator64<__AP64> PrimaryAllocator;
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
 typedef LargeMmapAllocator<> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
-          SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef Allocator::AllocatorCache AllocatorCache;
 
 static Allocator allocator;
 static bool global_inited;

Modified: compiler-rt/trunk/lib/scudo/scudo_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/scudo_allocator.h?rev=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/scudo_allocator.h (original)
+++ compiler-rt/trunk/lib/scudo/scudo_allocator.h Wed May  1 12:30:49 2019
@@ -102,9 +102,9 @@ typedef SizeClassAllocator32<AP32> Prima
 #include "scudo_allocator_secondary.h"
 #include "scudo_allocator_combined.h"
 
-typedef SizeClassAllocatorLocalCache<PrimaryT> AllocatorCacheT;
 typedef LargeMmapAllocator SecondaryT;
-typedef CombinedAllocator<PrimaryT, AllocatorCacheT, SecondaryT> BackendT;
+typedef CombinedAllocator<PrimaryT, SecondaryT> BackendT;
+typedef BackendT::AllocatorCache AllocatorCacheT;
 
 void initScudo();
 

Modified: compiler-rt/trunk/lib/scudo/scudo_allocator_combined.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/scudo_allocator_combined.h?rev=359715&r1=359714&r2=359715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/scudo_allocator_combined.h (original)
+++ compiler-rt/trunk/lib/scudo/scudo_allocator_combined.h Wed May  1 12:30:49 2019
@@ -18,10 +18,10 @@
 # error "This file must be included inside scudo_allocator.h."
 #endif
 
-template <class PrimaryAllocator, class AllocatorCache,
-    class SecondaryAllocator>
+template <class PrimaryAllocator, class SecondaryAllocator>
 class CombinedAllocator {
  public:
+  using AllocatorCache = typename PrimaryAllocator::AllocatorCache;
   void init(s32 ReleaseToOSIntervalMs) {
     Primary.Init(ReleaseToOSIntervalMs);
     Secondary.Init();

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=359715&r1=359714&r2=359715&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:30:49 2019
@@ -79,10 +79,9 @@ struct AP64 {  // Allocator64 parameters
 };
 typedef SizeClassAllocator64<AP64> PrimaryAllocator;
 #endif
-typedef SizeClassAllocatorLocalCache<PrimaryAllocator> AllocatorCache;
 typedef LargeMmapAllocator<MapUnmapCallback> SecondaryAllocator;
-typedef CombinedAllocator<PrimaryAllocator, AllocatorCache,
-    SecondaryAllocator> Allocator;
+typedef CombinedAllocator<PrimaryAllocator, SecondaryAllocator> Allocator;
+typedef Allocator::AllocatorCache AllocatorCache;
 Allocator *allocator();
 #endif
 




More information about the llvm-commits mailing list