[libcxx-commits] [libcxx] 8bb5e21 - [libc++] Align and avoid inlining benchmark functions (#213938)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 12 14:12:31 PDT 2026
Author: Nikolas Klauser
Date: 2026-08-12T17:12:25-04:00
New Revision: 8bb5e216937e6b541f351aa1637c67e85a43ada0
URL: https://github.com/llvm/llvm-project/commit/8bb5e216937e6b541f351aa1637c67e85a43ada0
DIFF: https://github.com/llvm/llvm-project/commit/8bb5e216937e6b541f351aa1637c67e85a43ada0.diff
LOG: [libc++] Align and avoid inlining benchmark functions (#213938)
We're currently having the problem that clearly unrelated benchmarks
sometimes change performance in significant ways. This is an attempt to
mitigate that issue by aligning the functions and thus making it less
likely that unrelated changes cause changes in cache behaviour.
Co-authored-by: Louis Dionne <ldionne.2 at gmail.com>
Added:
Modified:
libcxx/test/benchmarks/CartesianBenchmarks.h
libcxx/test/benchmarks/adjacent_view_begin.bench.cpp
libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp
libcxx/test/benchmarks/algorithms/lexicographical_compare_three_way.bench.cpp
libcxx/test/benchmarks/algorithms/min_max_element.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/copy.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/copy_backward.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/copy_if.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/copy_n.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/fill.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/fill_n.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/generate.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/generate_n.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/move.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/move_backward.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/remove_copy.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/replace_copy.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/reverse.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/reverse_copy.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/rotate.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/rotate_copy.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/sample.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/shift_left.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/shift_right.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/shuffle.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/swap_ranges.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/contains.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/contains_subrange.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/find.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/for_each.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/for_each_n.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
libcxx/test/benchmarks/algorithms/partitions/is_partitioned.bench.cpp
libcxx/test/benchmarks/algorithms/partitions/partition.bench.cpp
libcxx/test/benchmarks/algorithms/partitions/partition_copy.bench.cpp
libcxx/test/benchmarks/algorithms/partitions/partition_point.bench.cpp
libcxx/test/benchmarks/algorithms/partitions/stable_partition.bench.cpp
libcxx/test/benchmarks/algorithms/ranges_min_max.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/binary_search.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/equal_range.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/is_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/lower_upper_bound.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/make_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/make_heap_then_sort_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/nth_element.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/partial_sort.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/partial_sort_copy.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/permutation.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/push_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/set_intersection.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/sort.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/sort_heap.bench.cpp
libcxx/test/benchmarks/algorithms/sorting/stable_sort.bench.cpp
libcxx/test/benchmarks/atomic_wait_1_waiter_1_notifier.bench.cpp
libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp
libcxx/test/benchmarks/atomic_wait_multi_waiter_1_notifier.bench.cpp
libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
libcxx/test/benchmarks/bitset.bench.cpp
libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
libcxx/test/benchmarks/containers/associative/map.bench.cpp
libcxx/test/benchmarks/containers/associative/unordered_map.bench.cpp
libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
libcxx/test/benchmarks/containers/sequence/vector_bool.bench.cpp
libcxx/test/benchmarks/containers/string.bench.cpp
libcxx/test/benchmarks/exception_ptr.bench.cpp
libcxx/test/benchmarks/filesystem.bench.cpp
libcxx/test/benchmarks/format/format.bench.cpp
libcxx/test/benchmarks/format/format_to.bench.cpp
libcxx/test/benchmarks/format/format_to_n.bench.cpp
libcxx/test/benchmarks/format/formatted_size.bench.cpp
libcxx/test/benchmarks/format/formatter_float.bench.cpp
libcxx/test/benchmarks/format/formatter_int.bench.cpp
libcxx/test/benchmarks/format/print.bench.cpp
libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp
libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp
libcxx/test/benchmarks/format/write_double_comparison.bench.cpp
libcxx/test/benchmarks/format/write_int_comparison.bench.cpp
libcxx/test/benchmarks/format/write_string_comparison.bench.cpp
libcxx/test/benchmarks/hash.bench.cpp
libcxx/test/benchmarks/iterators/distance.bench.cpp
libcxx/test/benchmarks/join_view.bench.cpp
libcxx/test/benchmarks/libcxxabi/dynamic_cast.bench.cpp
libcxx/test/benchmarks/libcxxabi/dynamic_cast_old_stress.bench.cpp
libcxx/test/benchmarks/memory/align.bench.cpp
libcxx/test/benchmarks/monotonic_buffer.bench.cpp
libcxx/test/benchmarks/numeric/gcd.bench.cpp
libcxx/test/benchmarks/random.bench.cpp
libcxx/test/benchmarks/shared_mutex_vs_mutex.bench.cpp
libcxx/test/benchmarks/stop_token.bench.cpp
libcxx/test/benchmarks/streams/copy.bench.cpp
libcxx/test/benchmarks/streams/fstream.bench.cpp
libcxx/test/benchmarks/streams/getline.bench.cpp
libcxx/test/benchmarks/stringstream.bench.cpp
libcxx/test/benchmarks/system_error.bench.cpp
libcxx/test/benchmarks/text/localization/ctype.bench.cpp
libcxx/test/benchmarks/text/localization/locale.bench.cpp
libcxx/test/benchmarks/text/localization/num_get.bench.cpp
libcxx/test/benchmarks/text/localization/num_put.bench.cpp
libcxx/test/benchmarks/to_chars.bench.cpp
libcxx/test/benchmarks/utc_clock.bench.cpp
libcxx/test/benchmarks/util_smartptr.bench.cpp
libcxx/test/benchmarks/variant.bench.cpp
libcxx/test/support/test_macros.h
Removed:
################################################################################
diff --git a/libcxx/test/benchmarks/CartesianBenchmarks.h b/libcxx/test/benchmarks/CartesianBenchmarks.h
index c712230843ebf..a9b2046b7c974 100644
--- a/libcxx/test/benchmarks/CartesianBenchmarks.h
+++ b/libcxx/test/benchmarks/CartesianBenchmarks.h
@@ -40,7 +40,9 @@ void makeBenchmarkFromValuesImpl(const Args& A, std::index_sequence<Is...>) {
for (auto& V : A) {
B Bench{std::get<Is>(V)...};
if (!internal::skip(Bench, 0)) {
- benchmark::RegisterBenchmark(Bench.name().c_str(), [=](benchmark::State& S) { Bench.run(S); });
+ benchmark::RegisterBenchmark(Bench.name().c_str(), [=](benchmark::State& S) TEST_ALIGN_BENCHMARK {
+ Bench.run(S);
+ });
}
}
}
diff --git a/libcxx/test/benchmarks/adjacent_view_begin.bench.cpp b/libcxx/test/benchmarks/adjacent_view_begin.bench.cpp
index 33eea8434db55..6eb84406019f0 100644
--- a/libcxx/test/benchmarks/adjacent_view_begin.bench.cpp
+++ b/libcxx/test/benchmarks/adjacent_view_begin.bench.cpp
@@ -14,11 +14,12 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
namespace {
template <size_t N>
-void BM_adjacent_full(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_adjacent_full(benchmark::State& state) {
const std::vector<int> inputs(1000000, 42);
auto view = inputs | std::views::adjacent<N>;
for (auto _ : state) {
@@ -33,7 +34,7 @@ BENCHMARK(BM_adjacent_full<100>)->Name("rng::adjacent_view::begin()/100 (full vi
BENCHMARK(BM_adjacent_full<1000>)->Name("rng::adjacent_view::begin()/1000 (full view)");
template <size_t N>
-void BM_adjacent_empty(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_adjacent_empty(benchmark::State& state) {
const std::vector<int> inputs;
auto view = inputs | std::views::adjacent<N>;
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp b/libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp
index 3ff2534881a94..0ec60eea85045 100755
--- a/libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp
@@ -11,10 +11,11 @@
#include <algorithm>
#include <benchmark/benchmark.h>
#include <vector>
+#include "test_macros.h"
// Benchmarks the worst case: check the whole range just to find out that they compare equal
template <class T>
-static void bm_lexicographical_compare(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_lexicographical_compare(benchmark::State& state) {
std::vector<T> vec1(state.range(), '1');
std::vector<T> vec2(state.range(), '1');
@@ -29,7 +30,7 @@ BENCHMARK(bm_lexicographical_compare<signed char>)->Arg(1)->Range(8, 1 << 20);
BENCHMARK(bm_lexicographical_compare<int>)->Arg(1)->Range(8, 1 << 20);
template <class T>
-static void bm_ranges_lexicographical_compare(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_ranges_lexicographical_compare(benchmark::State& state) {
std::vector<T> vec1(state.range(), '1');
std::vector<T> vec2(state.range(), '1');
diff --git a/libcxx/test/benchmarks/algorithms/lexicographical_compare_three_way.bench.cpp b/libcxx/test/benchmarks/algorithms/lexicographical_compare_three_way.bench.cpp
index 05d73bdedd998..75105c4fc1fd1 100644
--- a/libcxx/test/benchmarks/algorithms/lexicographical_compare_three_way.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/lexicographical_compare_three_way.bench.cpp
@@ -12,9 +12,10 @@
#include "benchmark/benchmark.h"
#include "test_iterators.h"
+#include "test_macros.h"
template <class IteratorT>
-static void BM_lexicographical_compare_three_way(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_lexicographical_compare_three_way(benchmark::State& state) {
auto size = state.range(0);
std::vector<int> v1;
v1.resize(size);
diff --git a/libcxx/test/benchmarks/algorithms/min_max_element.bench.cpp b/libcxx/test/benchmarks/algorithms/min_max_element.bench.cpp
index d7de70cb75f15..6501d5c6e624c 100644
--- a/libcxx/test/benchmarks/algorithms/min_max_element.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/min_max_element.bench.cpp
@@ -20,7 +20,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::type_identity<Container>, std::string name, auto algo) {
benchmark::RegisterBenchmark(
name,
- [algo](benchmark::State& state) {
+ [algo](benchmark::State& state) TEST_ALIGN_BENCHMARK {
Container c(state.range(), 3);
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/algorithms/modifying/copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/copy.bench.cpp
index 33f0f185269c6..9d20a9629f1be 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/copy.bench.cpp
@@ -26,7 +26,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy(normal container)
{
auto bm = []<class InputContainer, class OutputContainer>(std::string name, auto copy) {
- benchmark::RegisterBenchmark(name, [copy](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
using ValueType = typename InputContainer::value_type;
InputContainer c;
@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy(vector<bool>)
{
auto bm = []<bool Aligned>(std::string name, auto copy) {
- benchmark::RegisterBenchmark(name, [copy](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
std::vector<bool> in(n, true);
std::vector<bool> out(Aligned ? n : n + 8);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/copy_backward.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/copy_backward.bench.cpp
index 235829d06f566..50bec485fb05f 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/copy_backward.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/copy_backward.bench.cpp
@@ -26,7 +26,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy_n(normal container)
{
auto bm = []<class InputContainer, class OutputContainer>(std::string name, auto copy_backward) {
- benchmark::RegisterBenchmark(name, [copy_backward](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_backward](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
using ValueType = typename InputContainer::value_type;
InputContainer c;
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy_n(vector<bool>)
{
auto bm = []<bool Aligned>(std::string name, auto copy_backward) {
- benchmark::RegisterBenchmark(name, [copy_backward](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_backward](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
std::vector<bool> in(n, true);
std::vector<bool> out(Aligned ? n : n + 8);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/copy_if.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/copy_if.bench.cpp
index a295c73b733df..706e74a0d5315 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/copy_if.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/copy_if.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
// optimizations that can be applied in this case.
{
auto bm = []<class Container>(std::string name, auto copy_if) {
- benchmark::RegisterBenchmark(name, [copy_if](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_if](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -58,7 +59,7 @@ int main(int argc, char** argv) {
// Copy the full range.
{
auto bm = []<class Container>(std::string name, auto copy_if) {
- benchmark::RegisterBenchmark(name, [copy_if](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_if](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/copy_n.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/copy_n.bench.cpp
index d30674cf2ff8c..2f38feb56966e 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/copy_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/copy_n.bench.cpp
@@ -26,7 +26,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy_n(normal container)
{
auto bm = []<class Container>(std::string name, auto copy_n) {
- benchmark::RegisterBenchmark(name, [copy_n](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -50,7 +50,7 @@ int main(int argc, char** argv) {
// {std,ranges}::copy_n(vector<bool>)
{
auto bm = []<bool Aligned>(std::string name, auto copy_n) {
- benchmark::RegisterBenchmark(name, [copy_n](auto& st) {
+ benchmark::RegisterBenchmark(name, [copy_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
std::vector<bool> in(n, true);
std::vector<bool> out(Aligned ? n : n + 8);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/fill.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/fill.bench.cpp
index 4789eee552ced..3a3de3cadc05c 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/fill.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/fill.bench.cpp
@@ -28,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto fill) {
benchmark::RegisterBenchmark(
name,
- [fill](auto& st) {
+ [fill](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
// {std,ranges}::fill(vector<bool>)
{
auto bm = [](std::string name, auto fill) {
- benchmark::RegisterBenchmark(name, [fill](auto& st) {
+ benchmark::RegisterBenchmark(name, [fill](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
bool x = true;
std::vector<bool> c(size, x);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/fill_n.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/fill_n.bench.cpp
index fc7895edddb98..f723ca3897265 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/fill_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/fill_n.bench.cpp
@@ -28,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto fill_n) {
benchmark::RegisterBenchmark(
name,
- [fill_n](auto& st) {
+ [fill_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
// {std,ranges}::fill_n(vector<bool>)
{
auto bm = [](std::string name, auto fill_n) {
- benchmark::RegisterBenchmark(name, [fill_n](auto& st) {
+ benchmark::RegisterBenchmark(name, [fill_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
bool x = true;
std::vector<bool> c(size, x);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/generate.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/generate.bench.cpp
index f5f1be24c39a5..95dc249ea76bf 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/generate.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/generate.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto generate) {
benchmark::RegisterBenchmark(
name,
- [generate](auto& st) {
+ [generate](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
Container c(size);
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/generate_n.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/generate_n.bench.cpp
index 196cd0dff2bed..a210641215d18 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/generate_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/generate_n.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto generate_n) {
benchmark::RegisterBenchmark(
name,
- [generate_n](auto& st) {
+ [generate_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
Container c(size);
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/move.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/move.bench.cpp
index e854dfbe12de3..a2a8197f68635 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/move.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/move.bench.cpp
@@ -27,7 +27,7 @@ int main(int argc, char** argv) {
// {std,ranges}::move(normal container)
{
auto bm = []<class InputContainer, class OutputContainer>(std::string name, auto move) {
- benchmark::RegisterBenchmark(name, [move](auto& st) {
+ benchmark::RegisterBenchmark(name, [move](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename InputContainer::value_type;
InputContainer in;
@@ -54,7 +54,7 @@ int main(int argc, char** argv) {
// {std,ranges}::move(vector<bool>)
{
auto bm = []<bool Aligned>(std::string name, auto move) {
- benchmark::RegisterBenchmark(name, [move](auto& st) {
+ benchmark::RegisterBenchmark(name, [move](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<bool> c1(size, true);
std::vector<bool> c2(size, false);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/move_backward.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/move_backward.bench.cpp
index 763ba2c976260..9d4353a6322aa 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/move_backward.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/move_backward.bench.cpp
@@ -27,7 +27,7 @@ int main(int argc, char** argv) {
// {std,ranges}::move_backward(normal container)
{
auto bm = []<class InputContainer, class OutputContainer>(std::string name, auto move_backward) {
- benchmark::RegisterBenchmark(name, [move_backward](auto& st) {
+ benchmark::RegisterBenchmark(name, [move_backward](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename InputContainer::value_type;
InputContainer in;
@@ -56,7 +56,7 @@ int main(int argc, char** argv) {
// {std,ranges}::move_backward(vector<bool>)
{
auto bm = []<bool Aligned>(std::string name, auto move_backward) {
- benchmark::RegisterBenchmark(name, [move_backward](auto& st) {
+ benchmark::RegisterBenchmark(name, [move_backward](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<bool> c1(size, true);
std::vector<bool> c2(size, false);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
index e125b73d8cd61..501b7279f5281 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto remove) {
benchmark::RegisterBenchmark(
name,
- [remove](auto& st) {
+ [remove](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 10;
using ValueType = typename Container::value_type;
@@ -90,7 +91,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto remove) {
benchmark::RegisterBenchmark(
name,
- [remove](auto& st) {
+ [remove](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 10;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/remove_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/remove_copy.bench.cpp
index 4afc657822ccf..0de0dc1ab36ac 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/remove_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/remove_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -36,7 +37,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto remove_copy) {
benchmark::RegisterBenchmark(
name,
- [remove_copy](auto& st) {
+ [remove_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -77,7 +78,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto remove_copy) {
benchmark::RegisterBenchmark(
name,
- [remove_copy](auto& st) {
+ [remove_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
index 287bc40089e35..13f400492ed0c 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -35,7 +36,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto replace) {
benchmark::RegisterBenchmark(
name,
- [replace](auto& st) {
+ [replace](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -75,7 +76,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto replace) {
benchmark::RegisterBenchmark(
name,
- [replace](auto& st) {
+ [replace](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/replace_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/replace_copy.bench.cpp
index 0cad92d3b5ef3..9237143e43637 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/replace_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/replace_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto replace_copy) {
benchmark::RegisterBenchmark(
name,
- [replace_copy](auto& st) {
+ [replace_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -76,7 +77,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto replace_copy) {
benchmark::RegisterBenchmark(
name,
- [replace_copy](auto& st) {
+ [replace_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/reverse.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/reverse.bench.cpp
index 70790c01b6fda..4118c7c273a04 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/reverse.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/reverse.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -25,7 +26,7 @@ int main(int argc, char** argv) {
// {std,ranges}::reverse(normal container)
{
auto bm = []<class Container>(std::string name, auto reverse) {
- benchmark::RegisterBenchmark(name, [reverse](auto& st) {
+ benchmark::RegisterBenchmark(name, [reverse](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/reverse_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/reverse_copy.bench.cpp
index ce9d339204f3d..c8ce83e93f8bb 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/reverse_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/reverse_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -25,7 +26,7 @@ int main(int argc, char** argv) {
// {std,ranges}::reverse_copy(normal container)
{
auto bm = []<class Container>(std::string name, auto reverse_copy) {
- benchmark::RegisterBenchmark(name, [reverse_copy](auto& st) {
+ benchmark::RegisterBenchmark(name, [reverse_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/rotate.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/rotate.bench.cpp
index 5ffcc07bc3f8e..704b6a65ec2ec 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/rotate.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/rotate.bench.cpp
@@ -29,7 +29,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto rotate, double fraction) {
benchmark::RegisterBenchmark(
name,
- [=](auto& st) {
+ [=](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -69,7 +69,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto rotate) {
benchmark::RegisterBenchmark(
name,
- [rotate](auto& st) {
+ [rotate](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -99,7 +99,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto rotate) {
benchmark::RegisterBenchmark(
name,
- [rotate](auto& st) {
+ [rotate](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/rotate_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/rotate_copy.bench.cpp
index 2801a1d92a2fc..b2d28b5e5235d 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/rotate_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/rotate_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -29,7 +30,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto rotate_copy) {
benchmark::RegisterBenchmark(
name,
- [rotate_copy](auto& st) {
+ [rotate_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/sample.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/sample.bench.cpp
index c8ddefdd1be7a..2cbc631c9c606 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/sample.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/sample.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto sample) {
benchmark::RegisterBenchmark(
name,
- [sample](auto& st) {
+ [sample](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/shift_left.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/shift_left.bench.cpp
index b26526484c66a..6dc0137ce2925 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/shift_left.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/shift_left.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -28,7 +29,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto shift_left) {
benchmark::RegisterBenchmark(
name,
- [shift_left](auto& st) {
+ [shift_left](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/shift_right.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/shift_right.bench.cpp
index 42946760fc8a3..d4649fbcc2a96 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/shift_right.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/shift_right.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -28,7 +29,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto shift_right) {
benchmark::RegisterBenchmark(
name,
- [shift_right](auto& st) {
+ [shift_right](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/shuffle.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/shuffle.bench.cpp
index 6e3b8b1a36e86..a0eadb830bba2 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/shuffle.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/shuffle.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto shuffle) {
benchmark::RegisterBenchmark(
name,
- [shuffle](auto& st) {
+ [shuffle](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/swap_ranges.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/swap_ranges.bench.cpp
index 445c22e05b993..179da83e3947d 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/swap_ranges.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/swap_ranges.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto swap_ranges) {
benchmark::RegisterBenchmark(
name,
- [swap_ranges](auto& st) {
+ [swap_ranges](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c1, c2;
@@ -58,7 +59,7 @@ int main(int argc, char** argv) {
auto bm = []<bool Aligned>(std::string name, auto swap_ranges) {
benchmark::RegisterBenchmark(
name,
- [swap_ranges](auto& st) {
+ [swap_ranges](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<bool> c1(size, true);
std::vector<bool> c2(Aligned ? size : size + 4, false);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
index 09118cd3bcdf3..ac4d439daf09b 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -29,7 +30,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto transform) {
benchmark::RegisterBenchmark(
name,
- [transform](auto& st) {
+ [transform](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c1, c2;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
index 44c7a47db3965..97a2ff0828ddc 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto transform) {
benchmark::RegisterBenchmark(
name,
- [transform](auto& st) {
+ [transform](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
index 5529afc9d5b97..5c27fd6039fe5 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto unique) {
benchmark::RegisterBenchmark(
name,
- [unique](auto& st) {
+ [unique](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 10;
using ValueType = typename Container::value_type;
@@ -89,7 +90,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto unique) {
benchmark::RegisterBenchmark(
name,
- [unique](auto& st) {
+ [unique](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 10;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
index baca916a51aa0..f97a778848a3f 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -31,7 +32,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto unique_copy) {
benchmark::RegisterBenchmark(
name,
- [unique_copy](auto& st) {
+ [unique_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c(size);
@@ -71,7 +72,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto unique_copy) {
benchmark::RegisterBenchmark(
name,
- [unique_copy](auto& st) {
+ [unique_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c(size);
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
index e67b5cd31a1a6..5f9855f77eaf6 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_adjacent_find = [](auto first, auto last) { return std::adjacent_find(first, last); };
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto adjacent_find) {
benchmark::RegisterBenchmark(
name,
- [adjacent_find](auto& st) {
+ [adjacent_find](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
index cf2eb996ddffc..0663f8f2e38a1 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_any_of = [](auto first, auto last, auto pred) { return std::any_of(first, last, pred); };
@@ -36,7 +37,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto any_of) {
benchmark::RegisterBenchmark(
name,
- [any_of](auto& st) {
+ [any_of](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/contains.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/contains.bench.cpp
index 1bb9400113ef9..908c9a839c0dc 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/contains.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/contains.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark ranges::contains where we process the whole sequence, which is the
@@ -25,7 +26,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/contains_subrange.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/contains_subrange.bench.cpp
index cce2e42142ab0..9eaed74cb0355 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/contains_subrange.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/contains_subrange.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark ranges::contains_subrange where we never find the needle, which is the
@@ -26,7 +27,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -59,7 +60,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -99,7 +100,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -129,7 +130,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
index edffcbb58780c..0c87d7177a083 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_count = [](auto first, auto last, auto const& value) { return std::count(first, last, value); };
@@ -29,7 +30,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto count) {
benchmark::RegisterBenchmark(
name,
- [count](auto& st) {
+ [count](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -68,7 +69,7 @@ int main(int argc, char** argv) {
auto bm = [](std::string name, auto count) {
benchmark::RegisterBenchmark(
name,
- [count](auto& st) {
+ [count](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<bool> c(size, false);
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
index f2b51a73f428e..75376b83c8886 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
@@ -19,6 +19,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto ranges_ends_with_pred = [](auto first1, auto last1, auto first2, auto last2) {
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto ends_with) {
benchmark::RegisterBenchmark(
name,
- [ends_with](auto& st) {
+ [ends_with](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -71,7 +72,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto ends_with) {
benchmark::RegisterBenchmark(
name,
- [ends_with](auto& st) {
+ [ends_with](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
index 4ee194b431bac..abddfd9302bd8 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_equal_3leg = [](auto first1, auto last1, auto first2, auto) { return std::equal(first1, last1, first2); };
@@ -35,7 +36,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto equal) {
benchmark::RegisterBenchmark(
name,
- [equal](auto& st) {
+ [equal](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -84,7 +85,7 @@ int main(int argc, char** argv) {
auto bm = [](std::string name, auto equal, bool aligned) {
benchmark::RegisterBenchmark(
name,
- [=](auto& st) {
+ [=](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range();
std::vector<bool> c1(size, true);
std::vector<bool> c2(size + 8, true);
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find.bench.cpp
index 763058e359dfd..314689492fa5a 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_find = [](auto first, auto last, auto const& value) { return std::find(first, last, value); };
@@ -78,7 +79,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find) {
benchmark::RegisterBenchmark(
name,
- [find](auto& st) {
+ [find](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -108,7 +109,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find) {
benchmark::RegisterBenchmark(
name,
- [find](auto& st) {
+ [find](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -136,7 +137,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find) {
benchmark::RegisterBenchmark(
name,
- [find](auto& st) {
+ [find](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::size_t const seg_size = 256;
std::size_t const segments = (size + seg_size - 1) / seg_size;
@@ -174,7 +175,7 @@ int main(int argc, char** argv) {
auto bm = [](std::string name, auto find) {
benchmark::RegisterBenchmark(
name,
- [find](auto& st) {
+ [find](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<bool> c(size, true);
bool y = false;
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
index 86cba1be38cc0..1b94bc2298c1a 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
@@ -19,6 +19,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_find_end = [](auto first1, auto last1, auto first2, auto last2) {
@@ -49,7 +50,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_end) {
benchmark::RegisterBenchmark(
name,
- [find_end](auto& st) {
+ [find_end](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -79,7 +80,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_end) {
benchmark::RegisterBenchmark(
name,
- [find_end](auto& st) {
+ [find_end](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -117,7 +118,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_end) {
benchmark::RegisterBenchmark(
name,
- [find_end](auto& st) {
+ [find_end](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -143,7 +144,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_end) {
benchmark::RegisterBenchmark(
name,
- [find_end](auto& st) {
+ [find_end](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -170,7 +171,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_end) {
benchmark::RegisterBenchmark(
name,
- [find_end](auto& st) {
+ [find_end](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
index 3c00db8dafbd8..4a7366e72f1cf 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_find_first_of = [](auto first1, auto last1, auto first2, auto last2) {
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_first_of) {
benchmark::RegisterBenchmark(
name,
- [find_first_of](auto& st) {
+ [find_first_of](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -69,7 +70,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_first_of) {
benchmark::RegisterBenchmark(
name,
- [find_first_of](auto& st) {
+ [find_first_of](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
index 763a8596103c8..bab436d7b5289 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto ranges_find_last_if = [](auto first, auto last, auto const& value) {
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_last) {
benchmark::RegisterBenchmark(
name,
- [find_last](auto& st) {
+ [find_last](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -86,7 +87,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto find_last) {
benchmark::RegisterBenchmark(
name,
- [find_last](auto& st) {
+ [find_last](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
index ab83e538e4996..cca60f1dc4801 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
@@ -20,6 +20,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_ranges_fold_left = [](auto first, auto last, auto init, auto func) {
@@ -39,7 +40,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto fold) {
benchmark::RegisterBenchmark(
name,
- [fold](auto& st) {
+ [fold](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
static_assert(std::is_unsigned_v<ValueType>,
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/for_each.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/for_each.bench.cpp
index e66aeb4a53f2a..09bce0dd31ab2 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/for_each.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/for_each.bench.cpp
@@ -20,6 +20,7 @@
#include <vector>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_for_each = [](auto first, auto last, auto f) { return std::for_each(first, last, f); };
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
using ElemType = typename Container::value_type;
benchmark::RegisterBenchmark(
name,
- [for_each](auto& st) {
+ [for_each](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
Container c(size, 1);
auto first = c.begin();
@@ -58,7 +59,7 @@ int main(int argc, char** argv) {
std::type_identity<Container>, std::bool_constant<IsMapLike>, std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
Container c;
for (std::int64_t i = 0; i != st.range(0); ++i) {
if constexpr (IsMapLike)
@@ -87,7 +88,7 @@ int main(int argc, char** argv) {
std::type_identity<Container>, std::bool_constant<IsMapLike>, std::string name) {
benchmark::RegisterBenchmark(
name,
- [](auto& st) {
+ [](auto& st) TEST_ALIGN_BENCHMARK {
Container c;
const std::size_t size = st.range(0);
@@ -122,7 +123,7 @@ int main(int argc, char** argv) {
benchmark::RegisterBenchmark(
name,
- [for_each](auto& st) {
+ [for_each](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::size_t const seg_size = 256;
std::size_t const segments = (size + seg_size - 1) / seg_size;
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/for_each_n.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/for_each_n.bench.cpp
index 0068d634574ed..b84410a58c0a4 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/for_each_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/for_each_n.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_for_each_n = [](auto first, auto n, auto f) { return std::for_each_n(first, n, f); };
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
using ElemType = typename Container::value_type;
benchmark::RegisterBenchmark(
name,
- [for_each_n](auto& st) {
+ [for_each_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const n = st.range(0);
Container c(n, 1);
auto first = c.begin();
@@ -55,7 +56,7 @@ int main(int argc, char** argv) {
using ElemType = typename C1::value_type;
benchmark::RegisterBenchmark(
name,
- [for_each_n](auto& st) {
+ [for_each_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::size_t const seg_size = 256;
std::size_t const segments = (size + seg_size - 1) / seg_size;
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
index 5ae6ca06c6c8c..e16893a8d4301 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_is_permutation_3leg = [](auto first1, auto last1, auto first2, auto) {
@@ -72,7 +73,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto is_permutation) {
benchmark::RegisterBenchmark(
name,
- [is_permutation](auto& st) {
+ [is_permutation](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -100,7 +101,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto is_permutation) {
benchmark::RegisterBenchmark(
name,
- [is_permutation](auto& st) {
+ [is_permutation](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data;
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
index c9411620b20fa..af825b669e993 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_mismatch_3leg = [](auto first1, auto last1, auto first2, auto) {
@@ -40,7 +41,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto mismatch) {
benchmark::RegisterBenchmark(
name,
- [mismatch](auto& st) {
+ [mismatch](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
index 06b3354169cf1..683a43ccd5a39 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
@@ -18,6 +18,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_search = [](auto first1, auto last1, auto first2, auto last2) {
@@ -32,7 +33,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto search) {
benchmark::RegisterBenchmark(
name,
- [search](auto& st) {
+ [search](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -68,7 +69,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto search) {
benchmark::RegisterBenchmark(
name,
- [search](auto& st) {
+ [search](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -114,7 +115,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto search) {
benchmark::RegisterBenchmark(
name,
- [search](auto& st) {
+ [search](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
@@ -148,7 +149,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto search) {
benchmark::RegisterBenchmark(
name,
- [search](auto& st) {
+ [search](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
index c8d02151b147f..1a8727ca623fe 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_search_n = [](auto first, auto last, auto n, auto const& value) {
@@ -31,7 +32,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto search_n) {
benchmark::RegisterBenchmark(
name,
- [search_n](auto& st) {
+ [search_n](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
index 57747e551dc71..ab71ad79aad95 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
@@ -17,6 +17,7 @@
#include <benchmark/benchmark.h>
#include "../../GenerateInput.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto ranges_starts_with_pred = [](auto first1, auto last1, auto first2, auto last2) {
@@ -28,7 +29,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto starts_with) {
benchmark::RegisterBenchmark(
name,
- [starts_with](auto& st) {
+ [starts_with](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
ValueType x = Generate<ValueType>::random();
diff --git a/libcxx/test/benchmarks/algorithms/partitions/is_partitioned.bench.cpp b/libcxx/test/benchmarks/algorithms/partitions/is_partitioned.bench.cpp
index 61f9b23e74d7e..be89160b668c7 100644
--- a/libcxx/test/benchmarks/algorithms/partitions/is_partitioned.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/partitions/is_partitioned.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
auto compute_median(auto first, auto last) {
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container, bool Partitioned>(std::string name, auto is_partitioned) {
benchmark::RegisterBenchmark(
name,
- [is_partitioned](auto& st) {
+ [is_partitioned](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/partitions/partition.bench.cpp b/libcxx/test/benchmarks/algorithms/partitions/partition.bench.cpp
index 3c84717913eef..6a5ffbbd066d8 100644
--- a/libcxx/test/benchmarks/algorithms/partitions/partition.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/partitions/partition.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
auto compute_median(auto first, auto last) {
@@ -36,7 +37,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partition) {
benchmark::RegisterBenchmark(
name,
- [partition](auto& st) {
+ [partition](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -79,7 +80,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partition) {
benchmark::RegisterBenchmark(
name,
- [partition](auto& st) {
+ [partition](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/partitions/partition_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/partitions/partition_copy.bench.cpp
index b7976a2b21a3b..9fca75440bac3 100644
--- a/libcxx/test/benchmarks/algorithms/partitions/partition_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/partitions/partition_copy.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
auto compute_median(auto first, auto last) {
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partition_copy) {
benchmark::RegisterBenchmark(
name,
- [partition_copy](auto& st) {
+ [partition_copy](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/partitions/partition_point.bench.cpp b/libcxx/test/benchmarks/algorithms/partitions/partition_point.bench.cpp
index 1d368fed749ad..eae95baf5fc24 100644
--- a/libcxx/test/benchmarks/algorithms/partitions/partition_point.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/partitions/partition_point.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
auto compute_median(auto first, auto last) {
@@ -32,7 +33,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partition_point) {
benchmark::RegisterBenchmark(
name,
- [partition_point](auto& st) {
+ [partition_point](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/partitions/stable_partition.bench.cpp b/libcxx/test/benchmarks/algorithms/partitions/stable_partition.bench.cpp
index 8f726b3bd8e06..43e0f743cb0a3 100644
--- a/libcxx/test/benchmarks/algorithms/partitions/stable_partition.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/partitions/stable_partition.bench.cpp
@@ -18,6 +18,7 @@
#include "count_new.h"
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
auto compute_median(auto first, auto last) {
@@ -36,7 +37,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto stable_partition) {
benchmark::RegisterBenchmark(
name,
- [stable_partition](auto& st) {
+ [stable_partition](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -79,7 +80,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto stable_partition) {
benchmark::RegisterBenchmark(
name,
- [stable_partition](auto& st) {
+ [stable_partition](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
@@ -122,7 +123,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto stable_partition) {
benchmark::RegisterBenchmark(
name,
- [stable_partition](auto& st) {
+ [stable_partition](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/ranges_min_max.bench.cpp b/libcxx/test/benchmarks/algorithms/ranges_min_max.bench.cpp
index fb8018c889fe8..a027fdc4ed9ed 100644
--- a/libcxx/test/benchmarks/algorithms/ranges_min_max.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/ranges_min_max.bench.cpp
@@ -20,7 +20,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::type_identity<Container>, std::string name, auto algo) {
benchmark::RegisterBenchmark(
name,
- [algo](benchmark::State& state) {
+ [algo](benchmark::State& state) TEST_ALIGN_BENCHMARK {
Container c(state.range(), 3);
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/algorithms/sorting/binary_search.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/binary_search.bench.cpp
index 9b85911961af4..1e1fe38a41358 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/binary_search.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/binary_search.bench.cpp
@@ -16,6 +16,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -31,7 +32,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto binary_search) {
benchmark::RegisterBenchmark(
name,
- [binary_search](auto& st) {
+ [binary_search](auto& st) TEST_ALIGN_BENCHMARK {
using ValueType = typename Container::value_type;
std::size_t const size = st.range(0);
@@ -76,7 +77,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto binary_search) {
benchmark::RegisterBenchmark(
name,
- [binary_search](auto& st) {
+ [binary_search](auto& st) TEST_ALIGN_BENCHMARK {
using ValueType = typename Container::value_type;
std::size_t const size = st.range(0);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/equal_range.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/equal_range.bench.cpp
index 7c4d943019baa..071fc10903d07 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/equal_range.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/equal_range.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_equal_range = [](auto first, auto last, auto const& value) { return std::equal_range(first, last, value); };
@@ -29,7 +30,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto equal_range) {
benchmark::RegisterBenchmark(
name,
- [equal_range](auto& st) {
+ [equal_range](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<int> data(size);
std::iota(data.begin(), data.end(), 0);
@@ -62,7 +63,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto equal_range) {
benchmark::RegisterBenchmark(
name,
- [equal_range](auto& st) {
+ [equal_range](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::size_t const subrange_size = size / 2;
std::size_t const left_flank = (size - subrange_size) / 2;
@@ -99,7 +100,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto equal_range) {
benchmark::RegisterBenchmark(
name,
- [equal_range](auto& st) {
+ [equal_range](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::vector<int> data(size);
std::iota(data.begin(), data.end(), 0);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/is_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/is_heap.bench.cpp
index 0d0e6324cf7e1..e089504fdd8f4 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/is_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/is_heap.bench.cpp
@@ -16,6 +16,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto is_heap) {
benchmark::RegisterBenchmark(
name,
- [is_heap](auto& st) {
+ [is_heap](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
index 884df63b151f6..f802237d48cad 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto is_sorted) {
benchmark::RegisterBenchmark(
name,
- [is_sorted](auto& st) {
+ [is_sorted](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
index 05b3a3966f383..5066e1bbdf564 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
@@ -17,6 +17,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -30,7 +31,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto is_sorted_until) {
benchmark::RegisterBenchmark(
name,
- [is_sorted_until](auto& st) {
+ [is_sorted_until](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/lower_upper_bound.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/lower_upper_bound.bench.cpp
index 36eefac3ef4e5..7bd122759c775 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/lower_upper_bound.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/lower_upper_bound.bench.cpp
@@ -16,6 +16,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto lookup) {
benchmark::RegisterBenchmark(
name,
- [lookup](auto& st) {
+ [lookup](auto& st) TEST_ALIGN_BENCHMARK {
using ValueType = typename Container::value_type;
std::size_t const size = st.range(0);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/make_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/make_heap.bench.cpp
index 90bc8ee749eef..a2e33ccd71678 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/make_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/make_heap.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark std::make_heap on various types of data
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto generate_data, auto pred) {
benchmark::RegisterBenchmark(
name,
- [generate_data, pred](auto& st) {
+ [generate_data, pred](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/make_heap_then_sort_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/make_heap_then_sort_heap.bench.cpp
index 9e0e612953407..dd855b56c620d 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/make_heap_then_sort_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/make_heap_then_sort_heap.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark {std,ranges}::sort on various types of data
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto pred, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [pred, generate_data](auto& st) {
+ [pred, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/nth_element.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/nth_element.bench.cpp
index 4c3e8115def30..f5a5670fce32f 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/nth_element.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/nth_element.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_nth_element = [](auto first, auto nth, auto last) { return std::nth_element(first, nth, last); };
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto nth_element, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [nth_element, generate_data](auto& st) {
+ [nth_element, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/partial_sort.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/partial_sort.bench.cpp
index 400779df1d4c2..ae57f8326937c 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/partial_sort.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/partial_sort.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_partial_sort = [](auto first, auto mid, auto last) { return std::partial_sort(first, mid, last); };
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partial_sort, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [partial_sort, generate_data](auto& st) {
+ [partial_sort, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/partial_sort_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/partial_sort_copy.bench.cpp
index 2e81f8b5bef91..7936e34df2b91 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/partial_sort_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/partial_sort_copy.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_partial_sort_copy = [](auto first, auto last, auto dfirst, auto dlast) {
@@ -32,7 +33,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto partial_sort_copy, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [partial_sort_copy, generate_data](auto& st) {
+ [partial_sort_copy, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data = generate_data(size);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/permutation.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/permutation.bench.cpp
index 8834c595361fa..327270fde9a8c 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/permutation.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/permutation.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_next_permutation = [](auto first, auto last) { return std::next_permutation(first, last); };
@@ -32,7 +33,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto permutation, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [permutation, generate_data](auto& st) {
+ [permutation, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
using ValueType = typename Container::value_type;
std::vector<ValueType> data = generate_data(size);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
index d545daa1241d2..def8f0b8b41f4 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/pop_heap.bench.cpp
@@ -14,13 +14,14 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
int main(int argc, char** argv) {
auto bm = []<class Container>(std::type_identity<Container>, std::string name) {
benchmark::RegisterBenchmark(
name,
- [](benchmark::State& state) {
+ [](benchmark::State& state) TEST_ALIGN_BENCHMARK {
std::size_t size = state.range(0);
Container c;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/push_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/push_heap.bench.cpp
index dffc9105894ed..1fa24dab6cc98 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/push_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/push_heap.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark {std,ranges}::sort on various types of data
@@ -27,7 +28,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto pred, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [pred, generate_data](auto& st) {
+ [pred, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/set_intersection.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/set_intersection.bench.cpp
index bf353c436c83d..8bda54d1ed172 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/set_intersection.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/set_intersection.bench.cpp
@@ -18,6 +18,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include "../../GenerateInput.h"
// Generate two ranges where the larger range holds `n` elements and the smaller one holds every `ratio`th
@@ -38,7 +39,7 @@ std::pair<std::vector<T>, std::vector<T>> spread(std::size_t n, std::size_t rati
int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto generate) {
- return benchmark::RegisterBenchmark(name, [generate](auto& st) {
+ return benchmark::RegisterBenchmark(name, [generate](auto& st) TEST_ALIGN_BENCHMARK {
using ValueType = typename Container::value_type;
std::size_t const size = st.range(0);
diff --git a/libcxx/test/benchmarks/algorithms/sorting/sort.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/sort.bench.cpp
index 83f425d669c51..bc4f2fb55a8e0 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/sort.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/sort.bench.cpp
@@ -17,6 +17,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_sort = [](auto first, auto last) { return std::sort(first, last); };
@@ -32,7 +33,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto sort, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [sort, generate_data](auto& st) {
+ [sort, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/sort_heap.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/sort_heap.bench.cpp
index 51b0d0a000beb..2307200fde673 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/sort_heap.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/sort_heap.bench.cpp
@@ -16,6 +16,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
// Benchmark {std,ranges}::sort on various types of data
@@ -26,7 +27,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto pred, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [pred, generate_data](auto& st) {
+ [pred, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/algorithms/sorting/stable_sort.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/stable_sort.bench.cpp
index 07e300b718804..88126f226ce45 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/stable_sort.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/stable_sort.bench.cpp
@@ -18,6 +18,7 @@
#include "benchmark/benchmark.h"
#include "common.h"
#include "count_new.h"
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_stable_sort = [](auto first, auto last) { return std::stable_sort(first, last); };
@@ -33,7 +34,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto stable_sort, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [stable_sort, generate_data](auto& st) {
+ [stable_sort, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
@@ -88,7 +89,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto stable_sort, auto generate_data) {
benchmark::RegisterBenchmark(
name,
- [stable_sort, generate_data](auto& st) {
+ [stable_sort, generate_data](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
constexpr std::size_t BatchSize = 32;
using ValueType = typename Container::value_type;
diff --git a/libcxx/test/benchmarks/atomic_wait_1_waiter_1_notifier.bench.cpp b/libcxx/test/benchmarks/atomic_wait_1_waiter_1_notifier.bench.cpp
index 5c82b8e8e9af6..7808df9ea44f2 100644
--- a/libcxx/test/benchmarks/atomic_wait_1_waiter_1_notifier.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait_1_waiter_1_notifier.bench.cpp
@@ -24,11 +24,12 @@
#include "benchmark/benchmark.h"
#include "make_test_thread.h"
+#include "test_macros.h"
using namespace std::chrono_literals;
template <class NotifyPolicy, class NumPrioTasks>
-void BM_1_atomic_1_waiter_1_notifier(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_1_atomic_1_waiter_1_notifier(benchmark::State& state) {
[[maybe_unused]] std::array<HighPrioTask, NumPrioTasks::value> tasks{};
std::atomic<std::uint64_t> a;
auto thread_func = [&](std::stop_token st) { NotifyPolicy::notify(a, st); };
diff --git a/libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp b/libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp
index 4d6547418e767..fee62f21659a7 100644
--- a/libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait_N_waiter_N_notifier.bench.cpp
@@ -26,11 +26,12 @@
#include "benchmark/benchmark.h"
#include "make_test_thread.h"
+#include "test_macros.h"
using namespace std::chrono_literals;
template <class NotifyPolicy, class NumberOfAtomics, class NumPrioTasks>
-void BM_N_atomics_N_waiter_N_notifier(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_N_atomics_N_waiter_N_notifier(benchmark::State& state) {
[[maybe_unused]] std::array<HighPrioTask, NumPrioTasks::value> tasks{};
const std::uint64_t total_loop_test_param = state.range(0);
constexpr std::uint64_t num_atomics = NumberOfAtomics::value;
diff --git a/libcxx/test/benchmarks/atomic_wait_multi_waiter_1_notifier.bench.cpp b/libcxx/test/benchmarks/atomic_wait_multi_waiter_1_notifier.bench.cpp
index f8288cb4c8020..2a6d19e335759 100644
--- a/libcxx/test/benchmarks/atomic_wait_multi_waiter_1_notifier.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait_multi_waiter_1_notifier.bench.cpp
@@ -24,11 +24,12 @@
#include "benchmark/benchmark.h"
#include "make_test_thread.h"
+#include "test_macros.h"
using namespace std::chrono_literals;
template <class NotifyPolicy, class NumWaitingThreads, class NumPrioTasks>
-void BM_1_atomic_multi_waiter_1_notifier(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_1_atomic_multi_waiter_1_notifier(benchmark::State& state) {
[[maybe_unused]] std::array<HighPrioTask, NumPrioTasks::value> tasks{};
std::atomic<std::uint64_t> a;
diff --git a/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp b/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
index 9849ffa7e038d..9e373162a6d1d 100644
--- a/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
+++ b/libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.bench.cpp
@@ -20,6 +20,7 @@
#include "benchmark/benchmark.h"
#include "make_test_thread.h"
+#include "test_macros.h"
using namespace std::chrono_literals;
@@ -102,10 +103,12 @@ void test_multi_thread_lock_unlock(benchmark::State& state) {
}
}
-void BM_atomic_wait(benchmark::State& state) { test_multi_thread_lock_unlock<std::atomic<bool>, AtomicLock>(state); }
+TEST_ALIGN_BENCHMARK void BM_atomic_wait(benchmark::State& state) {
+ test_multi_thread_lock_unlock<std::atomic<bool>, AtomicLock>(state);
+}
BENCHMARK(BM_atomic_wait)->RangeMultiplier(2)->Range(1 << 10, 1 << 20);
-void BM_mutex(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_mutex(benchmark::State& state) {
test_multi_thread_lock_unlock<std::mutex, std::unique_lock<std::mutex>>(state);
}
BENCHMARK(BM_mutex)->RangeMultiplier(2)->Range(1 << 10, 1 << 20);
diff --git a/libcxx/test/benchmarks/bitset.bench.cpp b/libcxx/test/benchmarks/bitset.bench.cpp
index 5fda4cbc2b377..1ac3e288480fb 100644
--- a/libcxx/test/benchmarks/bitset.bench.cpp
+++ b/libcxx/test/benchmarks/bitset.bench.cpp
@@ -9,6 +9,7 @@
// UNSUPPORTED: c++03
#include "benchmark/benchmark.h"
+#include "test_macros.h"
#include <bitset>
#include <cmath>
#include <cstddef>
@@ -39,7 +40,7 @@ struct GenerateBitset {
};
template <std::size_t N>
-static void BM_BitsetToString(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_BitsetToString(benchmark::State& state) {
double p = state.range(0) / 100.0;
std::bitset<N> b = GenerateBitset<N>::generate(p);
benchmark::DoNotOptimize(b);
@@ -67,7 +68,7 @@ BENCHMARK(BM_BitsetToString<64>)->Arg(50)->Name("BM_BitsetToString<64>/Uniform (
BENCHMARK(BM_BitsetToString<8192>)->Arg(50)->Name("BM_BitsetToString<8192>/Uniform (50%)");
BENCHMARK(BM_BitsetToString<1048576>)->Arg(50)->Name("BM_BitsetToString<1048576>/Uniform (50%)"); // 1 << 20
-static void BM_Bitset_ctor_ull(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_Bitset_ctor_ull(benchmark::State& state) {
unsigned long long val = 1;
for (auto _ : state) {
benchmark::DoNotOptimize(val);
diff --git a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
index 72fd0ac9bfa0e..34cd1ca90b647 100644
--- a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
@@ -89,7 +89,7 @@ void associative_container_benchmarks(std::string container) {
/////////////////////////
// Constructors
/////////////////////////
- bench("ctor(const Self&)", [=](auto& st) {
+ bench("ctor(const Self&)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container src(in.begin(), in.end());
@@ -110,7 +110,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("ctor(const Self&, const allocator_type&)", [=](auto& st) {
+ bench("ctor(const Self&, const allocator_type&)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container src(in.begin(), in.end());
@@ -131,7 +131,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench_non_empty("ctor(Self&&, const allocator_type&) (
diff erent allocs)", [=](auto& st) {
+ bench_non_empty("ctor(Self&&, const allocator_type&) (
diff erent allocs)", [=](auto& st) TEST_ALIGN_BENCHMARK {
using PMRContainer = adapt_operations<Container>::template rebind_alloc<
std::pmr::polymorphic_allocator<typename Container::value_type>>;
@@ -165,7 +165,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("ctor(iterator, iterator) (unsorted sequence)", [=](auto& st) {
+ bench("ctor(iterator, iterator) (unsorted sequence)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::mt19937 randomness;
std::vector<Key> keys = generate_unique_keys(size);
@@ -188,7 +188,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("ctor(iterator, iterator) (sorted sequence)", [=](auto& st) {
+ bench("ctor(iterator, iterator) (sorted sequence)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Key> keys = generate_unique_keys(size);
std::sort(keys.begin(), keys.end());
@@ -213,7 +213,7 @@ void associative_container_benchmarks(std::string container) {
/////////////////////////
// Assignment
/////////////////////////
- bench("operator=(const Self&) (into cleared Container)", [=](auto& st) {
+ bench("operator=(const Self&) (into cleared Container)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container src(in.begin(), in.end());
@@ -234,7 +234,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("operator=(const Self&) (into partially populated Container)", [=](auto& st) {
+ bench("operator=(const Self&) (into partially populated Container)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container src(in.begin(), in.end());
@@ -260,7 +260,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("operator=(const Self&) (into populated Container)", [=](auto& st) {
+ bench("operator=(const Self&) (into populated Container)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container src(in.begin(), in.end());
@@ -278,7 +278,7 @@ void associative_container_benchmarks(std::string container) {
/////////////////////////
// Insertion
/////////////////////////
- bench_non_empty("insert(const value_type&) (already present)", [=](auto& st) {
+ bench_non_empty("insert(const value_type&) (already present)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Value to_insert = in[in.size() / 2]; // pick any existing value
@@ -334,11 +334,13 @@ void associative_container_benchmarks(std::string container) {
st.ResumeTiming();
}
};
- bench("insert(value) (new value, end)", [=](auto& state) { insert_new_value_bench(true, state); });
- bench("insert(value) (new value, middle)", [=](auto& state) { insert_new_value_bench(false, state); });
+ bench("insert(value) (new value, end)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_new_value_bench(true, state); });
+ bench("insert(value) (new value, middle)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_new_value_bench(false, state); });
if constexpr (is_map_like && !is_multi_key_container) {
- bench_non_empty("insert_or_assign(key, value) (already present)", [=](auto& st) {
+ bench_non_empty("insert_or_assign(key, value) (already present)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Value to_insert = in[in.size() / 2]; // pick any existing value
@@ -387,9 +389,10 @@ void associative_container_benchmarks(std::string container) {
st.ResumeTiming();
}
};
- bench("insert_or_assign(key, value) (new value, end)", [=](auto& state) { insert_or_assign_bench(true, state); });
+ bench("insert_or_assign(key, value) (new value, end)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_or_assign_bench(true, state); });
bench("insert_or_assign(key, value) (new value, middle)",
- [=](auto& state) { insert_or_assign_bench(false, state); });
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_or_assign_bench(false, state); });
}
// The insert(hint, ...) methods are only relevant for ordered containers, and we lack
@@ -431,8 +434,10 @@ void associative_container_benchmarks(std::string container) {
st.ResumeTiming();
}
};
- bench("insert(hint, value) (good hint, end)", [=](auto& state) { insert_good_hint_bench(true, state); });
- bench("insert(hint, value) (good hint, middle)", [=](auto& state) { insert_good_hint_bench(false, state); });
+ bench("insert(hint, value) (good hint, end)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_good_hint_bench(true, state); });
+ bench("insert(hint, value) (good hint, middle)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_good_hint_bench(false, state); });
auto insert_bad_hint_bench = [=](bool bench_end_iter, auto& st) {
const std::size_t size = st.range(0);
@@ -465,8 +470,10 @@ void associative_container_benchmarks(std::string container) {
}
};
- bench("insert(hint, value) (bad hint, end)", [=](auto& state) { insert_bad_hint_bench(true, state); });
- bench("insert(hint, value) (bad hint, middle)", [=](auto& state) { insert_bad_hint_bench(false, state); });
+ bench("insert(hint, value) (bad hint, end)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_bad_hint_bench(true, state); });
+ bench("insert(hint, value) (bad hint, middle)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { insert_bad_hint_bench(false, state); });
}
auto insert_iter_iter_bench = [=](bool bench_end_iter, auto& st) {
@@ -498,14 +505,14 @@ void associative_container_benchmarks(std::string container) {
st.ResumeTiming();
}
};
- bench_non_empty("insert(iterator, iterator) (all new keys, end)", [=](auto& state) {
+ bench_non_empty("insert(iterator, iterator) (all new keys, end)", [=](auto& state) TEST_ALIGN_BENCHMARK {
insert_iter_iter_bench(true, state);
});
- bench_non_empty("insert(iterator, iterator) (all new keys, middle)", [=](auto& state) {
+ bench_non_empty("insert(iterator, iterator) (all new keys, middle)", [=](auto& state) TEST_ALIGN_BENCHMARK {
insert_iter_iter_bench(false, state);
});
- bench_non_empty("insert(iterator, iterator) (half new keys)", [=](auto& st) {
+ bench_non_empty("insert(iterator, iterator) (half new keys)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
@@ -529,7 +536,7 @@ void associative_container_benchmarks(std::string container) {
});
if constexpr (is_map_like) {
- bench_non_empty("insert(iterator, iterator) (product_iterator from same type)", [=](auto& st) {
+ bench_non_empty("insert(iterator, iterator) (product_iterator from same type)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size + (size / 10)));
Container source(in.begin(), in.end());
@@ -548,7 +555,7 @@ void associative_container_benchmarks(std::string container) {
});
#if defined(__cpp_lib_ranges_zip) && __cpp_lib_ranges_zip >= 202110L
- bench_non_empty("insert(iterator, iterator) (product_iterator from zip_view)", [=](auto& st) {
+ bench_non_empty("insert(iterator, iterator) (product_iterator from zip_view)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Key> keys = generate_unique_keys(size + (size / 10));
std::sort(keys.begin(), keys.end());
@@ -573,7 +580,7 @@ void associative_container_benchmarks(std::string container) {
/////////////////////////
// Erasure
/////////////////////////
- bench_non_empty("erase(key) (existent)", [=](auto& st) {
+ bench_non_empty("erase(key) (existent)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Value element = in[in.size() / 2]; // pick any element
@@ -624,10 +631,12 @@ void associative_container_benchmarks(std::string container) {
// no cleanup required because we erased a non-existent element
}
};
- bench("erase(key) (non-existent, end)", [=](auto& state) { erase_key_non_existent_bench(true, state); });
- bench("erase(key) (non-existent, middle)", [=](auto& state) { erase_key_non_existent_bench(false, state); });
+ bench("erase(key) (non-existent, end)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { erase_key_non_existent_bench(true, state); });
+ bench("erase(key) (non-existent, middle)",
+ [=](auto& state) TEST_ALIGN_BENCHMARK { erase_key_non_existent_bench(false, state); });
- bench_non_empty("erase(iterator)", [=](auto& st) {
+ bench_non_empty("erase(iterator)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Value element = in[in.size() / 2]; // pick any element
@@ -655,7 +664,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench_non_empty("erase(iterator, iterator) (erase half the container)", [=](auto& st) {
+ bench_non_empty("erase(iterator, iterator) (erase half the container)", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container c(in.begin(), in.end());
@@ -676,7 +685,7 @@ void associative_container_benchmarks(std::string container) {
}
});
- bench("clear()", [=](auto& st) {
+ bench("clear()", [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container c(in.begin(), in.end());
@@ -696,7 +705,7 @@ void associative_container_benchmarks(std::string container) {
// Query
/////////////////////////
auto query_bench = [=](auto func) {
- return [=](auto& st) {
+ return [=](auto& st) TEST_ALIGN_BENCHMARK {
const std::size_t size = st.range(0);
std::vector<Value> in = make_value_types(generate_unique_keys(size));
Container c(in.begin(), in.end());
diff --git a/libcxx/test/benchmarks/containers/associative/map.bench.cpp b/libcxx/test/benchmarks/containers/associative/map.bench.cpp
index 755a5ecf0cdd2..9d3884b8c24be 100644
--- a/libcxx/test/benchmarks/containers/associative/map.bench.cpp
+++ b/libcxx/test/benchmarks/containers/associative/map.bench.cpp
@@ -15,8 +15,9 @@
#include "associative_container_benchmarks.h"
#include "../../GenerateInput.h"
#include "benchmark/benchmark.h"
+#include "test_macros.h"
-static void BM_map_find_string_literal(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_map_find_string_literal(benchmark::State& state) {
std::map<std::string, int> map;
map.emplace("Something very very long to show a long string situation", 1);
map.emplace("Something Else", 2);
diff --git a/libcxx/test/benchmarks/containers/associative/unordered_map.bench.cpp b/libcxx/test/benchmarks/containers/associative/unordered_map.bench.cpp
index 79ef7ddd4429a..785babcd5d415 100644
--- a/libcxx/test/benchmarks/containers/associative/unordered_map.bench.cpp
+++ b/libcxx/test/benchmarks/containers/associative/unordered_map.bench.cpp
@@ -15,8 +15,9 @@
#include "associative_container_benchmarks.h"
#include "../../GenerateInput.h"
#include "benchmark/benchmark.h"
+#include "test_macros.h"
-static void BM_map_find_string_literal(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_map_find_string_literal(benchmark::State& state) {
std::unordered_map<std::string, int> map;
map.emplace("Something very very long to show a long string situation", 1);
map.emplace("Something Else", 2);
diff --git a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
index c6cf6fbafcb9e..ff7b7fe2af018 100644
--- a/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/sequence/sequence_container_benchmarks.h
@@ -65,7 +65,7 @@ void sequence_container_benchmarks(std::string container) {
/////////////////////////
if constexpr (std::is_constructible_v<Container, std::size_t>) {
// not all containers provide this constructor
- bench("ctor(size_type)", [](auto& st) {
+ bench("ctor(size_type)", [](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
for ([[maybe_unused]] auto _ : st) {
@@ -76,7 +76,7 @@ void sequence_container_benchmarks(std::string container) {
}
for (auto gen : generators)
- bench("ctor(size_type, const value_type&)" + tostr(gen), [gen](auto& st) {
+ bench("ctor(size_type, const value_type&)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
ValueType value = gen();
benchmark::DoNotOptimize(value);
@@ -88,7 +88,7 @@ void sequence_container_benchmarks(std::string container) {
});
for (auto gen : generators)
- bench("ctor(Iterator, Iterator)" + tostr(gen), [gen](auto& st) {
+ bench("ctor(Iterator, Iterator)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -104,7 +104,7 @@ void sequence_container_benchmarks(std::string container) {
#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
for (auto gen : generators)
- bench("ctor(Range)" + tostr(gen), [gen](auto& st) {
+ bench("ctor(Range)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -118,7 +118,7 @@ void sequence_container_benchmarks(std::string container) {
#endif
for (auto gen : generators)
- bench("ctor(const Self&)" + tostr(gen), [gen](auto& st) {
+ bench("ctor(const Self&)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
Container in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -135,7 +135,7 @@ void sequence_container_benchmarks(std::string container) {
// Assignment
/////////////////////////
for (auto gen : generators)
- bench("operator=(const Self&)" + tostr(gen), [gen](auto& st) {
+ bench("operator=(const Self&)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
Container in1, in2;
std::generate_n(std::back_inserter(in1), size, gen);
@@ -161,7 +161,7 @@ void sequence_container_benchmarks(std::string container) {
// implementation basically creates a new container from scratch or manages to reuse the
// pre-existing storage.
for (auto gen : generators)
- bench("assign(input-iter, input-iter) (full container)" + tostr(gen), [gen](auto& st) {
+ bench("assign(input-iter, input-iter) (full container)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in1, in2;
std::generate_n(std::back_inserter(in1), size, gen);
@@ -185,7 +185,7 @@ void sequence_container_benchmarks(std::string container) {
// Insertion
/////////////////////////
for (auto gen : generators)
- bench("insert(begin)" + tostr(gen), [gen](auto& st) {
+ bench("insert(begin)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -207,7 +207,7 @@ void sequence_container_benchmarks(std::string container) {
if constexpr (std::random_access_iterator<typename Container::iterator>) {
for (auto gen : generators)
- bench("insert(middle)" + tostr(gen), [gen](auto& st) {
+ bench("insert(middle)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -233,7 +233,7 @@ void sequence_container_benchmarks(std::string container) {
// Insert at the start of a vector in a scenario where the vector already
// has enough capacity to hold all the elements we are inserting.
for (auto gen : generators)
- bench("insert(begin, input-iter, input-iter) (no realloc)" + tostr(gen), [gen](auto& st) {
+ bench("insert(begin, input-iter, input-iter) (no realloc)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -260,7 +260,7 @@ void sequence_container_benchmarks(std::string container) {
// has almost enough capacity to hold all the elements we are inserting,
// but does need to reallocate.
for (auto gen : generators)
- bench("insert(begin, input-iter, input-iter) (half filled)" + tostr(gen), [gen](auto& st) {
+ bench("insert(begin, input-iter, input-iter) (half filled)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -286,7 +286,7 @@ void sequence_container_benchmarks(std::string container) {
// more elements, but needs to reallocate almost immediately to fit the remaining
// elements.
for (auto gen : generators)
- bench("insert(begin, input-iter, input-iter) (near full)" + tostr(gen), [gen](auto& st) {
+ bench("insert(begin, input-iter, input-iter) (near full)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -320,7 +320,7 @@ void sequence_container_benchmarks(std::string container) {
// For containers where we can observe capacity(), push_back a single element
// without reserving to ensure the container needs to grow
for (auto gen : generators)
- bench("push_back() (growing)" + tostr(gen), [gen](auto& st) {
+ bench("push_back() (growing)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -354,7 +354,7 @@ void sequence_container_benchmarks(std::string container) {
// ensure the container doesn't grow
if constexpr (has_reserve) {
for (auto gen : generators)
- bench("push_back() (with reserve)" + tostr(gen), [gen](auto& st) {
+ bench("push_back() (with reserve)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -378,7 +378,7 @@ void sequence_container_benchmarks(std::string container) {
// push_back many elements: this is amortized constant for std::vector but not all containers
for (auto gen : generators)
- bench("push_back() (many elements)" + tostr(gen), [gen](auto& st) {
+ bench("push_back() (many elements)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -400,7 +400,7 @@ void sequence_container_benchmarks(std::string container) {
#if defined(__cpp_lib_containers_ranges) && __cpp_lib_containers_ranges >= 202202L
for (auto gen : generators)
- bench("append_range() (into empty container)" + tostr(gen), [gen](auto& state) {
+ bench("append_range() (into empty container)" + tostr(gen), [gen](auto& state) TEST_ALIGN_BENCHMARK {
auto const size = state.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -427,7 +427,7 @@ void sequence_container_benchmarks(std::string container) {
if constexpr (has_prepend_range) {
for (auto gen : generators)
- bench("prepend_range() (into empty container)" + tostr(gen), [gen](auto& state) {
+ bench("prepend_range() (into empty container)" + tostr(gen), [gen](auto& state) TEST_ALIGN_BENCHMARK {
auto const size = state.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -450,7 +450,7 @@ void sequence_container_benchmarks(std::string container) {
// Erasure
/////////////////////////
for (auto gen : generators)
- bench("erase(begin)" + tostr(gen), [gen](auto& st) {
+ bench("erase(begin)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
@@ -472,7 +472,7 @@ void sequence_container_benchmarks(std::string container) {
if constexpr (std::random_access_iterator<typename Container::iterator>) {
for (auto gen : generators)
- bench("erase(middle)" + tostr(gen), [gen](auto& st) {
+ bench("erase(middle)" + tostr(gen), [gen](auto& st) TEST_ALIGN_BENCHMARK {
auto const size = st.range(0);
std::vector<ValueType> in;
std::generate_n(std::back_inserter(in), size, gen);
diff --git a/libcxx/test/benchmarks/containers/sequence/vector_bool.bench.cpp b/libcxx/test/benchmarks/containers/sequence/vector_bool.bench.cpp
index e9201cb959934..14c180a107e12 100644
--- a/libcxx/test/benchmarks/containers/sequence/vector_bool.bench.cpp
+++ b/libcxx/test/benchmarks/containers/sequence/vector_bool.bench.cpp
@@ -14,7 +14,7 @@
#include "test_macros.h"
-static void BM_vector_bool_copy_ctor(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_copy_ctor(benchmark::State& state) {
std::vector<bool> vec(100, true);
for (auto _ : state) {
@@ -25,7 +25,7 @@ static void BM_vector_bool_copy_ctor(benchmark::State& state) {
}
BENCHMARK(BM_vector_bool_copy_ctor)->Name("std::vector<bool>::ctor(const Self&)");
-static void BM_vector_bool_move_ctor_alloc_equal(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_move_ctor_alloc_equal(benchmark::State& state) {
std::vector<bool> vec(100, true);
for (auto _ : state) {
@@ -39,7 +39,7 @@ BENCHMARK(BM_vector_bool_move_ctor_alloc_equal)
->Name("std::vector<bool>::ctor(Self&&, const allocator_type&) (equal allocators)");
#if TEST_STD_VER >= 17
-static void BM_vector_bool_move_ctor_alloc_
diff erent(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_move_ctor_alloc_
diff erent(benchmark::State& state) {
std::pmr::monotonic_buffer_resource resource;
std::pmr::vector<bool> vec(100, true, &resource);
@@ -53,7 +53,7 @@ BENCHMARK(BM_vector_bool_move_ctor_alloc_
diff erent)
->Name("std::vector<bool>::ctor(Self&&, const allocator_type&) (
diff erent allocators)");
#endif
-static void BM_vector_bool_size_ctor(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_size_ctor(benchmark::State& state) {
for (auto _ : state) {
std::vector<bool> vec(100, true);
benchmark::DoNotOptimize(vec);
@@ -61,7 +61,7 @@ static void BM_vector_bool_size_ctor(benchmark::State& state) {
}
BENCHMARK(BM_vector_bool_size_ctor)->Name("std::vector<bool>::ctor(size_type, const value_type&)");
-static void BM_vector_bool_reserve(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_reserve(benchmark::State& state) {
for (auto _ : state) {
std::vector<bool> vec;
vec.reserve(100);
@@ -70,7 +70,7 @@ static void BM_vector_bool_reserve(benchmark::State& state) {
}
BENCHMARK(BM_vector_bool_reserve)->Name("std::vector<bool>::reserve()");
-static void BM_vector_bool_resize(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_vector_bool_resize(benchmark::State& state) {
for (auto _ : state) {
std::vector<bool> vec;
vec.resize(100);
diff --git a/libcxx/test/benchmarks/containers/string.bench.cpp b/libcxx/test/benchmarks/containers/string.bench.cpp
index 49f688aedae5c..b795654e84281 100644
--- a/libcxx/test/benchmarks/containers/string.bench.cpp
+++ b/libcxx/test/benchmarks/containers/string.bench.cpp
@@ -32,12 +32,12 @@ std::string rename(std::string str, std::string_view replacement) {
template <class Func, class Mod = decltype([](auto) {})>
void bench(std::string name, Func func, Mod modifier = {}) {
- benchmark::RegisterBenchmark(rename(name, "string"), [=](benchmark::State& state) {
+ benchmark::RegisterBenchmark(rename(name, "string"), [=](benchmark::State& state) TEST_ALIGN_BENCHMARK {
func(std::type_identity<char>(), state);
})->Apply(modifier);
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- benchmark::RegisterBenchmark(rename(name, "wstring"), [=](benchmark::State& state) {
+ benchmark::RegisterBenchmark(rename(name, "wstring"), [=](benchmark::State& state) TEST_ALIGN_BENCHMARK {
func(std::type_identity<wchar_t>(), state);
})->Apply(modifier);
#endif
diff --git a/libcxx/test/benchmarks/exception_ptr.bench.cpp b/libcxx/test/benchmarks/exception_ptr.bench.cpp
index 8ec7488ddf099..a6a3ce6cf3182 100644
--- a/libcxx/test/benchmarks/exception_ptr.bench.cpp
+++ b/libcxx/test/benchmarks/exception_ptr.bench.cpp
@@ -10,15 +10,16 @@
#include <benchmark/benchmark.h>
#include <exception>
+#include "test_macros.h"
-void bm_make_exception_ptr(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK 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);
-void bm_exception_ptr_copy_ctor_nonnull(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_copy_ctor_nonnull(benchmark::State& state) {
std::exception_ptr excptr = std::make_exception_ptr(42);
for (auto _ : state) {
benchmark::DoNotOptimize(std::exception_ptr(excptr));
@@ -26,7 +27,7 @@ void bm_exception_ptr_copy_ctor_nonnull(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_copy_ctor_nonnull);
-void bm_exception_ptr_copy_ctor_null(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_copy_ctor_null(benchmark::State& state) {
std::exception_ptr excptr = nullptr;
for (auto _ : state) {
std::exception_ptr excptr_copy(excptr);
@@ -37,7 +38,7 @@ void bm_exception_ptr_copy_ctor_null(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_copy_ctor_null);
-void bm_exception_ptr_move_ctor_nonnull(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_move_ctor_nonnull(benchmark::State& state) {
std::exception_ptr excptr = std::make_exception_ptr(42);
for (auto _ : state) {
// Need to copy, such that the `excptr` is not moved from and
@@ -48,7 +49,7 @@ void bm_exception_ptr_move_ctor_nonnull(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_move_ctor_nonnull);
-void bm_exception_ptr_move_ctor_null(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_move_ctor_null(benchmark::State& state) {
std::exception_ptr excptr = nullptr;
for (auto _ : state) {
std::exception_ptr new_excptr(std::move(excptr));
@@ -59,7 +60,7 @@ void bm_exception_ptr_move_ctor_null(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_move_ctor_null);
-void bm_exception_ptr_copy_assign_nonnull(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_copy_assign_nonnull(benchmark::State& state) {
std::exception_ptr excptr = std::make_exception_ptr(42);
for (auto _ : state) {
std::exception_ptr new_excptr;
@@ -69,7 +70,7 @@ void bm_exception_ptr_copy_assign_nonnull(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_copy_assign_nonnull);
-void bm_exception_ptr_copy_assign_null(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_copy_assign_null(benchmark::State& state) {
std::exception_ptr excptr = nullptr;
for (auto _ : state) {
std::exception_ptr new_excptr;
@@ -81,7 +82,7 @@ void bm_exception_ptr_copy_assign_null(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_copy_assign_null);
-void bm_exception_ptr_move_assign_nonnull(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_move_assign_nonnull(benchmark::State& state) {
std::exception_ptr excptr = std::make_exception_ptr(42);
for (auto _ : state) {
// Need to copy, such that the `excptr` is not moved from and
@@ -94,7 +95,7 @@ void bm_exception_ptr_move_assign_nonnull(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_move_assign_nonnull);
-void bm_exception_ptr_move_assign_null(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_move_assign_null(benchmark::State& state) {
std::exception_ptr excptr = nullptr;
for (auto _ : state) {
std::exception_ptr new_excptr;
@@ -106,7 +107,7 @@ void bm_exception_ptr_move_assign_null(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_move_assign_null);
-void bm_exception_ptr_swap_nonnull(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_swap_nonnull(benchmark::State& state) {
std::exception_ptr excptr1 = std::make_exception_ptr(41);
std::exception_ptr excptr2 = std::make_exception_ptr(42);
for (auto _ : state) {
@@ -117,7 +118,7 @@ void bm_exception_ptr_swap_nonnull(benchmark::State& state) {
}
BENCHMARK(bm_exception_ptr_swap_nonnull);
-void bm_exception_ptr_swap_null(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void bm_exception_ptr_swap_null(benchmark::State& state) {
std::exception_ptr excptr1 = nullptr;
std::exception_ptr excptr2 = nullptr;
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/filesystem.bench.cpp b/libcxx/test/benchmarks/filesystem.bench.cpp
index ef06209ca0e67..ad88c517b4665 100644
--- a/libcxx/test/benchmarks/filesystem.bench.cpp
+++ b/libcxx/test/benchmarks/filesystem.bench.cpp
@@ -13,13 +13,14 @@
#include "GenerateInput.h"
#include "benchmark/benchmark.h"
#include "test_iterators.h"
+#include "test_macros.h"
namespace fs = std::filesystem;
static const size_t TestNumInputs = 1024;
template <class GenInputs>
-void BM_PathConstructString(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathConstructString(benchmark::State& st, GenInputs gen) {
using fs::path;
const auto in = gen(st.range(0));
path PP;
@@ -36,7 +37,7 @@ BENCHMARK_CAPTURE(BM_PathConstructString, large_string, getRandomStringInputs)
->Range(8, TestNumInputs);
template <class GenInputs>
-void BM_PathConstructCStr(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathConstructCStr(benchmark::State& st, GenInputs gen) {
using fs::path;
const auto in = gen(st.range(0));
path PP;
@@ -53,7 +54,7 @@ BENCHMARK_CAPTURE(BM_PathConstructCStr, large_string, getRandomStringInputs)
->Arg(TestNumInputs);
template <template <class...> class ItType, class GenInputs>
-void BM_PathConstructIter(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathConstructIter(benchmark::State& st, GenInputs gen) {
using fs::path;
using Iter = ItType<std::string::const_iterator>;
const auto in = gen(st.range(0));
@@ -78,7 +79,7 @@ BENCHMARK_CAPTURE(BM_PathConstructIter<forward_iterator>, large_string, getRando
->Range(8, TestNumInputs);
template <class GenInputs>
-void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathIterateMultipleTimes(benchmark::State& st, GenInputs gen) {
using fs::path;
const auto in = gen(st.range(0));
path PP;
@@ -97,7 +98,7 @@ BENCHMARK_CAPTURE(BM_PathIterateMultipleTimes, iterate_elements, getRandomString
->Range(8, TestNumInputs);
template <class GenInputs>
-void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathIterateOnce(benchmark::State& st, GenInputs gen) {
using fs::path;
const auto in = gen(st.range(0));
path PP;
@@ -117,7 +118,7 @@ BENCHMARK_CAPTURE(BM_PathIterateOnce, iterate_elements, getRandomStringInputs)
->Range(8, TestNumInputs);
template <class GenInputs>
-void BM_PathIterateOnceBackwards(benchmark::State& st, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_PathIterateOnceBackwards(benchmark::State& st, GenInputs gen) {
using fs::path;
const auto in = gen(st.range(0));
path PP;
@@ -149,7 +150,7 @@ static fs::path getRandomPaths(int NumParts, int PathLen) {
}
template <class GenInput>
-void BM_LexicallyNormal(benchmark::State& st, GenInput gen, size_t PathLen) {
+TEST_ALIGN_BENCHMARK void BM_LexicallyNormal(benchmark::State& st, GenInput gen, size_t PathLen) {
using fs::path;
auto In = gen(st.range(0), PathLen);
benchmark::DoNotOptimize(&In);
@@ -167,7 +168,7 @@ BENCHMARK_CAPTURE(BM_LexicallyNormal, large_path, getRandomPaths, /*PathLen*/ 32
->Range(2, 256);
template <class GenInput>
-void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
+TEST_ALIGN_BENCHMARK void BM_LexicallyRelative(benchmark::State& st, GenInput gen, size_t PathLen) {
auto BasePath = gen(st.range(0), PathLen);
auto TargetPath = gen(st.range(0), PathLen);
benchmark::DoNotOptimize(&BasePath);
diff --git a/libcxx/test/benchmarks/format/format.bench.cpp b/libcxx/test/benchmarks/format/format.bench.cpp
index 65caac747cbab..9dcd593ecc063 100644
--- a/libcxx/test/benchmarks/format/format.bench.cpp
+++ b/libcxx/test/benchmarks/format/format.bench.cpp
@@ -19,7 +19,7 @@
#define CSTR(S) MAKE_CSTRING(CharT, S)
template <class CharT>
-static void BM_format_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_string(benchmark::State& state) {
size_t size = state.range(0);
std::basic_string<CharT> str(size, CharT('*'));
@@ -36,7 +36,7 @@ BENCHMARK(BM_format_string<wchar_t>)->RangeMultiplier(2)->Range(1, 1 << 20);
#endif
template <class CharT>
-static void BM_string_without_formatting(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_string_without_formatting(benchmark::State& state) {
for (auto _ : state) {
benchmark::DoNotOptimize(std::format(CSTR("Hello, World!")));
}
diff --git a/libcxx/test/benchmarks/format/format_to.bench.cpp b/libcxx/test/benchmarks/format/format_to.bench.cpp
index d1cbb49cad4e2..e6fdfb482cfa0 100644
--- a/libcxx/test/benchmarks/format/format_to.bench.cpp
+++ b/libcxx/test/benchmarks/format/format_to.bench.cpp
@@ -27,7 +27,7 @@
/*** Back inserter ***/
template <class Container>
-static void BM_format_to_string_back_inserter(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_string_back_inserter(benchmark::State& state) {
using CharT = typename Container::value_type;
size_t size = state.range(0);
auto str = std::basic_string<CharT>(size, CharT('*'));
@@ -42,7 +42,7 @@ static void BM_format_to_string_back_inserter(benchmark::State& state) {
/*** Begin ***/
template <class Container>
-static void BM_format_to_string_begin(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_string_begin(benchmark::State& state) {
using CharT = typename Container::value_type;
size_t size = state.range(0);
auto str = std::basic_string<CharT>(size, CharT('*'));
@@ -57,7 +57,7 @@ static void BM_format_to_string_begin(benchmark::State& state) {
/*** Pointer ***/
template <class CharT>
-static void BM_format_to_string_span(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_string_span(benchmark::State& state) {
size_t size = state.range(0);
auto str = std::basic_string<CharT>(size, CharT('*'));
@@ -70,7 +70,7 @@ static void BM_format_to_string_span(benchmark::State& state) {
}
template <class CharT>
-static void BM_format_to_string_pointer(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_string_pointer(benchmark::State& state) {
size_t size = state.range(0);
auto str = std::basic_string<CharT>(size, CharT('*'));
diff --git a/libcxx/test/benchmarks/format/format_to_n.bench.cpp b/libcxx/test/benchmarks/format/format_to_n.bench.cpp
index 748c72f2c2866..c902a5bc225f7 100644
--- a/libcxx/test/benchmarks/format/format_to_n.bench.cpp
+++ b/libcxx/test/benchmarks/format/format_to_n.bench.cpp
@@ -27,7 +27,7 @@
/*** Back inserter ***/
template <class Container>
-static void BM_format_to_n_string_back_inserter(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_n_string_back_inserter(benchmark::State& state) {
using CharT = typename Container::value_type;
size_t size = state.range(0);
auto str = std::basic_string<CharT>(2 * size, CharT('*'));
@@ -42,7 +42,7 @@ static void BM_format_to_n_string_back_inserter(benchmark::State& state) {
/*** Begin ***/
template <class Container>
-static void BM_format_to_n_string_begin(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_n_string_begin(benchmark::State& state) {
using CharT = typename Container::value_type;
size_t size = state.range(0);
auto str = std::basic_string<CharT>(2 * size, CharT('*'));
@@ -57,7 +57,7 @@ static void BM_format_to_n_string_begin(benchmark::State& state) {
/*** Pointer ***/
template <class CharT>
-static void BM_format_to_n_string_span(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_n_string_span(benchmark::State& state) {
size_t size = state.range(0);
auto str = std::basic_string<CharT>(2 * size, CharT('*'));
@@ -70,7 +70,7 @@ static void BM_format_to_n_string_span(benchmark::State& state) {
}
template <class CharT>
-static void BM_format_to_n_string_pointer(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_n_string_pointer(benchmark::State& state) {
size_t size = state.range(0);
auto str = std::basic_string<CharT>(2 * size, CharT('*'));
diff --git a/libcxx/test/benchmarks/format/formatted_size.bench.cpp b/libcxx/test/benchmarks/format/formatted_size.bench.cpp
index 9c52f386a782a..763f4da9f3324 100644
--- a/libcxx/test/benchmarks/format/formatted_size.bench.cpp
+++ b/libcxx/test/benchmarks/format/formatted_size.bench.cpp
@@ -19,7 +19,7 @@
#define CSTR(S) MAKE_CSTRING(CharT, S)
template <class CharT>
-static void BM_formatted_size_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_formatted_size_string(benchmark::State& state) {
size_t size = state.range(0);
std::basic_string<CharT> str(size, CharT('*'));
diff --git a/libcxx/test/benchmarks/format/formatter_float.bench.cpp b/libcxx/test/benchmarks/format/formatter_float.bench.cpp
index 31a6e0a629dd3..00b44d85866ff 100644
--- a/libcxx/test/benchmarks/format/formatter_float.bench.cpp
+++ b/libcxx/test/benchmarks/format/formatter_float.bench.cpp
@@ -18,6 +18,7 @@
#include <string>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
template <class>
inline constexpr std::string to_string = "";
@@ -36,7 +37,7 @@ int main(int argc, char** argv) {
auto bm = []<class FloatingPoint>(std::type_identity<FloatingPoint>, ValueE v, std::string fmt) {
benchmark::RegisterBenchmark(
"std::format(" + to_string<FloatingPoint> + ") (value: " + value_name(v) + ", fmt: " + fmt + ")",
- [fmt, v](benchmark::State& state) {
+ [fmt, v](benchmark::State& state) TEST_ALIGN_BENCHMARK {
std::array<FloatingPoint, 1000> data = [&] {
std::array<FloatingPoint, 1000> result;
if (v == ValueE::Inf) {
diff --git a/libcxx/test/benchmarks/format/formatter_int.bench.cpp b/libcxx/test/benchmarks/format/formatter_int.bench.cpp
index 01cd1f04017b0..bd4210fadbcc1 100644
--- a/libcxx/test/benchmarks/format/formatter_int.bench.cpp
+++ b/libcxx/test/benchmarks/format/formatter_int.bench.cpp
@@ -26,7 +26,7 @@ static std::array<T, 1000> generate(std::uniform_int_distribution<T> distributio
}
template <class T>
-static void BM_Basic(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_Basic(benchmark::State& state) {
std::array data{generate<T>()};
std::array<char, 100> output;
@@ -42,7 +42,7 @@ BENCHMARK(BM_Basic<int64_t>)->Name("std::format(int64_t)");
// Ideally the low values of a 128-bit value are all dispatched to a 64-bit routine.
#ifndef TEST_HAS_NO_INT128
template <class T>
-static void BM_BasicLow(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_BasicLow(benchmark::State& state) {
using U = std::conditional_t<std::is_signed_v<T>, int64_t, uint64_t>;
std::array data{
generate<T>(std::uniform_int_distribution<T>{std::numeric_limits<U>::min(), std::numeric_limits<U>::max()})};
@@ -71,7 +71,7 @@ inline constexpr std::string to_string<uint64_t> = "uint64_t";
int main(int argc, char** argv) {
auto bm = []<class IntT>(std::type_identity<IntT>, std::string fmt) {
benchmark::RegisterBenchmark(
- "std::format(" + to_string<IntT> + ") (fmt: " + fmt + ")", [fmt](benchmark::State& state) {
+ "std::format(" + to_string<IntT> + ") (fmt: " + fmt + ")", [fmt](benchmark::State& state) TEST_ALIGN_BENCHMARK {
std::array data = generate<IntT>();
std::array<char, 512> output;
diff --git a/libcxx/test/benchmarks/format/print.bench.cpp b/libcxx/test/benchmarks/format/print.bench.cpp
index ec59189d87263..8e7eae404cf7d 100644
--- a/libcxx/test/benchmarks/format/print.bench.cpp
+++ b/libcxx/test/benchmarks/format/print.bench.cpp
@@ -15,7 +15,7 @@
#include "test_macros.h"
template <class CharT>
-static void BM_string_without_formatting(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_string_without_formatting(benchmark::State& state) {
std::FILE* devnull = std::fopen("/dev/null", "w");
for (auto _ : state) {
std::print(devnull, "Hello, World!");
@@ -25,7 +25,7 @@ BENCHMARK(BM_string_without_formatting<char>)->Name("std::print(\"Hello, World!\
#ifndef TEST_HAS_NO_UNICODE
template <class CharT>
-static void BM_string_without_formatting_opaque(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_string_without_formatting_opaque(benchmark::State& state) {
std::FILE* devnull = std::fopen("/dev/null", "w");
for (auto _ : state) {
const char* format_string = "Hello, World!";
diff --git a/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp b/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp
index eb3ffc37c882e..3ca61cbd1b7ae 100644
--- a/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp
+++ b/libcxx/test/benchmarks/format/std_format_spec_string_unicode.bench.cpp
@@ -255,27 +255,27 @@ void BM_text(benchmark::State& state, std::basic_string_view<CharT> input) {
}
template <class CharT>
-void BM_ascii_text(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_ascii_text(benchmark::State& state) {
BM_text(state, ascii_text<CharT>());
}
template <class CharT>
-void BM_unicode_text(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_unicode_text(benchmark::State& state) {
BM_text(state, unicode_text<CharT>());
}
template <class CharT>
-void BM_cyrillic_text(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_cyrillic_text(benchmark::State& state) {
BM_text(state, cyrillic_text<CharT>());
}
template <class CharT>
-void BM_japanese_text(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_japanese_text(benchmark::State& state) {
BM_text(state, japanese_text<CharT>());
}
template <class CharT>
-void BM_emoji_text(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_emoji_text(benchmark::State& state) {
BM_text(state, emoji_text<CharT>());
}
diff --git a/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp b/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp
index aa91229798903..d768f4ebcf2d8 100644
--- a/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp
+++ b/libcxx/test/benchmarks/format/std_format_spec_string_unicode_escape.bench.cpp
@@ -20,6 +20,7 @@
#include "benchmark/benchmark.h"
#include "make_string.h"
+#include "test_macros.h"
#define SV(S) MAKE_STRING_VIEW(CharT, S)
@@ -257,27 +258,27 @@ void BM_escaped(benchmark::State& state, std::basic_string_view<CharT> input) {
}
template <class CharT>
-void BM_ascii_escaped(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_ascii_escaped(benchmark::State& state) {
BM_escaped(state, ascii_text<CharT>());
}
template <class CharT>
-void BM_unicode_escaped(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_unicode_escaped(benchmark::State& state) {
BM_escaped(state, unicode_text<CharT>());
}
template <class CharT>
-void BM_cyrillic_escaped(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_cyrillic_escaped(benchmark::State& state) {
BM_escaped(state, cyrillic_text<CharT>());
}
template <class CharT>
-void BM_japanese_escaped(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_japanese_escaped(benchmark::State& state) {
BM_escaped(state, japanese_text<CharT>());
}
template <class CharT>
-void BM_emoji_escaped(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_emoji_escaped(benchmark::State& state) {
BM_escaped(state, emoji_text<CharT>());
}
diff --git a/libcxx/test/benchmarks/format/write_double_comparison.bench.cpp b/libcxx/test/benchmarks/format/write_double_comparison.bench.cpp
index 90a95ae0483c8..a40a509974b73 100644
--- a/libcxx/test/benchmarks/format/write_double_comparison.bench.cpp
+++ b/libcxx/test/benchmarks/format/write_double_comparison.bench.cpp
@@ -21,6 +21,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
std::array data = [] {
std::uniform_real_distribution<double> distribution;
@@ -30,7 +31,7 @@ std::array data = [] {
return result;
}();
-static void BM_sprintf(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_sprintf(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
@@ -39,7 +40,7 @@ static void BM_sprintf(benchmark::State& state) {
}
}
-static void BM_to_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_string(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
std::string s = std::to_string(value);
@@ -47,7 +48,7 @@ static void BM_to_string(benchmark::State& state) {
}
}
-static void BM_to_chars(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
@@ -57,7 +58,7 @@ static void BM_to_chars(benchmark::State& state) {
}
}
-static void BM_to_chars_as_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars_as_string(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
@@ -68,7 +69,7 @@ static void BM_to_chars_as_string(benchmark::State& state) {
}
}
-static void BM_format(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
std::string s = std::format("{}", value);
@@ -77,7 +78,7 @@ static void BM_format(benchmark::State& state) {
}
template <class C>
-static void BM_format_to_back_inserter(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_back_inserter(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
C c;
@@ -87,7 +88,7 @@ static void BM_format_to_back_inserter(benchmark::State& state) {
}
template <class F>
-static void BM_format_to_iterator(benchmark::State& state, F&& f) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_iterator(benchmark::State& state, F&& f) {
auto output = f();
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
diff --git a/libcxx/test/benchmarks/format/write_int_comparison.bench.cpp b/libcxx/test/benchmarks/format/write_int_comparison.bench.cpp
index 95ee2b720428e..14e7de30674d3 100644
--- a/libcxx/test/benchmarks/format/write_int_comparison.bench.cpp
+++ b/libcxx/test/benchmarks/format/write_int_comparison.bench.cpp
@@ -21,6 +21,7 @@
#include <vector>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
std::array data = [] {
std::uniform_int_distribution<int> distribution{std::numeric_limits<int>::min(), std::numeric_limits<int>::max()};
@@ -30,7 +31,7 @@ std::array data = [] {
return result;
}();
-static void BM_sprintf(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_sprintf(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
@@ -39,7 +40,7 @@ static void BM_sprintf(benchmark::State& state) {
}
}
-static void BM_to_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_string(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
std::string s = std::to_string(value);
@@ -47,7 +48,7 @@ static void BM_to_string(benchmark::State& state) {
}
}
-static void BM_to_chars(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
@@ -57,7 +58,7 @@ static void BM_to_chars(benchmark::State& state) {
}
}
-static void BM_to_chars_as_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars_as_string(benchmark::State& state) {
std::array<char, 100> output;
while (state.KeepRunningBatch(data.size()))
@@ -68,7 +69,7 @@ static void BM_to_chars_as_string(benchmark::State& state) {
}
}
-static void BM_format(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
std::string s = std::format("{}", value);
@@ -77,7 +78,7 @@ static void BM_format(benchmark::State& state) {
}
template <class C>
-static void BM_format_to_back_inserter(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_back_inserter(benchmark::State& state) {
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
C c;
@@ -87,7 +88,7 @@ static void BM_format_to_back_inserter(benchmark::State& state) {
}
template <class F>
-static void BM_format_to_iterator(benchmark::State& state, F&& f) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_iterator(benchmark::State& state, F&& f) {
auto output = f();
while (state.KeepRunningBatch(data.size()))
for (auto value : data) {
diff --git a/libcxx/test/benchmarks/format/write_string_comparison.bench.cpp b/libcxx/test/benchmarks/format/write_string_comparison.bench.cpp
index 3e76b62275547..91109ec0f5908 100644
--- a/libcxx/test/benchmarks/format/write_string_comparison.bench.cpp
+++ b/libcxx/test/benchmarks/format/write_string_comparison.bench.cpp
@@ -137,20 +137,20 @@ std::string_view string_view_6_characters = c_string_6_characters;
std::string_view string_view_60_characters = c_string_60_characters;
std::string_view string_view_6000_characters = c_string_6000_characters;
-static void BM_sprintf(benchmark::State& state, const char* value) {
+static TEST_ALIGN_BENCHMARK void BM_sprintf(benchmark::State& state, const char* value) {
std::array<char, 10'000> output;
for (auto _ : state)
benchmark::DoNotOptimize(std::sprintf(output.data(), "%s", value));
}
template <class T>
-static void BM_format(benchmark::State& state, const T& value) {
+static TEST_ALIGN_BENCHMARK void BM_format(benchmark::State& state, const T& value) {
for (auto _ : state)
benchmark::DoNotOptimize(std::format("{}", value));
}
template <class Container, class T>
-static void BM_format_to_back_inserter(benchmark::State& state, const T& value) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_back_inserter(benchmark::State& state, const T& value) {
for (auto _ : state) {
Container c;
std::format_to(std::back_inserter(c), "{}", value);
@@ -159,7 +159,7 @@ static void BM_format_to_back_inserter(benchmark::State& state, const T& value)
}
template <class T, class F>
-static void BM_format_to_iterator(benchmark::State& state, const T& value, F&& f) {
+static TEST_ALIGN_BENCHMARK void BM_format_to_iterator(benchmark::State& state, const T& value, F&& f) {
auto output = f();
for (auto _ : state) {
benchmark::DoNotOptimize(std::format_to(std::begin(output), "{}", value));
diff --git a/libcxx/test/benchmarks/hash.bench.cpp b/libcxx/test/benchmarks/hash.bench.cpp
index ca958765dc210..564382d6b553e 100644
--- a/libcxx/test/benchmarks/hash.bench.cpp
+++ b/libcxx/test/benchmarks/hash.bench.cpp
@@ -20,7 +20,7 @@
constexpr std::size_t TestNumInputs = 1024;
template <class HashFn, class GenInputs>
-void BM_Hash(benchmark::State& st, HashFn fn, GenInputs gen) {
+TEST_ALIGN_BENCHMARK void BM_Hash(benchmark::State& st, HashFn fn, GenInputs gen) {
auto in = gen(st.range(0));
const auto end = in.data() + in.size();
std::size_t last_hash = 0;
diff --git a/libcxx/test/benchmarks/iterators/distance.bench.cpp b/libcxx/test/benchmarks/iterators/distance.bench.cpp
index 78ada03fb6cc4..456a96417ddeb 100644
--- a/libcxx/test/benchmarks/iterators/distance.bench.cpp
+++ b/libcxx/test/benchmarks/iterators/distance.bench.cpp
@@ -16,6 +16,7 @@
#include <vector>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
int main(int argc, char** argv) {
auto std_distance = [](auto first, auto last) { return std::distance(first, last); };
@@ -25,7 +26,7 @@ int main(int argc, char** argv) {
auto bm = [](std::string name, auto distance) {
benchmark::RegisterBenchmark(
name,
- [distance](auto& st) {
+ [distance](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::deque<int> c(size, 1);
@@ -48,7 +49,7 @@ int main(int argc, char** argv) {
auto bm = []<class Container>(std::string name, auto distance, std::size_t seg_size) {
benchmark::RegisterBenchmark(
name,
- [distance, seg_size](auto& st) {
+ [distance, seg_size](auto& st) TEST_ALIGN_BENCHMARK {
std::size_t const size = st.range(0);
std::size_t const segments = (size + seg_size - 1) / seg_size;
Container c(segments);
diff --git a/libcxx/test/benchmarks/join_view.bench.cpp b/libcxx/test/benchmarks/join_view.bench.cpp
index 78a875ae62510..51eb37c11d973 100644
--- a/libcxx/test/benchmarks/join_view.bench.cpp
+++ b/libcxx/test/benchmarks/join_view.bench.cpp
@@ -13,6 +13,7 @@
#include <ranges>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
namespace {
void run_sizes(benchmark::Benchmark* benchmark) {
@@ -30,7 +31,7 @@ void run_sizes(benchmark::Benchmark* benchmark) {
->Arg(70000);
}
-void BM_join_view_in_vectors(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_join_view_in_vectors(benchmark::State& state) {
auto size = state.range(0);
std::vector<std::vector<int>> input(size, std::vector<int>(32));
std::ranges::fill(input | std::views::join, 10);
@@ -45,7 +46,7 @@ void BM_join_view_in_vectors(benchmark::State& state) {
}
BENCHMARK(BM_join_view_in_vectors)->Apply(run_sizes);
-void BM_join_view_out_vectors(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_join_view_out_vectors(benchmark::State& state) {
auto size = state.range(0);
std::vector<std::vector<int>> output(size, std::vector<int>(32));
std::vector<int> input;
@@ -60,7 +61,7 @@ void BM_join_view_out_vectors(benchmark::State& state) {
}
BENCHMARK(BM_join_view_out_vectors)->Apply(run_sizes);
-void BM_join_view_deques(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_join_view_deques(benchmark::State& state) {
auto size = state.range(0);
std::deque<std::deque<int>> deque(size, std::deque<int>(32));
std::ranges::fill(deque | std::views::join, 10);
diff --git a/libcxx/test/benchmarks/libcxxabi/dynamic_cast.bench.cpp b/libcxx/test/benchmarks/libcxxabi/dynamic_cast.bench.cpp
index 709bc3838eb2e..019d0c04ba3a8 100644
--- a/libcxx/test/benchmarks/libcxxabi/dynamic_cast.bench.cpp
+++ b/libcxx/test/benchmarks/libcxxabi/dynamic_cast.bench.cpp
@@ -11,6 +11,7 @@
#include <cstddef>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
template <std::size_t Depth>
struct Chain : Chain<Depth - 1> {};
@@ -45,7 +46,7 @@ struct VDag<Index, 0> {
};
template <typename Dyn, typename From, typename To = Dyn>
-static void DynCast(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void DynCast(benchmark::State& state) {
Dyn obj;
From* from_ptr = &obj;
for (auto _ : state) {
@@ -54,7 +55,7 @@ static void DynCast(benchmark::State& state) {
}
}
-static void StaticCast(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void StaticCast(benchmark::State& state) {
Chain<9> obj;
Chain<0>* from_ptr = &obj;
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/libcxxabi/dynamic_cast_old_stress.bench.cpp b/libcxx/test/benchmarks/libcxxabi/dynamic_cast_old_stress.bench.cpp
index e79d865c2ca30..be6b69856b003 100644
--- a/libcxx/test/benchmarks/libcxxabi/dynamic_cast_old_stress.bench.cpp
+++ b/libcxx/test/benchmarks/libcxxabi/dynamic_cast_old_stress.bench.cpp
@@ -13,6 +13,7 @@
#include <utility>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
template <std::size_t Indx, std::size_t Depth>
struct C : public virtual C<Indx, Depth - 1>, public virtual C<Indx + 1, Depth - 1> {
@@ -40,7 +41,7 @@ constexpr std::size_t Width = 10;
constexpr std::size_t Depth = 5;
template <typename Destination>
-void CastTo(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void CastTo(benchmark::State& state) {
A<Width, Depth> a;
auto base = static_cast<C<Width / 2, 0>*>(&a);
diff --git a/libcxx/test/benchmarks/memory/align.bench.cpp b/libcxx/test/benchmarks/memory/align.bench.cpp
index 9fb637c21f9ac..3e142e8f15e84 100644
--- a/libcxx/test/benchmarks/memory/align.bench.cpp
+++ b/libcxx/test/benchmarks/memory/align.bench.cpp
@@ -12,6 +12,7 @@
#include <iostream>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
struct Input {
std::size_t align;
@@ -20,7 +21,7 @@ struct Input {
std::size_t buffer_size;
};
-static void BM_align(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_align(benchmark::State& state) {
char buffer[1024];
Input input{};
void* ptr = buffer + 123;
diff --git a/libcxx/test/benchmarks/monotonic_buffer.bench.cpp b/libcxx/test/benchmarks/monotonic_buffer.bench.cpp
index 66ab5809985b5..fe3952b6064ab 100644
--- a/libcxx/test/benchmarks/monotonic_buffer.bench.cpp
+++ b/libcxx/test/benchmarks/monotonic_buffer.bench.cpp
@@ -12,8 +12,9 @@
#include <memory_resource>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
-static void bm_list(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_list(benchmark::State& state) {
char buffer[16384];
std::pmr::monotonic_buffer_resource resource(buffer, sizeof(buffer));
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/numeric/gcd.bench.cpp b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
index c13b36ff7e989..e2438e6ab8ca5 100644
--- a/libcxx/test/benchmarks/numeric/gcd.bench.cpp
+++ b/libcxx/test/benchmarks/numeric/gcd.bench.cpp
@@ -13,6 +13,7 @@
#include <cstring>
#include <numeric>
#include <random>
+#include "test_macros.h"
template <class T>
static std::array<T, 1000> generate(std::uniform_int_distribution<T> distribution = std::uniform_int_distribution<T>{
@@ -23,7 +24,7 @@ static std::array<T, 1000> generate(std::uniform_int_distribution<T> distributio
return result;
}
-static void bm_gcd_random(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_gcd_random(benchmark::State& state) {
std::array data = generate<int>();
while (state.KeepRunningBatch(data.size() * data.size()))
for (auto v0 : data)
@@ -32,7 +33,7 @@ static void bm_gcd_random(benchmark::State& state) {
}
BENCHMARK(bm_gcd_random)->Name("std::gcd() (random numbers)");
-static void bm_gcd_trivial(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_gcd_trivial(benchmark::State& state) {
int lhs = ~static_cast<int>(0), rhs = 1;
for (auto _ : state) {
benchmark::DoNotOptimize(lhs);
@@ -42,7 +43,7 @@ static void bm_gcd_trivial(benchmark::State& state) {
}
BENCHMARK(bm_gcd_trivial)->Name("std::gcd() (trivial inputs)");
-static void bm_gcd_complex(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_gcd_complex(benchmark::State& state) {
long long lhs = 2971215073;
long long rhs = 1836311903;
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/random.bench.cpp b/libcxx/test/benchmarks/random.bench.cpp
index 15e16b988a29f..7dfb8ca957cdd 100644
--- a/libcxx/test/benchmarks/random.bench.cpp
+++ b/libcxx/test/benchmarks/random.bench.cpp
@@ -16,11 +16,12 @@
#include <random>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
constexpr std::size_t MAX_BUFFER_LEN = 256;
constexpr std::size_t MAX_SEED_LEN = 16;
-static void BM_SeedSeq_Generate(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_SeedSeq_Generate(benchmark::State& state) {
std::array<std::uint32_t, MAX_BUFFER_LEN> buffer;
std::array<std::uint32_t, MAX_SEED_LEN> seeds;
{
@@ -35,7 +36,7 @@ static void BM_SeedSeq_Generate(benchmark::State& state) {
BENCHMARK(BM_SeedSeq_Generate)->Ranges({{1, MAX_SEED_LEN}, {1, MAX_BUFFER_LEN}});
template <class Engine>
-static void BM_engine(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_engine(benchmark::State& state) {
Engine engine;
for (auto _ : state) {
@@ -46,7 +47,7 @@ BENCHMARK(BM_engine<std::mt19937_64>)->Name("std::mt19937_64::operator()");
BENCHMARK(BM_engine<std::mt19937>)->Name("std::mt19937::operator()");
template <class Engine>
-static void BM_engine_array(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_engine_array(benchmark::State& state) {
Engine engine;
typename Engine::result_type buffer[128];
diff --git a/libcxx/test/benchmarks/shared_mutex_vs_mutex.bench.cpp b/libcxx/test/benchmarks/shared_mutex_vs_mutex.bench.cpp
index 84729ebe013df..156765e275007 100644
--- a/libcxx/test/benchmarks/shared_mutex_vs_mutex.bench.cpp
+++ b/libcxx/test/benchmarks/shared_mutex_vs_mutex.bench.cpp
@@ -23,19 +23,20 @@
#include <thread>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
int global_value = 42;
std::mutex m;
std::shared_mutex sm;
-static void BM_shared_mutex(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_shared_mutex(benchmark::State& state) {
for (auto _ : state) {
std::shared_lock<std::shared_mutex> lock(sm);
benchmark::DoNotOptimize(global_value);
}
}
-static void BM_mutex(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_mutex(benchmark::State& state) {
for (auto _ : state) {
std::lock_guard<std::mutex> lock(m);
benchmark::DoNotOptimize(global_value);
diff --git a/libcxx/test/benchmarks/stop_token.bench.cpp b/libcxx/test/benchmarks/stop_token.bench.cpp
index a386c30c6c15c..a9328a07f1646 100644
--- a/libcxx/test/benchmarks/stop_token.bench.cpp
+++ b/libcxx/test/benchmarks/stop_token.bench.cpp
@@ -15,12 +15,13 @@
#include "benchmark/benchmark.h"
#include "make_test_thread.h"
+#include "test_macros.h"
using namespace std::chrono_literals;
// We have a single thread created by std::jthread consuming the stop_token:
// polling for stop_requested.
-void BM_stop_token_single_thread_polling_stop_requested(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_stop_token_single_thread_polling_stop_requested(benchmark::State& state) {
auto thread_func = [&](std::stop_token st, std::atomic<std::uint64_t>* loop_count) {
while (!st.stop_requested()) {
// doing some work
@@ -45,7 +46,7 @@ void BM_stop_token_single_thread_polling_stop_requested(benchmark::State& state)
BENCHMARK(BM_stop_token_single_thread_polling_stop_requested)->Arg(1024)->Arg(131072)->Arg(16777216);
// We have multiple threads polling for stop_requested of the same stop_token.
-void BM_stop_token_multi_thread_polling_stop_requested(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_stop_token_multi_thread_polling_stop_requested(benchmark::State& state) {
std::atomic<bool> start{false};
auto thread_func = [&start](std::atomic<std::uint64_t>* loop_count, std::stop_token st) {
@@ -95,7 +96,7 @@ BENCHMARK(BM_stop_token_multi_thread_polling_stop_requested)->Arg(1024)->Arg(131
// We have a single thread created by std::jthread consuming the stop_token:
// registering/deregistering callbacks, one at a time.
-void BM_stop_token_single_thread_reg_unreg_callback(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_stop_token_single_thread_reg_unreg_callback(benchmark::State& state) {
auto thread_func = [&](std::stop_token st, std::atomic<std::uint64_t>* reg_count) {
while (!st.stop_requested()) {
std::stop_callback cb{st, [&]() noexcept {}};
@@ -128,7 +129,7 @@ BENCHMARK(BM_stop_token_single_thread_reg_unreg_callback)->Arg(1024)->Arg(131072
//
// Say something like each thread keeping a circular buffer of N stop-callbacks and destroying the stop-callbacks in
// FIFO order
-void BM_stop_token_async_reg_unreg_callback(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_stop_token_async_reg_unreg_callback(benchmark::State& state) {
struct dummy_stop_callback {
void operator()() const noexcept {}
};
diff --git a/libcxx/test/benchmarks/streams/copy.bench.cpp b/libcxx/test/benchmarks/streams/copy.bench.cpp
index 21cadab12abeb..79fe4b0a9876d 100644
--- a/libcxx/test/benchmarks/streams/copy.bench.cpp
+++ b/libcxx/test/benchmarks/streams/copy.bench.cpp
@@ -13,8 +13,9 @@
#include <vector>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
-static void bm_copy(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_copy(benchmark::State& state) {
std::vector<char> buffer;
buffer.resize(16384);
diff --git a/libcxx/test/benchmarks/streams/fstream.bench.cpp b/libcxx/test/benchmarks/streams/fstream.bench.cpp
index 2e16ae58749e6..b9001bd719457 100644
--- a/libcxx/test/benchmarks/streams/fstream.bench.cpp
+++ b/libcxx/test/benchmarks/streams/fstream.bench.cpp
@@ -12,8 +12,9 @@
#include <vector>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
-static void bm_ofstream_write(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_ofstream_write(benchmark::State& state) {
std::vector<char> buffer;
buffer.resize(16384);
@@ -24,7 +25,7 @@ static void bm_ofstream_write(benchmark::State& state) {
}
BENCHMARK(bm_ofstream_write)->Name("std::ofstream::write(char*, size)");
-static void bm_ifstream_read(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void bm_ifstream_read(benchmark::State& state) {
std::vector<char> buffer;
buffer.resize(16384);
diff --git a/libcxx/test/benchmarks/streams/getline.bench.cpp b/libcxx/test/benchmarks/streams/getline.bench.cpp
index 74fb4d12ae971..52ccc34508a45 100644
--- a/libcxx/test/benchmarks/streams/getline.bench.cpp
+++ b/libcxx/test/benchmarks/streams/getline.bench.cpp
@@ -12,8 +12,9 @@
#include <sstream>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
-void BM_getline_string(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_getline_string(benchmark::State& state) {
std::istringstream iss;
std::string str;
diff --git a/libcxx/test/benchmarks/stringstream.bench.cpp b/libcxx/test/benchmarks/stringstream.bench.cpp
index 367024c49ac69..052696815236d 100644
--- a/libcxx/test/benchmarks/stringstream.bench.cpp
+++ b/libcxx/test/benchmarks/stringstream.bench.cpp
@@ -74,7 +74,7 @@ struct LocaleSelector {
std::mutex LocaleSelector::mutex;
-static void BM_Istream_numbers(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_Istream_numbers(benchmark::State& state) {
LocaleSelector sel(state);
double i = 0;
while (state.KeepRunning())
@@ -82,7 +82,7 @@ static void BM_Istream_numbers(benchmark::State& state) {
}
BENCHMARK(BM_Istream_numbers)->DenseRange(0, 3);
-static void BM_Ostream_number(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_Ostream_number(benchmark::State& state) {
LocaleSelector sel(state);
while (state.KeepRunning()) {
std::ostringstream ss;
diff --git a/libcxx/test/benchmarks/system_error.bench.cpp b/libcxx/test/benchmarks/system_error.bench.cpp
index 8506efef13263..72f6f844a1f83 100644
--- a/libcxx/test/benchmarks/system_error.bench.cpp
+++ b/libcxx/test/benchmarks/system_error.bench.cpp
@@ -12,8 +12,9 @@
#include <system_error>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
-static void BM_SystemErrorWithMessage(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_SystemErrorWithMessage(benchmark::State& state) {
for (auto _ : state) {
std::error_code ec{};
benchmark::DoNotOptimize(std::system_error{ec, ""});
@@ -21,7 +22,7 @@ static void BM_SystemErrorWithMessage(benchmark::State& state) {
}
BENCHMARK(BM_SystemErrorWithMessage);
-static void BM_SystemErrorWithoutMessage(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_SystemErrorWithoutMessage(benchmark::State& state) {
for (auto _ : state) {
std::error_code ec{};
benchmark::DoNotOptimize(std::system_error{ec});
diff --git a/libcxx/test/benchmarks/text/localization/ctype.bench.cpp b/libcxx/test/benchmarks/text/localization/ctype.bench.cpp
index 2bb40ef96b61f..ad32243f83706 100644
--- a/libcxx/test/benchmarks/text/localization/ctype.bench.cpp
+++ b/libcxx/test/benchmarks/text/localization/ctype.bench.cpp
@@ -16,7 +16,7 @@
#include "test_macros.h"
template <class CharT>
-static void BM_tolower_char(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_tolower_char(benchmark::State& state) {
const auto& ct = std::use_facet<std::ctype<CharT>>(std::locale::classic());
for (auto _ : state) {
@@ -32,7 +32,7 @@ BENCHMARK(BM_tolower_char<wchar_t>);
#endif
template <class CharT>
-static void BM_tolower_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_tolower_string(benchmark::State& state) {
const auto& ct = std::use_facet<std::ctype<CharT>>(std::locale::classic());
std::basic_string<CharT> str;
@@ -49,7 +49,7 @@ BENCHMARK(BM_tolower_string<wchar_t>);
#endif
template <class CharT>
-static void BM_toupper_char(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_toupper_char(benchmark::State& state) {
const auto& ct = std::use_facet<std::ctype<CharT>>(std::locale::classic());
for (auto _ : state) {
@@ -63,7 +63,7 @@ BENCHMARK(BM_toupper_char<wchar_t>);
#endif
template <class CharT>
-static void BM_toupper_string(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_toupper_string(benchmark::State& state) {
const auto& ct = std::use_facet<std::ctype<CharT>>(std::locale::classic());
std::basic_string<CharT> str;
diff --git a/libcxx/test/benchmarks/text/localization/locale.bench.cpp b/libcxx/test/benchmarks/text/localization/locale.bench.cpp
index 60bc541bc053f..8372e878bf5a7 100644
--- a/libcxx/test/benchmarks/text/localization/locale.bench.cpp
+++ b/libcxx/test/benchmarks/text/localization/locale.bench.cpp
@@ -13,8 +13,9 @@
#include <locale>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
-static void BM_num_get(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_num_get(benchmark::State& state) {
std::locale loc1, loc2;
for (auto _ : state) {
diff --git a/libcxx/test/benchmarks/text/localization/num_get.bench.cpp b/libcxx/test/benchmarks/text/localization/num_get.bench.cpp
index cf48c0b6378ea..c0bf3ee14ef43 100644
--- a/libcxx/test/benchmarks/text/localization/num_get.bench.cpp
+++ b/libcxx/test/benchmarks/text/localization/num_get.bench.cpp
@@ -13,11 +13,12 @@
#include <locale>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
struct num_get : std::num_get<char, std::string::iterator> {};
template <class T>
-void BM_num_get(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_num_get(benchmark::State& state) {
auto val = std::string("123");
std::ios ios(nullptr);
num_get np;
diff --git a/libcxx/test/benchmarks/text/localization/num_put.bench.cpp b/libcxx/test/benchmarks/text/localization/num_put.bench.cpp
index a39bd09e190f9..329b139d74df6 100644
--- a/libcxx/test/benchmarks/text/localization/num_put.bench.cpp
+++ b/libcxx/test/benchmarks/text/localization/num_put.bench.cpp
@@ -12,11 +12,12 @@
#include <locale>
#include <benchmark/benchmark.h>
+#include "test_macros.h"
struct num_put : std::num_put<char, std::string::iterator> {};
template <class T>
-void BM_num_put(benchmark::State& state) {
+TEST_ALIGN_BENCHMARK void BM_num_put(benchmark::State& state) {
auto val = T(123);
std::ios ios(nullptr);
num_put np;
diff --git a/libcxx/test/benchmarks/to_chars.bench.cpp b/libcxx/test/benchmarks/to_chars.bench.cpp
index 58df8f21399df..51754e350f8f7 100644
--- a/libcxx/test/benchmarks/to_chars.bench.cpp
+++ b/libcxx/test/benchmarks/to_chars.bench.cpp
@@ -23,7 +23,7 @@ static const std::array<unsigned, 1000> input = [] {
return result;
}();
-static void BM_to_chars_good(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars_good(benchmark::State& state) {
char buffer[128];
int base = state.range(0);
while (state.KeepRunningBatch(input.size()))
@@ -32,7 +32,7 @@ static void BM_to_chars_good(benchmark::State& state) {
}
BENCHMARK(BM_to_chars_good)->Arg(2)->Arg(8)->Arg(10)->Arg(16)->Arg(23);
-static void BM_to_chars_bad(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_chars_bad(benchmark::State& state) {
char buffer[128];
int base = state.range(0);
struct sample {
diff --git a/libcxx/test/benchmarks/utc_clock.bench.cpp b/libcxx/test/benchmarks/utc_clock.bench.cpp
index 6ff0ec59e4b7c..e40782372fcac 100644
--- a/libcxx/test/benchmarks/utc_clock.bench.cpp
+++ b/libcxx/test/benchmarks/utc_clock.bench.cpp
@@ -14,11 +14,12 @@
#include <chrono>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
// Benchmarks the performance of the UTC <-> system time conversions. These
// operations determine the sum of leap second insertions at a specific time.
-static void BM_from_sys(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_from_sys(benchmark::State& state) {
std::chrono::sys_days date{std::chrono::July / 1 / state.range(0)};
for (auto _ : state)
benchmark::DoNotOptimize(std::chrono::utc_clock::from_sys(date));
@@ -33,7 +34,7 @@ BENCHMARK(BM_from_sys)
BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(4);
BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(16);
-static void BM_to_sys(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_to_sys(benchmark::State& state) {
// 59 sec offset means we pass th UTC offset for the leap second; assuming
// there won't be more than 59 leap seconds ever.
std::chrono::utc_seconds date{
diff --git a/libcxx/test/benchmarks/util_smartptr.bench.cpp b/libcxx/test/benchmarks/util_smartptr.bench.cpp
index 445f4693e1987..2f9b6d9d6a5d5 100644
--- a/libcxx/test/benchmarks/util_smartptr.bench.cpp
+++ b/libcxx/test/benchmarks/util_smartptr.bench.cpp
@@ -11,8 +11,9 @@
#include <memory>
#include "benchmark/benchmark.h"
+#include "test_macros.h"
-static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
+static TEST_ALIGN_BENCHMARK void BM_SharedPtrCreateDestroy(benchmark::State& st) {
while (st.KeepRunning()) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
@@ -20,7 +21,7 @@ static void BM_SharedPtrCreateDestroy(benchmark::State& st) {
}
BENCHMARK(BM_SharedPtrCreateDestroy);
-static void BM_SharedPtrIncDecRef(benchmark::State& st) {
+static TEST_ALIGN_BENCHMARK void BM_SharedPtrIncDecRef(benchmark::State& st) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
while (st.KeepRunning()) {
@@ -30,7 +31,7 @@ static void BM_SharedPtrIncDecRef(benchmark::State& st) {
}
BENCHMARK(BM_SharedPtrIncDecRef);
-static void BM_WeakPtrIncDecRef(benchmark::State& st) {
+static TEST_ALIGN_BENCHMARK void BM_WeakPtrIncDecRef(benchmark::State& st) {
auto sp = std::make_shared<int>(42);
benchmark::DoNotOptimize(sp.get());
while (st.KeepRunning()) {
diff --git a/libcxx/test/benchmarks/variant.bench.cpp b/libcxx/test/benchmarks/variant.bench.cpp
index e191aeeb00ae0..d83eee1e2b251 100644
--- a/libcxx/test/benchmarks/variant.bench.cpp
+++ b/libcxx/test/benchmarks/variant.bench.cpp
@@ -13,6 +13,7 @@
#include "benchmark/benchmark.h"
#include "GenerateInput.h"
+#include "test_macros.h"
template <std::size_t I>
struct S {
@@ -34,7 +35,7 @@ static auto genVariants(std::index_sequence<Is...>) {
}
template <std::size_t N, std::size_t Alts>
-static void BM_Visit(benchmark::State& state) {
+static TEST_ALIGN_BENCHMARK void BM_Visit(benchmark::State& state) {
auto args = genVariants<N>(std::make_index_sequence<Alts>{});
for (auto _ : state) {
benchmark::DoNotOptimize(
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index de6fa29234106..50b14743be2ee 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -574,4 +574,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_LONG_DOUBLE_IS_80_BIT
#endif
+// Align benchmark functions and never inline them to reduce changes in performance in unrelated benchmarks
+#define TEST_ALIGN_BENCHMARK __attribute__((aligned(128), noinline))
+
#endif // SUPPORT_TEST_MACROS_HPP
More information about the libcxx-commits
mailing list