diff options
author | itrofimow <i.trofimow@yandex.ru> | 2024-01-22 19:12:41 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 10:12:41 -0500 |
commit | 51e91b64d0deb6a743861c2a0fba84865250036e (patch) | |
tree | 1863c3766d4d40d4f4aad9528efdfbfbe0d867c6 /libcxx/benchmarks | |
parent | 6ba62f4f251763745d39194ecd33ebaf7a739059 (diff) | |
download | llvm-51e91b64d0deb6a743861c2a0fba84865250036e.zip llvm-51e91b64d0deb6a743861c2a0fba84865250036e.tar.gz llvm-51e91b64d0deb6a743861c2a0fba84865250036e.tar.bz2 |
[libc++abi] Implement __cxa_init_primary_exception and use it to optimize std::make_exception_ptr (#65534)
This patch implements __cxa_init_primary_exception, an extension to the
Itanium C++ ABI. This extension is already present in both libsupc++ and
libcxxrt. This patch also starts making use of this function in
std::make_exception_ptr: instead of going through a full throw/catch
cycle, we are now able to initialize an exception directly, thus making
std::make_exception_ptr around 30x faster.
Diffstat (limited to 'libcxx/benchmarks')
-rw-r--r-- | libcxx/benchmarks/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libcxx/benchmarks/exception_ptr.bench.cpp | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt index ce4f5fd..2434d82 100644 --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -202,6 +202,7 @@ set(BENCHMARK_TESTS allocation.bench.cpp deque.bench.cpp deque_iterator.bench.cpp + exception_ptr.bench.cpp filesystem.bench.cpp format_to_n.bench.cpp format_to.bench.cpp diff --git a/libcxx/benchmarks/exception_ptr.bench.cpp b/libcxx/benchmarks/exception_ptr.bench.cpp new file mode 100644 index 0000000..1292ad7 --- /dev/null +++ b/libcxx/benchmarks/exception_ptr.bench.cpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <benchmark/benchmark.h> +#include <exception> + +void bm_make_exception_ptr(benchmark::State& state) { + for (auto _ : state) { + benchmark::DoNotOptimize(std::make_exception_ptr(42)); + } +} +BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8); + +BENCHMARK_MAIN(); |