[compiler-rt] r359333 - [sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 11:22:47 PDT 2019
Author: vitalybuka
Date: Fri Apr 26 11:22:47 2019
New Revision: 359333
URL: http://llvm.org/viewvc/llvm-project?rev=359333&view=rev
Log:
[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
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h?rev=359333&r1=359332&r2=359333&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_allocator_primary32.h Fri Apr 26 11:22:47 2019
@@ -47,6 +47,10 @@ struct SizeClassAllocator32FlagMasks {
template <class Params>
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<TwoLevelByteMapSize1, 1 << 12, AddressSpaceView>;
#endif
static_assert((Params::kFlags & SizeClassAllocator32FlagMasks::kForTest) ||
is_same<BM, ByteMap>::value,
More information about the llvm-commits
mailing list