[libcxx-commits] [libcxx] [libc++] Make benchmarks forward-compatible with the test suite (PR #114502)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 1 05:39:01 PDT 2024


================
@@ -19,7 +21,8 @@ static void bm_lexicographical_compare(benchmark::State& state) {
   for (auto _ : state) {
     benchmark::DoNotOptimize(vec1);
     benchmark::DoNotOptimize(vec2);
-    benchmark::DoNotOptimize(std::lexicographical_compare(vec1.begin(), vec1.end(), vec2.begin(), vec2.end()));
+    bool result = std::lexicographical_compare(vec1.begin(), vec1.end(), vec2.begin(), vec2.end());
+    benchmark::DoNotOptimize(result);
----------------
ldionne wrote:

`DoNotOptimize` shouldn't be called with a temporary. A warning is emitted, but before running this stuff as part of the test suite, we just ignore that warning. After, it gets turned into an error.

https://github.com/llvm/llvm-project/pull/114502


More information about the libcxx-commits mailing list