[PATCH] D61200: [sanitizer] NFC: add static_assert to confirm that we use optimal ByteMap type
Vitaly Buka via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 26 10:21:34 PDT 2019
vitalybuka created this revision.
vitalybuka added a reviewer: eugenis.
Herald added subscribers: llvm-commits, Sanitizers, kubamracek.
Herald added projects: Sanitizers, LLVM.
If bots work we can replace #ifs with template specialization by TwoLevelByteMapSize1.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D61200
Files:
compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
Index: compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
+++ compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h
@@ -47,6 +47,10 @@
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 @@
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61200.196877.patch
Type: text/x-patch
Size: 1380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190426/eff18b1f/attachment.bin>
More information about the llvm-commits
mailing list