[libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.
authorSiva Chandra Reddy <sivachandra@google.com>
Mon, 15 Jun 2020 20:54:53 +0000 (13:54 -0700)
committerSiva Chandra Reddy <sivachandra@google.com>
Wed, 17 Jun 2020 18:42:26 +0000 (11:42 -0700)
Summary:
To get the target order correct, the benchmarks directory has been moved
one level higher. Previously, it was living in the utils directory. The
utils directory is a collection of utils which are to be used by the
tests and implementations. However, benchmarks *use* the
implementations. So, moving it out of utils helps us setup proper
target level dependencies.

Reviewers: gchatelet

Differential Revision: https://reviews.llvm.org/D81910

22 files changed:
libc/CMakeLists.txt
libc/benchmarks/CMakeLists.txt [moved from libc/utils/benchmarks/CMakeLists.txt with 94% similarity]
libc/benchmarks/JSON.cpp [moved from libc/utils/benchmarks/JSON.cpp with 100% similarity]
libc/benchmarks/JSON.h [moved from libc/utils/benchmarks/JSON.h with 100% similarity]
libc/benchmarks/JSONTest.cpp [moved from libc/utils/benchmarks/JSONTest.cpp with 100% similarity]
libc/benchmarks/LibcBenchmark.cpp [moved from libc/utils/benchmarks/LibcBenchmark.cpp with 100% similarity]
libc/benchmarks/LibcBenchmark.h [moved from libc/utils/benchmarks/LibcBenchmark.h with 100% similarity]
libc/benchmarks/LibcBenchmarkTest.cpp [moved from libc/utils/benchmarks/LibcBenchmarkTest.cpp with 100% similarity]
libc/benchmarks/LibcMemoryBenchmark.cpp [moved from libc/utils/benchmarks/LibcMemoryBenchmark.cpp with 100% similarity]
libc/benchmarks/LibcMemoryBenchmark.h [moved from libc/utils/benchmarks/LibcMemoryBenchmark.h with 100% similarity]
libc/benchmarks/LibcMemoryBenchmarkMain.cpp [moved from libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp with 100% similarity]
libc/benchmarks/LibcMemoryBenchmarkMain.h [moved from libc/utils/benchmarks/LibcMemoryBenchmarkMain.h with 100% similarity]
libc/benchmarks/LibcMemoryBenchmarkTest.cpp [moved from libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp with 100% similarity]
libc/benchmarks/Memcmp.cpp [moved from libc/utils/benchmarks/Memcmp.cpp with 100% similarity]
libc/benchmarks/Memcpy.cpp [moved from libc/utils/benchmarks/Memcpy.cpp with 94% similarity]
libc/benchmarks/Memset.cpp [moved from libc/utils/benchmarks/Memset.cpp with 89% similarity]
libc/benchmarks/RATIONALE.md [moved from libc/utils/benchmarks/RATIONALE.md with 100% similarity]
libc/benchmarks/README.md [moved from libc/utils/benchmarks/README.md with 100% similarity]
libc/benchmarks/configuration_big.json [moved from libc/utils/benchmarks/configuration_big.json with 100% similarity]
libc/benchmarks/configuration_small.json [moved from libc/utils/benchmarks/configuration_small.json with 100% similarity]
libc/benchmarks/render.py3 [moved from libc/utils/benchmarks/render.py3 with 100% similarity]
libc/utils/CMakeLists.txt

index b774eac..58613fd 100644 (file)
@@ -99,3 +99,5 @@ if(LLVM_INCLUDE_TESTS)
   add_subdirectory(test)
   add_subdirectory(fuzzing)
 endif()
+
+add_subdirectory(benchmarks)
similarity index 94%
rename from libc/utils/benchmarks/CMakeLists.txt
rename to libc/benchmarks/CMakeLists.txt
index 24741e0..6f3cfdb 100644 (file)
@@ -174,7 +174,7 @@ function(add_libc_benchmark_configuration target configuration)
     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 @@ function(add_libc_benchmark name file)
         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)
similarity index 94%
rename from libc/utils/benchmarks/Memcpy.cpp
rename to libc/benchmarks/Memcpy.cpp
index ef031d3..eb30853 100644 (file)
 #include "llvm/Support/raw_ostream.h"
 #include <memory>
 
+namespace __llvm_libc {
+extern void *memcpy(void *__restrict, const void *__restrict, size_t);
+} // namespace __llvm_libc
+
 namespace llvm {
 namespace libc_benchmarks {
 
similarity index 89%
rename from libc/utils/benchmarks/Memset.cpp
rename to libc/benchmarks/Memset.cpp
index f891b7b..e93b057 100644 (file)
 #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 @@ struct MemsetContext : public BenchmarkRunner {
 
   BenchmarkResult benchmark(const BenchmarkOptions &Options,
                             StringRef FunctionName, size_t Size) override {
-    FunctionPrototype Function =
-        StringSwitch<FunctionPrototype>(FunctionName).Case("memset", &::memset);
+    FunctionPrototype Function = StringSwitch<FunctionPrototype>(FunctionName)
+                                     .Case("memset", &__llvm_libc::memset);
     return llvm::libc_benchmarks::benchmark(
         Options, PP, [this, Function, Size](ParameterType p) {
           Function(DstBuffer + p.DstOffset, MemsetValue, Size);
index 8a7ee53..c6e877f 100644 (file)
@@ -4,4 +4,3 @@ add_subdirectory(HdrGen)
 add_subdirectory(MPFRWrapper)
 add_subdirectory(testutils)
 add_subdirectory(UnitTest)
-add_subdirectory(benchmarks)