This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Small tweaks and fixes to allocator related functions
ClosedPublic

Authored by cryptoad on Jun 29 2017, 3:28 PM.

Details

Summary

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.

Event Timeline

cryptoad created this revision.Jun 29 2017, 3:28 PM
alekseyshl accepted this revision.Jun 30 2017, 7:56 AM
This revision is now accepted and ready to land.Jun 30 2017, 7:56 AM
cryptoad closed this revision.Jun 30 2017, 9:05 AM