[all-commits] [llvm/llvm-project] a78aaa: [libc++] Factor out common logic for calling align...

Louis Dionne via All-commits all-commits at lists.llvm.org
Wed Nov 25 12:49:39 PST 2020


  Branch: refs/heads/temp-test-main
  Home:   https://github.com/llvm/llvm-project
  Commit: a78aaa1ad51214b2e04f41762e76bb43067ea1fd
      https://github.com/llvm/llvm-project/commit/a78aaa1ad51214b2e04f41762e76bb43067ea1fd
  Author: Louis Dionne <ldionne at apple.com>
  Date:   2020-11-25 (Wed, 25 Nov 2020)

  Changed paths:
    M libcxx/include/new
    M libcxx/src/new.cpp
    M libcxxabi/src/fallback_malloc.cpp
    M libcxxabi/src/stdlib_new_delete.cpp

  Log Message:
  -----------
  [libc++] Factor out common logic for calling aligned allocation

There were a couple of places where we needed to call the underlying
platform's aligned allocation/deallocation function. Instead of having
the same logic all over the place, extract the logic into a pair of
helper functions __libcpp_aligned_alloc and __libcpp_aligned_free.

The code in libcxxabi/src/fallback_malloc.cpp looks like it could be
simplified after this change -- I purposefully did not simplify it
further to keep this change as straightforward as possible, since it
is touching very important parts of the library.

Also, the changes in libcxx/src/new.cpp and libcxxabi/src/stdlib_new_delete.cpp
are basically the same -- I just kept both source files in sync.

The underlying reason for this refactoring is to make it easier to support
platforms that provide aligned allocation through C11's aligned_alloc
function instead of posix_memalign. After this change, we'll only have
to add support for that in a single place.

Differential Revision: https://reviews.llvm.org/D91379




More information about the All-commits mailing list