[PATCH] D34782: [scudo] Change aligned alloc functions to be more compliant & perf changes

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 28 14:37:45 PDT 2017


cryptoad created this revision.

We were not following the `man` documented behaviors for invalid arguments to
`memalign` and associated functions. Using `CHECK` for those was a bit extreme,
so we relax the behavior to return null pointers as expected when this happens.
Adapt the associated test.

I am using this change also to change a few more minor performance improvements:

- mark as `UNLIKELY` a bunch of unlikely conditions;
- the current `CHECK` in `__sanitizer::RoundUpTo` is redundant for us in *all* calls. So I am introducing our own version without said `CHECK`.
- change our combined allocator `GetActuallyAllocatedSize`. We already know if the pointer is from the Primary or Secondary, so the `PointerIsMine` check is redundant as well, and costly for the 32-bit Primary. So we get the size by directly using the available Primary functions.

Finally, change a `int` to `uptr` to avoid a warning/error when compiling on
Android.


https://reviews.llvm.org/D34782

Files:
  lib/scudo/scudo_allocator.cpp
  lib/scudo/scudo_allocator.h
  lib/scudo/scudo_allocator_combined.h
  lib/scudo/scudo_tls_android.cpp
  test/scudo/memalign.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34782.104515.patch
Type: text/x-patch
Size: 7717 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/dcb72d21/attachment.bin>


More information about the llvm-commits mailing list