forked from OSchip/llvm-project
[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
This commit is contained in:
parent
5c244115c9
commit
438f7fc068
|
@ -99,3 +99,5 @@ if(LLVM_INCLUDE_TESTS)
|
|||
add_subdirectory(test)
|
||||
add_subdirectory(fuzzing)
|
||||
endif()
|
||||
|
||||
add_subdirectory(benchmarks)
|
||||
|
|
|
@ -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)
|
|
@ -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 {
|
||||
|
|
@ -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);
|
|
@ -4,4 +4,3 @@ add_subdirectory(HdrGen)
|
|||
add_subdirectory(MPFRWrapper)
|
||||
add_subdirectory(testutils)
|
||||
add_subdirectory(UnitTest)
|
||||
add_subdirectory(benchmarks)
|
||||
|
|
Loading…
Reference in New Issue