[libc++] Improve binary size when using __transaction
authorNikolas Klauser <nikolasklauser@berlin.de>
Thu, 8 Dec 2022 08:40:54 +0000 (09:40 +0100)
committerNikolas Klauser <nikolasklauser@berlin.de>
Mon, 23 Jan 2023 03:57:32 +0000 (04:57 +0100)
commit7458908f12da37e90262bdfaf753d15fb07006e7
treee72f84b29015fea589e4d171cfc30885e5eb6d39
parent88eae6ef9fb527bfd979c1672e2ed07f77136fbd
[libc++] Improve binary size when using __transaction

__exception_guard is a no-op in -fno-exceptions mode to produce better code-gen. This means that we don't provide the strong exception guarantees. However, Clang doesn't generate cleanup code with exceptions disabled, so even if we wanted to provide the strong exception guarantees we couldn't. This is also only relevant for constructs with a stack of -fexceptions > -fno-exceptions > -fexceptions code, since the exception can't be caught where exceptions are disabled. While -fexceptions > -fno-exceptions is quite common (e.g. libc++.dylib > -fno-exceptions), having another layer with exceptions enabled seems a lot less common, especially one that tries to catch an exception through -fno-exceptions code.

Fixes https://github.com/llvm/llvm-project/issues/56783

Reviewed By: ldionne, Mordante, huixie90, #libc

Spies: EricWF, alexfh, hans, joanahalili, libcxx-commits

Differential Revision: https://reviews.llvm.org/D133661
13 files changed:
libcxx/include/CMakeLists.txt
libcxx/include/__expected/expected.h
libcxx/include/__memory/uninitialized_algorithms.h
libcxx/include/__memory_resource/polymorphic_allocator.h
libcxx/include/__utility/exception_guard.h [new file with mode: 0644]
libcxx/include/__utility/transaction.h [deleted file]
libcxx/include/module.modulemap.in
libcxx/include/utility
libcxx/include/vector
libcxx/test/libcxx/private_headers.verify.cpp
libcxx/test/libcxx/utilities/assert.exception_guard.no_exceptions.pass.cpp [new file with mode: 0644]
libcxx/test/libcxx/utilities/exception_guard.no_exceptions.pass.cpp [new file with mode: 0644]
libcxx/test/libcxx/utilities/exception_guard.pass.cpp [moved from libcxx/test/libcxx/utilities/transaction.pass.cpp with 81% similarity]