Fix PR22634 - std::allocator doesn't respect over-aligned types.
authorEric Fiselier <eric@efcs.ca>
Thu, 22 Mar 2018 04:42:56 +0000 (04:42 +0000)
committerEric Fiselier <eric@efcs.ca>
Thu, 22 Mar 2018 04:42:56 +0000 (04:42 +0000)
commitf2918d1c24c9e69f1c63a4ca864bbd68ef5a51cc
treea3e112d71ad60d20340cfbf634b0da3a882d6ff7
parentfc179c6dd59b0da8068ecb800095e79d2ec41bc6
Fix PR22634 - std::allocator doesn't respect over-aligned types.

This patch fixes std::allocator, and more specifically, all users
of __libcpp_allocate and __libcpp_deallocate, to support over-aligned
types.

__libcpp_allocate/deallocate now take an alignment parameter, and when
the specified alignment is greater than that supported by malloc/new,
the aligned version of operator new is called (assuming it's available).

When aligned new isn't available, the old behavior has been kept, and the
alignment parameter is ignored.

This patch depends on recent changes to __builtin_operator_new/delete which
allow them to be used to call any regular new/delete operator. By using
__builtin_operator_new/delete when possible, the new/delete erasure optimization
is maintained.

llvm-svn: 328180
libcxx/include/__config
libcxx/include/__sso_allocator
libcxx/include/memory
libcxx/include/new
libcxx/include/valarray
libcxx/src/experimental/memory_resource.cpp
libcxx/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
libcxx/test/support/count_new.hpp
libcxx/test/support/test_macros.h