llvm-project/libcxx/include
Eric Fiselier 7e6448bb02 Implement sized deallocation for std::allocator and friends.
Summary:
C++14 sized deallocation is disabled by default due to ABI concerns. However, when a user manually enables it then libc++ should take advantage of it since sized deallocation can provide a significant performance win depending on the underlying malloc implementation. (Note that libc++'s definitions of sized delete don't do anything special yet, but users are free to provide their own).

This patch updates __libcpp_deallocate to selectively call sized operator delete when it's available. `__libcpp_deallocate_unsized` should be used when the size of the allocation is unknown.

On Apple this patch makes no attempt to determine if the sized operator delete is unavailable, only that the language feature is enabled. This could cause a compile error when using `std::allocator`, but the same compile error would occur whenever the user calls `new`, so I don't think it's a problem.

Reviewers: ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: rsmith, ckennelly, libcxx-commits, christof

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

llvm-svn: 345214
2018-10-24 22:44:01 +00:00
..
experimental Re-apply "[libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to." 2018-07-30 22:27:38 +00:00
ext Remove usages of _LIBCPP_MSVC which is never defined 2017-05-10 21:40:58 +00:00
support Fix Shadowing warning on Windows 2018-10-01 02:54:08 +00:00
CMakeLists.txt Recommit r339943 - Establish the <bit> header. NFC yet. Reviewed as https://reviews.llvm.org/D50815 - with a fix for the sanitizer bots 2018-08-17 16:07:48 +00:00
__bit_reference Refactor the newly created <bit> header. Still (almost) NFC. Reviewed as https://reviews.llvm.org/D50876 2018-08-17 17:27:25 +00:00
__bsd_locale_defaults.h Add system header pragma to BSD locale fallback headers. 2017-08-03 02:50:43 +00:00
__bsd_locale_fallbacks.h [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
__config [libcxx] Avoid repeating the definition of std:: namespaces 2018-10-16 20:02:59 +00:00
__config_site.in [libcxx] By default, do not use internal_linkage to hide symbols from the ABI 2018-08-16 12:44:28 +00:00
__debug [libc++] Introduce _LIBCPP_EXTERN_VIS to fix __libcpp_debug_function link errors 2017-01-16 21:01:00 +00:00
__errc [libc++] Lift std::errc into a separated header 2018-07-03 03:25:10 +00:00
__functional_03 [libcxx] func.wrap.func.con: Unset function before destroying anything 2018-04-25 23:38:41 +00:00
__functional_base [libc++] Add deprecated attributes to many deprecated components 2018-09-23 18:35:00 +00:00
__functional_base_03
__hash_table First half of C++17's splicing maps and sets 2018-08-01 01:33:38 +00:00
__libcpp_version Update version to 8.0.0svn: cmake, includes files and docs 2018-08-01 13:54:28 +00:00
__locale [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
__mutex_base [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY 2018-08-01 02:08:59 +00:00
__node_handle Comment out #define __cpp_lib_node_extract, we only support half of that functionality 2018-08-23 17:08:02 +00:00
__nullptr [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
__split_buffer [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows 2017-05-31 22:07:49 +00:00
__sso_allocator Implement sized deallocation for std::allocator and friends. 2018-10-24 22:44:01 +00:00
__std_stream [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows 2017-05-31 22:07:49 +00:00
__string Fix misleading indentation; replace a couple of NULLs with nullptr. Resolves https://reviews.llvm.org/D42945 ; thanks to Bruce Mitchener for the patch. 2018-02-06 18:58:05 +00:00
__threading_support Fix typo 2018-09-17 07:40:42 +00:00
__tree [NFC][libc++] Consistently use spaces to indent 2018-08-03 22:36:53 +00:00
__tuple Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in tuple and utility 2017-04-19 01:23:39 +00:00
__undef_macros [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows 2017-05-31 22:07:49 +00:00
algorithm Do the math in uniform_int_distribution::operator() as unsigned to prevent UB when overflowing. Also add a UBSAN notification that we're ffine with unsigned overflow. This fixes PR#32617. Thanks to Vincent & Christoph for their help with this issue. 2018-10-08 20:20:34 +00:00
any Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
array Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
atomic Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
bit Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
bitset [NFC][libc++] Consistently use spaces to indent 2018-08-03 22:36:53 +00:00
cassert
ccomplex
cctype
cerrno
cfenv
cfloat Test for the presence of a bunch of new macros for c++17. These macros come from C11. Part of P0063 2018-07-31 23:29:06 +00:00
charconv [libc++][C++17] Elementary string conversions for integral types 2018-08-01 02:38:30 +00:00
chrono Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang. Reviewed as D51762 2018-10-16 17:27:54 +00:00
cinttypes
ciso646
climits
clocale
cmath Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
codecvt [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
compare [libc++] Declare <compare> operators with the proper visibility attribute 2018-07-10 13:21:03 +00:00
complex Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
complex.h
condition_variable [libc++] Make _LIBCPP_TYPE_VIS export members 2017-03-02 03:22:18 +00:00
csetjmp
csignal
cstdarg
cstdbool
cstddef Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
cstdint
cstdio [libc++] Drop support for CRTs older than VS 2015 2017-04-07 02:20:52 +00:00
cstdlib Selectively import timespec_get into namespace std, since some C libraries don't have it. Reviewed as https://reviews.llvm.org/D50799 2018-08-15 21:19:08 +00:00
cstring
ctgmath
ctime Selectively import timespec_get into namespace std, since some C libraries don't have it. Reviewed as https://reviews.llvm.org/D50799 2018-08-15 21:19:08 +00:00
ctype.h [libc++] Refactor Windows support headers. 2017-05-10 20:57:45 +00:00
cwchar [libc++] Remove unnecessary MSVCRT exclusions 2016-11-08 03:31:42 +00:00
cwctype
deque Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
errno.h
exception Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
filesystem Fix even more Clang warnings. 2018-10-01 01:59:37 +00:00
float.h Test for the presence of a bunch of new macros for c++17. These macros come from C11. Part of P0063 2018-07-31 23:29:06 +00:00
forward_list Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
fstream Implement <filesystem> 2018-07-27 03:07:09 +00:00
functional [libc++] Add deprecated attributes to many deprecated components 2018-09-23 18:35:00 +00:00
future [libc++] Remove race condition in std::async 2018-08-24 14:00:59 +00:00
initializer_list [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
inttypes.h [include] Declare __STDC_*_MACROS for C++11 compat in old libc 2016-09-26 20:20:00 +00:00
iomanip Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
ios [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
iosfwd [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS 2017-01-04 23:56:00 +00:00
iostream
istream [libcxx] Remove _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 2018-10-16 19:26:23 +00:00
iterator Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
limits Fix more unreserved names 2017-06-01 02:29:37 +00:00
limits.h [libcxx] Fix gcc build. 2016-10-10 15:56:01 +00:00
list Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
locale [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
locale.h [libcxx] Implement locale.h to fix modules build 2016-11-19 01:14:15 +00:00
map Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
math.h [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY 2018-07-11 23:14:33 +00:00
memory Implement sized deallocation for std::allocator and friends. 2018-10-24 22:44:01 +00:00
module.modulemap Recommit r339943 - Establish the <bit> header. NFC yet. Reviewed as https://reviews.llvm.org/D50815 - with a fix for the sanitizer bots 2018-08-17 16:07:48 +00:00
mutex Annotate scoped_lock as with scoped_lockable attribute 2018-10-09 23:42:29 +00:00
new Implement sized deallocation for std::allocator and friends. 2018-10-24 22:44:01 +00:00
numeric Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
optional Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
ostream [libcxx] Remove _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 2018-10-16 19:26:23 +00:00
queue Deduction guides for the container adaptors - queue, stack, and priority_queue 2018-05-22 01:57:53 +00:00
random [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback 2018-08-16 23:56:54 +00:00
ratio Implement most of P0607: Inline Variables for the Standard Library. This involved marking a lot of variables as inline (but only for C++17 and later). 2018-01-02 17:17:01 +00:00
regex Fix even more Clang warnings. 2018-10-01 01:59:37 +00:00
scoped_allocator Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
set Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
setjmp.h
shared_mutex Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
span [libc++][NFC] Add error messages to a couple of static_asserts in span 2018-10-03 21:36:16 +00:00
sstream [NFC][libc++] Consistently use spaces to indent 2018-08-03 22:36:53 +00:00
stack Deduction guides for the container adaptors - queue, stack, and priority_queue 2018-05-22 01:57:53 +00:00
stdbool.h
stddef.h Teach libc++ to use native NetBSD's max_align_t 2018-08-20 22:29:20 +00:00
stdexcept [NFC][libc++] Consistently use spaces to indent 2018-08-03 22:36:53 +00:00
stdint.h [include] Declare __STDC_*_MACROS for C++11 compat in old libc 2016-09-26 20:20:00 +00:00
stdio.h libcxx: Rename vasprintf function to __libcpp_vasprintf. 2018-01-23 18:53:33 +00:00
stdlib.h [libc++] Refactor Windows support headers. 2017-05-10 20:57:45 +00:00
streambuf [libcxx] Remove _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY 2018-10-16 19:26:23 +00:00
string Partial fix for PR38964. (<string> can't be built with gcc -std=c++03) Reviewed as https://reviews.llvm.org/D52240 2018-10-16 16:02:18 +00:00
string.h
string_view Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
strstream Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output library 2017-04-18 23:38:41 +00:00
system_error [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY 2018-08-01 02:08:59 +00:00
tgmath.h Implement LWG 2835 - fix <tgmath.h> 2018-02-12 19:13:24 +00:00
thread Implement LWG 3039 and 3041 - 'Treating Unnecessary decay'. 2018-03-20 22:37:37 +00:00
tuple Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
type_traits Revert "Teach __libcpp_is_floating_point that __fp16 and _Float16 are" 2018-10-24 21:29:15 +00:00
typeindex [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS 2017-01-04 23:56:00 +00:00
typeinfo [NFC][libc++] Consistently use spaces to indent 2018-08-03 22:36:53 +00:00
unordered_map Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
unordered_set Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 2018-09-12 19:41:40 +00:00
utility Fix even more Clang warnings. 2018-10-01 01:59:37 +00:00
valarray Implement sized deallocation for std::allocator and friends. 2018-10-24 22:44:01 +00:00
variant Don't require relops on variant alternatives to all return the same 2018-09-19 17:53:21 +00:00
vector Off-by-one errors strike again. Thank goodness for ASAN and the bots. 2018-10-23 20:07:45 +00:00
version Update commnents to reflect the changes for LWG#3127. NFC 2018-10-22 20:50:06 +00:00
wchar.h [libc++] Account for Microsoft CRT const overloads 2017-09-15 18:49:34 +00:00
wctype.h