[msan] Use SizeClassAllocator64 for AArch64
authorFangrui Song <i@maskray.me>
Mon, 9 Jan 2023 19:49:08 +0000 (19:49 +0000)
committerFangrui Song <i@maskray.me>
Mon, 9 Jan 2023 19:49:08 +0000 (19:49 +0000)
Now that D137666 requires 48-bit VMA for AArch64, we can switch to
SizeClassAllocator64 for a slightly more efficient allocator
(asan/lsan already switched by default).

It seems that we can pick kSpaceBeg = 0xE00000000000ULL to support both Linux
("app-15") and FreeBSD ("high memory").

Reviewed By: #sanitizers, vitalybuka

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

compiler-rt/lib/msan/msan_allocator.cpp

index 53f47bd..3308ee7 100644 (file)
@@ -109,17 +109,16 @@ typedef SizeClassAllocator64<AP64> PrimaryAllocator;
 #elif defined(__aarch64__)
 static const uptr kMaxAllowedMallocSize = 8UL << 30;
 
-struct AP32 {
-  static const uptr kSpaceBeg = 0;
-  static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE;
+struct AP64 {
+  static const uptr kSpaceBeg = 0xE00000000000ULL;
+  static const uptr kSpaceSize = 0x40000000000;  // 4T.
   static const uptr kMetadataSize = sizeof(Metadata);
-  typedef __sanitizer::CompactSizeClassMap SizeClassMap;
-  static const uptr kRegionSizeLog = 20;
-  using AddressSpaceView = LocalAddressSpaceView;
+  typedef DefaultSizeClassMap SizeClassMap;
   typedef MsanMapUnmapCallback MapUnmapCallback;
   static const uptr kFlags = 0;
+  using AddressSpaceView = LocalAddressSpaceView;
 };
-typedef SizeClassAllocator32<AP32> PrimaryAllocator;
+typedef SizeClassAllocator64<AP64> PrimaryAllocator;
 #endif
 typedef CombinedAllocator<PrimaryAllocator> Allocator;
 typedef Allocator::AllocatorCache AllocatorCache;