mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
0f55045526
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any project could use it for benchmark generation. A dummy benchmark is added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of the build process. The current version does not utilize LLVM LNT and LLVM CMake infrastructure, but that might be sufficient for most users. Two introduced CMake variables: * `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark targets * `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated benchmark targets to the list of default LLVM targets (i.e. if `ON` benchmarks will be built upon standard build invocation, e.g. `ninja` or `make` with no specific targets) List of modifications: * `BENCHMARK_ENABLE_TESTING` is disabled * `BENCHMARK_ENABLE_EXCEPTIONS` is disabled * `BENCHMARK_ENABLE_INSTALL` is disabled * `BENCHMARK_ENABLE_GTEST_TESTS` is disabled * `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled Original discussion can be found here: http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html Reviewed by: dberris, lebedev.ri Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines, dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D50894 llvm-svn: 340809
65 lines
1.3 KiB
C++
65 lines
1.3 KiB
C++
#include <benchmark/benchmark.h>
|
|
|
|
#ifdef __clang__
|
|
#pragma clang diagnostic ignored "-Wreturn-type"
|
|
#endif
|
|
|
|
extern "C" {
|
|
|
|
extern int ExternInt;
|
|
extern int ExternInt2;
|
|
extern int ExternInt3;
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: test_basic:
|
|
extern "C" void test_basic() {
|
|
int x;
|
|
benchmark::DoNotOptimize(&x);
|
|
x = 101;
|
|
benchmark::ClobberMemory();
|
|
// CHECK: leaq [[DEST:[^,]+]], %rax
|
|
// CHECK: movl $101, [[DEST]]
|
|
// CHECK: ret
|
|
}
|
|
|
|
// CHECK-LABEL: test_redundant_store:
|
|
extern "C" void test_redundant_store() {
|
|
ExternInt = 3;
|
|
benchmark::ClobberMemory();
|
|
ExternInt = 51;
|
|
// CHECK-DAG: ExternInt
|
|
// CHECK-DAG: movl $3
|
|
// CHECK: movl $51
|
|
}
|
|
|
|
// CHECK-LABEL: test_redundant_read:
|
|
extern "C" void test_redundant_read() {
|
|
int x;
|
|
benchmark::DoNotOptimize(&x);
|
|
x = ExternInt;
|
|
benchmark::ClobberMemory();
|
|
x = ExternInt2;
|
|
// CHECK: leaq [[DEST:[^,]+]], %rax
|
|
// CHECK: ExternInt(%rip)
|
|
// CHECK: movl %eax, [[DEST]]
|
|
// CHECK-NOT: ExternInt2
|
|
// CHECK: ret
|
|
}
|
|
|
|
// CHECK-LABEL: test_redundant_read2:
|
|
extern "C" void test_redundant_read2() {
|
|
int x;
|
|
benchmark::DoNotOptimize(&x);
|
|
x = ExternInt;
|
|
benchmark::ClobberMemory();
|
|
x = ExternInt2;
|
|
benchmark::ClobberMemory();
|
|
// CHECK: leaq [[DEST:[^,]+]], %rax
|
|
// CHECK: ExternInt(%rip)
|
|
// CHECK: movl %eax, [[DEST]]
|
|
// CHECK: ExternInt2(%rip)
|
|
// CHECK: movl %eax, [[DEST]]
|
|
// CHECK: ret
|
|
}
|