From: Vitaly Buka Date: Fri, 26 Apr 2019 18:22:47 +0000 (+0000) Subject: [sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type X-Git-Tag: llvmorg-10-init~6897 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85dcdae5e366e011a314e86f62d03fdea8d2ffd4;p=platform%2Fupstream%2Fllvm.git [sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type Summary: If bots work we can replace #ifs with template specialization by TwoLevelByteMapSize1. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61200 llvm-svn: 359333 --- diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h index d773815..04f0326 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h @@ -47,6 +47,10 @@ struct SizeClassAllocator32FlagMasks { // Bit masks. template class SizeClassAllocator32 { + private: + static const u64 TwoLevelByteMapSize1 = + (Params::kSpaceSize >> Params::kRegionSizeLog) >> 12; + public: using AddressSpaceView = typename Params::AddressSpaceView; static const uptr kSpaceBeg = Params::kSpaceBeg; @@ -58,12 +62,12 @@ class SizeClassAllocator32 { typedef typename Params::MapUnmapCallback MapUnmapCallback; #if SANITIZER_WORDSIZE == 32 + static_assert(TwoLevelByteMapSize1 <= 128, "FlatByteMap should be used"); using BM = FlatByteMap<(Params::kSpaceSize >> Params::kRegionSizeLog), AddressSpaceView>; #elif SANITIZER_WORDSIZE == 64 - using BM = - TwoLevelByteMap<((Params::kSpaceSize >> Params::kRegionSizeLog) >> 12), - 1 << 12, AddressSpaceView>; + static_assert(TwoLevelByteMapSize1 > 128, "TwoLevelByteMap should be used"); + using BM = TwoLevelByteMap; #endif static_assert((Params::kFlags & SizeClassAllocator32FlagMasks::kForTest) || is_same::value,