diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -99,3 +99,5 @@ add_subdirectory(test) add_subdirectory(fuzzing) endif() + +add_subdirectory(benchmarks) diff --git a/libc/utils/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt rename from libc/utils/benchmarks/CMakeLists.txt rename to libc/benchmarks/CMakeLists.txt --- a/libc/utils/benchmarks/CMakeLists.txt +++ b/libc/benchmarks/CMakeLists.txt @@ -174,7 +174,7 @@ add_libc_benchmark_analysis(${conf_target} ${run_target}) endfunction() -function(add_libc_benchmark name file) +function(add_libc_benchmark name file entrypoint_target) set(libc_target libc-${name}-benchmark) add_executable(${libc_target} EXCLUDE_FROM_ALL @@ -182,12 +182,13 @@ LibcMemoryBenchmarkMain.h LibcMemoryBenchmarkMain.cpp ) - target_link_libraries(${libc_target} PUBLIC json) + + get_target_property(entrypoint_object_file ${entrypoint_target} "OBJECT_FILE_RAW") + target_link_libraries(${libc_target} PUBLIC json ${entrypoint_object_file}) foreach(configuration "small" "big") add_libc_benchmark_configuration(${libc_target} ${configuration}) endforeach() endfunction() -add_libc_benchmark(memcpy Memcpy.cpp) -add_libc_benchmark(memcmp Memcmp.cpp) -add_libc_benchmark(memset Memset.cpp) +add_libc_benchmark(memcpy Memcpy.cpp libc.src.string.memcpy) +add_libc_benchmark(memset Memset.cpp libc.src.string.memset) diff --git a/libc/utils/benchmarks/JSON.h b/libc/benchmarks/JSON.h rename from libc/utils/benchmarks/JSON.h rename to libc/benchmarks/JSON.h diff --git a/libc/utils/benchmarks/JSON.cpp b/libc/benchmarks/JSON.cpp rename from libc/utils/benchmarks/JSON.cpp rename to libc/benchmarks/JSON.cpp diff --git a/libc/utils/benchmarks/JSONTest.cpp b/libc/benchmarks/JSONTest.cpp rename from libc/utils/benchmarks/JSONTest.cpp rename to libc/benchmarks/JSONTest.cpp diff --git a/libc/utils/benchmarks/LibcBenchmark.h b/libc/benchmarks/LibcBenchmark.h rename from libc/utils/benchmarks/LibcBenchmark.h rename to libc/benchmarks/LibcBenchmark.h diff --git a/libc/utils/benchmarks/LibcBenchmark.cpp b/libc/benchmarks/LibcBenchmark.cpp rename from libc/utils/benchmarks/LibcBenchmark.cpp rename to libc/benchmarks/LibcBenchmark.cpp diff --git a/libc/utils/benchmarks/LibcBenchmarkTest.cpp b/libc/benchmarks/LibcBenchmarkTest.cpp rename from libc/utils/benchmarks/LibcBenchmarkTest.cpp rename to libc/benchmarks/LibcBenchmarkTest.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.h b/libc/benchmarks/LibcMemoryBenchmark.h rename from libc/utils/benchmarks/LibcMemoryBenchmark.h rename to libc/benchmarks/LibcMemoryBenchmark.h diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp rename from libc/utils/benchmarks/LibcMemoryBenchmark.cpp rename to libc/benchmarks/LibcMemoryBenchmark.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.h b/libc/benchmarks/LibcMemoryBenchmarkMain.h rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.h rename to libc/benchmarks/LibcMemoryBenchmarkMain.h diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp rename to libc/benchmarks/LibcMemoryBenchmarkMain.cpp diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp rename from libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp rename to libc/benchmarks/LibcMemoryBenchmarkTest.cpp diff --git a/libc/utils/benchmarks/Memcmp.cpp b/libc/benchmarks/Memcmp.cpp rename from libc/utils/benchmarks/Memcmp.cpp rename to libc/benchmarks/Memcmp.cpp diff --git a/libc/utils/benchmarks/Memcpy.cpp b/libc/benchmarks/Memcpy.cpp rename from libc/utils/benchmarks/Memcpy.cpp rename to libc/benchmarks/Memcpy.cpp --- a/libc/utils/benchmarks/Memcpy.cpp +++ b/libc/benchmarks/Memcpy.cpp @@ -13,6 +13,10 @@ #include "llvm/Support/raw_ostream.h" #include +namespace __llvm_libc { +extern void *memcpy(void *__restrict, const void *__restrict, size_t); +} // namespace __llvm_libc + namespace llvm { namespace libc_benchmarks { diff --git a/libc/utils/benchmarks/Memset.cpp b/libc/benchmarks/Memset.cpp rename from libc/utils/benchmarks/Memset.cpp rename to libc/benchmarks/Memset.cpp --- a/libc/utils/benchmarks/Memset.cpp +++ b/libc/benchmarks/Memset.cpp @@ -12,6 +12,10 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/raw_ostream.h" +namespace __llvm_libc { +void *memset(void *, int, size_t); +} // namespace __llvm_libc + namespace llvm { namespace libc_benchmarks { @@ -41,8 +45,8 @@ BenchmarkResult benchmark(const BenchmarkOptions &Options, StringRef FunctionName, size_t Size) override { - FunctionPrototype Function = - StringSwitch(FunctionName).Case("memset", &::memset); + FunctionPrototype Function = StringSwitch(FunctionName) + .Case("memset", &__llvm_libc::memset); return llvm::libc_benchmarks::benchmark( Options, PP, [this, Function, Size](ParameterType p) { Function(DstBuffer + p.DstOffset, MemsetValue, Size); diff --git a/libc/utils/benchmarks/RATIONALE.md b/libc/benchmarks/RATIONALE.md rename from libc/utils/benchmarks/RATIONALE.md rename to libc/benchmarks/RATIONALE.md diff --git a/libc/utils/benchmarks/README.md b/libc/benchmarks/README.md rename from libc/utils/benchmarks/README.md rename to libc/benchmarks/README.md diff --git a/libc/utils/benchmarks/configuration_big.json b/libc/benchmarks/configuration_big.json rename from libc/utils/benchmarks/configuration_big.json rename to libc/benchmarks/configuration_big.json diff --git a/libc/utils/benchmarks/configuration_small.json b/libc/benchmarks/configuration_small.json rename from libc/utils/benchmarks/configuration_small.json rename to libc/benchmarks/configuration_small.json diff --git a/libc/utils/benchmarks/render.py3 b/libc/benchmarks/render.py3 rename from libc/utils/benchmarks/render.py3 rename to libc/benchmarks/render.py3 diff --git a/libc/utils/CMakeLists.txt b/libc/utils/CMakeLists.txt --- a/libc/utils/CMakeLists.txt +++ b/libc/utils/CMakeLists.txt @@ -4,4 +4,3 @@ add_subdirectory(MPFRWrapper) add_subdirectory(testutils) add_subdirectory(UnitTest) -add_subdirectory(benchmarks)