Skip to content

Fix build issues with libc mem* benchmarks #115982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

dmpots
Copy link
Contributor

@dmpots dmpots commented Nov 13, 2024

Fix a few issues found when trying to build the benchmark:

Errors

  1. Unable to find include "src/__support/macros/config.h" in LibcMemoryBenchmarkMain.cpp

Warnings

  1. Unused variable warning Index in MemorySizeDistributions.cpp
  2. Fix deprecation warning for const-ref version of DoNotOptimize. warning: 'DoNotOptimize<void *>' is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks

Fix a few issues found when trying to build the benchmark:

Errors
1. Unable to find include "src/__support/macros/config.h" in
   LibcMemoryBenchmarkMain.cpp

Warnings
2. Unused variable warning `Index` in MemorySizeDistributions.cpp
3. Fix deprecation warning for const-ref version of `DoNotOptimize`.
   warning: 'DoNotOptimize<void *>' is deprecated: The const-ref version of this
             method can permit undesired compiler optimizations in benchmarks
@llvmbot llvmbot added the libc label Nov 13, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2024

@llvm/pr-subscribers-libc

Author: David Peixotto (dmpots)

Changes

Fix a few issues found when trying to build the benchmark:

Errors

  1. Unable to find include "src/__support/macros/config.h" in LibcMemoryBenchmarkMain.cpp

Warnings

  1. Unused variable warning Index in MemorySizeDistributions.cpp
  2. Fix deprecation warning for const-ref version of DoNotOptimize. warning: 'DoNotOptimize<void *>' is deprecated: The const-ref version of this method can permit undesired compiler optimizations in benchmarks

Full diff: https://github.com/llvm/llvm-project/pull/115982.diff

3 Files Affected:

  • (modified) libc/benchmarks/CMakeLists.txt (+1)
  • (modified) libc/benchmarks/LibcBenchmark.h (+1-1)
  • (modified) libc/benchmarks/MemorySizeDistributions.cpp (-2)
diff --git a/libc/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
index 0cff6eb12c2475..52e3f942d16ea3 100644
--- a/libc/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -126,6 +126,7 @@ add_library(libc-memory-benchmark
 target_include_directories(libc-memory-benchmark
     PUBLIC
     ${CMAKE_CURRENT_SOURCE_DIR}
+    ${LIBC_SOURCE_DIR}
 )
 target_link_libraries(libc-memory-benchmark
     PUBLIC
diff --git a/libc/benchmarks/LibcBenchmark.h b/libc/benchmarks/LibcBenchmark.h
index 0a0b40f924e68e..6b1556721e416f 100644
--- a/libc/benchmarks/LibcBenchmark.h
+++ b/libc/benchmarks/LibcBenchmark.h
@@ -211,7 +211,7 @@ BenchmarkResult benchmark(const BenchmarkOptions &Options,
     // Measuring this Batch.
     const auto StartTime = Clock.now();
     for (const auto Parameter : Batch) {
-      const auto Production = foo(Parameter);
+      auto Production = foo(Parameter);
       benchmark::DoNotOptimize(Production);
     }
     const auto EndTime = Clock.now();
diff --git a/libc/benchmarks/MemorySizeDistributions.cpp b/libc/benchmarks/MemorySizeDistributions.cpp
index c3590297445dd1..58ba31b26f04bd 100644
--- a/libc/benchmarks/MemorySizeDistributions.cpp
+++ b/libc/benchmarks/MemorySizeDistributions.cpp
@@ -185,11 +185,9 @@ ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() {
 MemorySizeDistribution
 getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
                      StringRef Name) {
-  size_t Index = 0;
   for (const auto &MSD : Distributions) {
     if (MSD.Name == Name)
       return MSD;
-    ++Index;
   }
   std::string Message;
   raw_string_ostream Stream(Message);

Copy link
Member

@nickdesaulniers nickdesaulniers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; do you need me to merge this for you?

@dmpots
Copy link
Contributor Author

dmpots commented Nov 14, 2024

LGTM; do you need me to merge this for you?

Yes, please! I do not have commit access. Thanks!

@nickdesaulniers nickdesaulniers merged commit 081a80f into llvm:main Nov 14, 2024
7 checks passed
@dmpots dmpots deleted the libc-benchmark-fix branch November 15, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants