[libcxx-commits] [libcxx] e2d07fc - [libc++] Mark libc++ deallocation helpers as noexcept (#110884)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 17 13:16:18 PDT 2024
Author: Louis Dionne
Date: 2024-10-17T16:16:15-04:00
New Revision: e2d07fc3d8737c08d351e841f82911a5c3ddf433
URL: https://github.com/llvm/llvm-project/commit/e2d07fc3d8737c08d351e841f82911a5c3ddf433
DIFF: https://github.com/llvm/llvm-project/commit/e2d07fc3d8737c08d351e841f82911a5c3ddf433.diff
LOG: [libc++] Mark libc++ deallocation helpers as noexcept (#110884)
They already can't throw exceptions and they are called from noexcept
functions, but they were not marked as noexcept. Depending on compiler
inlining, this might not make a difference or this might improve the
codegen a bit by removing the implicit try-catch block that Clang
generates around non-noexcept functions called from noexcept functions.
The original issue also mentioned that one occurrence of
std::allocator::deallocate was missing noexcept, however it has since
then been removed.
Fixes #66100
Added:
Modified:
libcxx/include/new
Removed:
################################################################################
diff --git a/libcxx/include/new b/libcxx/include/new
index 2947ee179510a5..75e2b8742df6bd 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -281,7 +281,7 @@ _LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
}
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) {
+_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
__builtin_operator_delete(__args...);
#else
@@ -302,7 +302,7 @@ inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __ali
}
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) {
+_LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) _NOEXCEPT {
#if !_LIBCPP_HAS_SIZED_DEALLOCATION
(void)__size;
return std::__libcpp_operator_delete(__ptr, __args...);
@@ -311,7 +311,7 @@ _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __siz
#endif
}
-inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) {
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) _NOEXCEPT {
#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
(void)__align;
return __do_deallocate_handle_size(__ptr, __size);
@@ -325,7 +325,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size
#endif
}
-inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) {
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) _NOEXCEPT {
#if !_LIBCPP_HAS_ALIGNED_ALLOCATION
(void)__align;
return __libcpp_operator_delete(__ptr);
More information about the libcxx-commits
mailing list