Skip to content

Commit 081a80f

Browse files
authored
Fix build issues with libc mem* benchmarks (#115982)
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
1 parent 7d20ea9 commit 081a80f

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

libc/benchmarks/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ add_library(libc-memory-benchmark
126126
target_include_directories(libc-memory-benchmark
127127
PUBLIC
128128
${CMAKE_CURRENT_SOURCE_DIR}
129+
${LIBC_SOURCE_DIR}
129130
)
130131
target_link_libraries(libc-memory-benchmark
131132
PUBLIC

libc/benchmarks/LibcBenchmark.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ BenchmarkResult benchmark(const BenchmarkOptions &Options,
211211
// Measuring this Batch.
212212
const auto StartTime = Clock.now();
213213
for (const auto Parameter : Batch) {
214-
const auto Production = foo(Parameter);
214+
auto Production = foo(Parameter);
215215
benchmark::DoNotOptimize(Production);
216216
}
217217
const auto EndTime = Clock.now();

libc/benchmarks/MemorySizeDistributions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ ArrayRef<MemorySizeDistribution> getMemcmpSizeDistributions() {
185185
MemorySizeDistribution
186186
getDistributionOrDie(ArrayRef<MemorySizeDistribution> Distributions,
187187
StringRef Name) {
188-
size_t Index = 0;
189-
for (const auto &MSD : Distributions) {
188+
for (const auto &MSD : Distributions)
190189
if (MSD.Name == Name)
191190
return MSD;
192-
++Index;
193-
}
191+
194192
std::string Message;
195193
raw_string_ostream Stream(Message);
196194
Stream << "Unknown MemorySizeDistribution '" << Name

0 commit comments

Comments
 (0)