[PATCH] D34840: [sanitizer] Small tweaks and fixes to allocator related functions

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 15:28:29 PDT 2017


cryptoad created this revision.
Herald added subscribers: kristof.beyls, kubamracek, aemerson.

In `sanitizer_allocator_primary32.h`:

- rounding up in `MapWithCallback` is not needed as `MmapOrDie` does it. Note that the 64-bit counterpart doesn't round up, this keeps the behavior consistent;
- since `IsAligned` exists, use it in `AllocateRegion`;
- in `PopulateFreeList`:
  - checking `b->Count` to be greater than 0 when `b->Count() == max_count` is redundant when done more than once. Just check that `max_count` is greater than 0 out of the loop; the compiler (at least on ARM) didn't optimize it;
  - mark the batch creation failure as `UNLIKELY`;

In `sanitizer_allocator_primary64.h`:

- in `MapWithCallback`, mark the failure condition as `UNLIKELY`;

In `sanitizer_posix.h`:

- mark a bunch of Mmap related failure conditions as `UNLIKELY`;
- in `MmapAlignedOrDieOnFatalError`, we have `IsAligned`, so use it; rearrange the conditions as one test was redudant;
- in `MmapFixedImpl`, 30 chars was not large enough to hold the message and a full 64-bit address (or at least a 48-bit usermode address), increase to 40.


https://reviews.llvm.org/D34840

Files:
  lib/sanitizer_common/sanitizer_allocator_primary32.h
  lib/sanitizer_common/sanitizer_allocator_primary64.h
  lib/sanitizer_common/sanitizer_posix.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34840.104751.patch
Type: text/x-patch
Size: 4806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170629/7e3c0fbf/attachment.bin>


More information about the llvm-commits mailing list