HomePhabricator

Fix PR22634 - std::allocator doesn't respect over-aligned types.

Description

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.

Details

Committed
EricWFMar 21 2018, 9:42 PM
Parents
rL328179: [X86][Skylake] Merge multiple InstrRW entries that map to the same…
Branches
Unknown
Tags
Unknown

Event Timeline

rnk added subscribers: pcc, rnk.Apr 19 2018, 11:35 AM
/libcxx/trunk/include/new
246

This is causing problems for us because the 14.11.25503 MSVCRT headers do not define align_val_t, and now libc++ uses it unconditionally. You can see it here:
https://ci.chromium.org/buildbot/chromium.clang/ToTWinLibcxx64/638

FAILED: obj/buildtools/third_party/libc++/libc++/new.obj 
...
In file included from ../../buildtools/third_party/libc++/trunk/src/new.cpp:14:
../../buildtools/third_party/libc++/trunk/include\new(246,11):  error: unknown type name 'align_val_t'
    const align_val_t __align_val = static_cast<align_val_t>(__align);
          ^

I think we will need to define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION in __config when _MSC_VER is lower than 14.12.