[libc-commits] [libc] 438f7fc - [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Wed Jun 17 11:43:26 PDT 2020
Author: Siva Chandra Reddy
Date: 2020-06-17T11:42:26-07:00
New Revision: 438f7fc068f9ba5555052c4af0b10f5e816c3a01
URL: https://github.com/llvm/llvm-project/commit/438f7fc068f9ba5555052c4af0b10f5e816c3a01
DIFF: https://github.com/llvm/llvm-project/commit/438f7fc068f9ba5555052c4af0b10f5e816c3a01.diff
LOG: [libc][benchmarks] Link the memory benchmark exes to functions from LLVM libc.
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
Added:
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
Modified:
libc/CMakeLists.txt
libc/utils/CMakeLists.txt
Removed:
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
################################################################################
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index b774eac6273a..58613fdae1da 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -99,3 +99,5 @@ if(LLVM_INCLUDE_TESTS)
add_subdirectory(test)
add_subdirectory(fuzzing)
endif()
+
+add_subdirectory(benchmarks)
diff --git a/libc/utils/benchmarks/CMakeLists.txt b/libc/benchmarks/CMakeLists.txt
similarity index 94%
rename from libc/utils/benchmarks/CMakeLists.txt
rename to libc/benchmarks/CMakeLists.txt
index 24741e0fdae3..6f3cfdb64a5f 100644
--- a/libc/utils/benchmarks/CMakeLists.txt
+++ b/libc/benchmarks/CMakeLists.txt
@@ -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)
diff --git a/libc/utils/benchmarks/JSON.cpp b/libc/benchmarks/JSON.cpp
similarity index 100%
rename from libc/utils/benchmarks/JSON.cpp
rename to libc/benchmarks/JSON.cpp
diff --git a/libc/utils/benchmarks/JSON.h b/libc/benchmarks/JSON.h
similarity index 100%
rename from libc/utils/benchmarks/JSON.h
rename to libc/benchmarks/JSON.h
diff --git a/libc/utils/benchmarks/JSONTest.cpp b/libc/benchmarks/JSONTest.cpp
similarity index 100%
rename from libc/utils/benchmarks/JSONTest.cpp
rename to libc/benchmarks/JSONTest.cpp
diff --git a/libc/utils/benchmarks/LibcBenchmark.cpp b/libc/benchmarks/LibcBenchmark.cpp
similarity index 100%
rename from libc/utils/benchmarks/LibcBenchmark.cpp
rename to libc/benchmarks/LibcBenchmark.cpp
diff --git a/libc/utils/benchmarks/LibcBenchmark.h b/libc/benchmarks/LibcBenchmark.h
similarity index 100%
rename from libc/utils/benchmarks/LibcBenchmark.h
rename to libc/benchmarks/LibcBenchmark.h
diff --git a/libc/utils/benchmarks/LibcBenchmarkTest.cpp b/libc/benchmarks/LibcBenchmarkTest.cpp
similarity index 100%
rename from libc/utils/benchmarks/LibcBenchmarkTest.cpp
rename to libc/benchmarks/LibcBenchmarkTest.cpp
diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.cpp b/libc/benchmarks/LibcMemoryBenchmark.cpp
similarity index 100%
rename from libc/utils/benchmarks/LibcMemoryBenchmark.cpp
rename to libc/benchmarks/LibcMemoryBenchmark.cpp
diff --git a/libc/utils/benchmarks/LibcMemoryBenchmark.h b/libc/benchmarks/LibcMemoryBenchmark.h
similarity index 100%
rename from libc/utils/benchmarks/LibcMemoryBenchmark.h
rename to libc/benchmarks/LibcMemoryBenchmark.h
diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp b/libc/benchmarks/LibcMemoryBenchmarkMain.cpp
similarity index 100%
rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.cpp
rename to libc/benchmarks/LibcMemoryBenchmarkMain.cpp
diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkMain.h b/libc/benchmarks/LibcMemoryBenchmarkMain.h
similarity index 100%
rename from libc/utils/benchmarks/LibcMemoryBenchmarkMain.h
rename to libc/benchmarks/LibcMemoryBenchmarkMain.h
diff --git a/libc/utils/benchmarks/LibcMemoryBenchmarkTest.cpp b/libc/benchmarks/LibcMemoryBenchmarkTest.cpp
similarity index 100%
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
similarity index 100%
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
similarity index 94%
rename from libc/utils/benchmarks/Memcpy.cpp
rename to libc/benchmarks/Memcpy.cpp
index ef031d3c07d7..eb3085355762 100644
--- a/libc/utils/benchmarks/Memcpy.cpp
+++ b/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 {
diff --git a/libc/utils/benchmarks/Memset.cpp b/libc/benchmarks/Memset.cpp
similarity index 89%
rename from libc/utils/benchmarks/Memset.cpp
rename to libc/benchmarks/Memset.cpp
index f891b7b79cd7..e93b057cb411 100644
--- 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 @@ 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);
diff --git a/libc/utils/benchmarks/RATIONALE.md b/libc/benchmarks/RATIONALE.md
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
similarity index 100%
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
index 8a7ee53334a4..c6e877fceef7 100644
--- a/libc/utils/CMakeLists.txt
+++ b/libc/utils/CMakeLists.txt
@@ -4,4 +4,3 @@ add_subdirectory(HdrGen)
add_subdirectory(MPFRWrapper)
add_subdirectory(testutils)
add_subdirectory(UnitTest)
-add_subdirectory(benchmarks)
More information about the libc-commits
mailing list