mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +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
53 lines
1.2 KiB
C++
53 lines
1.2 KiB
C++
#include "benchmark/benchmark.h"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace {
|
|
#if defined(__GNUC__)
|
|
std::uint64_t double_up(const std::uint64_t x) __attribute__((const));
|
|
#endif
|
|
std::uint64_t double_up(const std::uint64_t x) { return x * 2; }
|
|
}
|
|
|
|
// Using DoNotOptimize on types like BitRef seem to cause a lot of problems
|
|
// with the inline assembly on both GCC and Clang.
|
|
struct BitRef {
|
|
int index;
|
|
unsigned char &byte;
|
|
|
|
public:
|
|
static BitRef Make() {
|
|
static unsigned char arr[2] = {};
|
|
BitRef b(1, arr[0]);
|
|
return b;
|
|
}
|
|
private:
|
|
BitRef(int i, unsigned char& b) : index(i), byte(b) {}
|
|
};
|
|
|
|
int main(int, char*[]) {
|
|
// this test verifies compilation of DoNotOptimize() for some types
|
|
|
|
char buffer8[8] = "";
|
|
benchmark::DoNotOptimize(buffer8);
|
|
|
|
char buffer20[20] = "";
|
|
benchmark::DoNotOptimize(buffer20);
|
|
|
|
char buffer1024[1024] = "";
|
|
benchmark::DoNotOptimize(buffer1024);
|
|
benchmark::DoNotOptimize(&buffer1024[0]);
|
|
|
|
int x = 123;
|
|
benchmark::DoNotOptimize(x);
|
|
benchmark::DoNotOptimize(&x);
|
|
benchmark::DoNotOptimize(x += 42);
|
|
|
|
benchmark::DoNotOptimize(double_up(x));
|
|
|
|
// These tests are to e
|
|
benchmark::DoNotOptimize(BitRef::Make());
|
|
BitRef lval = BitRef::Make();
|
|
benchmark::DoNotOptimize(lval);
|
|
}
|