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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@328180 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-03-22 04:42:56 +00:00
parent 256f187bc6
commit a831287399
9 changed files with 343 additions and 87 deletions

View File

@@ -157,6 +157,11 @@
#define TEST_NORETURN [[noreturn]]
#endif
#if !defined(__cpp_aligned_new) || __cpp_aligned_new < 201606L || \
defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
#define TEST_HAS_NO_ALIGNED_ALLOCATION
#endif
#if defined(_LIBCPP_SAFE_STATIC)
#define TEST_SAFE_STATIC _LIBCPP_SAFE_STATIC
#else
@@ -228,6 +233,7 @@ inline void DoNotOptimize(Tp const& value) {
}
#endif
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif