[libc-commits] [PATCH] D81910: [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 17 11:51:20 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG438f7fc068f9: [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc. (authored by sivachandra).

Changed prior to commit:
  https://reviews.llvm.org/D81910?vs=270970&id=271429#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81910/new/

https://reviews.llvm.org/D81910

Files:
  libc/CMakeLists.txt
  libc/benchmarks/CMakeLists.txt
  libc/benchmarks/JSON.cpp
  libc/benchmarks/JSON.h
  libc/benchmarks/JSONTest.cpp
  libc/benchmarks/LibcBenchmark.cpp
  libc/benchmarks/LibcBenchmark.h
  libc/benchmarks/LibcBenchmarkTest.cpp
  libc/benchmarks/LibcMemoryBenchmark.cpp
  libc/benchmarks/LibcMemoryBenchmark.h
  libc/benchmarks/LibcMemoryBenchmarkMain.cpp
  libc/benchmarks/LibcMemoryBenchmarkMain.h
  libc/benchmarks/LibcMemoryBenchmarkTest.cpp
  libc/benchmarks/Memcmp.cpp
  libc/benchmarks/Memcpy.cpp
  libc/benchmarks/Memset.cpp
  libc/benchmarks/RATIONALE.md
  libc/benchmarks/README.md
  libc/benchmarks/configuration_big.json
  libc/benchmarks/configuration_small.json
  libc/benchmarks/render.py3
  libc/utils/CMakeLists.txt
  libc/utils/benchmarks/CMakeLists.txt
  libc/utils/benchmarks/JSON.cpp
  libc/utils/benchmarks/JSON.h
  libc/utils/benchmarks/JSONTest.cpp
  libc/utils/benchmarks/LibcBenchmark.cpp
  libc/utils/benchmarks/LibcBenchmark.h
  libc/utils/benchmarks/LibcBenchmarkTest.cpp
  libc/utils/benchmarks/LibcMemoryBenchmark.cpp
  libc/utils/benchmarks/LibcMemoryBenchmark.h
  libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp
  libc/utils/benchmarks/LibcMemoryBenchmarkMain.h
  libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp
  libc/utils/benchmarks/Memcmp.cpp
  libc/utils/benchmarks/Memcpy.cpp
  libc/utils/benchmarks/Memset.cpp
  libc/utils/benchmarks/RATIONALE.md
  libc/utils/benchmarks/README.md
  libc/utils/benchmarks/configuration_big.json
  libc/utils/benchmarks/configuration_small.json
  libc/utils/benchmarks/render.py3


Index: libc/utils/CMakeLists.txt
===================================================================
--- libc/utils/CMakeLists.txt
+++ libc/utils/CMakeLists.txt
@@ -4,4 +4,3 @@
 add_subdirectory(MPFRWrapper)
 add_subdirectory(testutils)
 add_subdirectory(UnitTest)
-add_subdirectory(benchmarks)
Index: libc/benchmarks/Memset.cpp
===================================================================
--- libc/benchmarks/Memset.cpp
+++ 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<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: libc/benchmarks/Memcpy.cpp
===================================================================
--- libc/benchmarks/Memcpy.cpp
+++ libc/benchmarks/Memcpy.cpp
@@ -13,6 +13,10 @@
 #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 {
 
Index: libc/benchmarks/CMakeLists.txt
===================================================================
--- libc/benchmarks/CMakeLists.txt
+++ 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)
Index: libc/CMakeLists.txt
===================================================================
--- libc/CMakeLists.txt
+++ libc/CMakeLists.txt
@@ -99,3 +99,5 @@
   add_subdirectory(test)
   add_subdirectory(fuzzing)
 endif()
+
+add_subdirectory(benchmarks)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81910.271429.patch
Type: text/x-patch
Size: 3178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200617/99dc9de3/attachment.bin>


More information about the libc-commits mailing list