Commit 553491a5 by Derek Mauro Committed by Copybara-Service

Only build the section of flag_benchmark used for viewing the

disassembly under LLVM. Due to the issue described in
https://github.com/abseil/abseil-cpp/issues/1340 and
https://github.com/google/benchmark/commit/8545dfb3ea301f5c77626a046d4756ef9f2e4970
it no longer builds under GCC.

The other changes are necessary to fix the build using the latest benchmark snapshot

Fixes #1340

PiperOrigin-RevId: 494809290
Change-Id: I4a03b2e2dcbdc273e59f1f09f204322e388e7cea
parent b23ae860
......@@ -39,10 +39,10 @@ http_archive(
# Google benchmark.
http_archive(
name = "com_github_google_benchmark", # 2021-09-20T09:19:51Z
sha256 = "62e2f2e6d8a744d67e4bbc212fcfd06647080de4253c97ad5c6749e09faf2cb0",
strip_prefix = "benchmark-0baacde3618ca617da95375e0af13ce1baadea47",
urls = ["https://github.com/google/benchmark/archive/0baacde3618ca617da95375e0af13ce1baadea47.zip"],
name = "com_github_google_benchmark", # 2022-12-10T23:42:44Z
sha256 = "a62735f4f4bebc069225aa725dc68eb6836dcdbf550424b5f18e2673e7d40f2c",
strip_prefix = "benchmark-da652a748675b679947710117329e9f77f374f2d",
urls = ["https://github.com/google/benchmark/archive/da652a748675b679947710117329e9f77f374f2d.zip"],
)
# Bazel Skylib.
......
......@@ -241,10 +241,11 @@ BENCHMARK(BM_ThreadedFindCommandLineFlag)->ThreadRange(1, 16);
} // namespace
#ifdef __llvm__
// To view disassembly use: gdb ${BINARY} -batch -ex "disassemble /s $FUNC"
#define InvokeGetFlag(T) \
T AbslInvokeGetFlag##T() { return absl::GetFlag(SINGLE_FLAG(T)); } \
int odr##T = (benchmark::DoNotOptimize(AbslInvokeGetFlag##T), 1);
BENCHMARKED_TYPES(InvokeGetFlag)
// To veiw disassembly use: gdb ${BINARY} -batch -ex "disassemble /s $FUNC"
#endif // __llvm__
......@@ -34,7 +34,7 @@ static void BM_bitwidth(benchmark::State& state) {
values.push_back(absl::Uniform<T>(rng, 0, std::numeric_limits<T>::max()));
}
while (state.KeepRunningBatch(count)) {
while (state.KeepRunningBatch(static_cast<int64_t>(count))) {
for (size_t i = 0; i < count; ++i) {
benchmark::DoNotOptimize(values[i]);
}
......@@ -56,7 +56,7 @@ static void BM_bitwidth_nonzero(benchmark::State& state) {
values.push_back(absl::Uniform<T>(rng, 1, std::numeric_limits<T>::max()));
}
while (state.KeepRunningBatch(count)) {
while (state.KeepRunningBatch(static_cast<int64_t>(count))) {
for (size_t i = 0; i < count; ++i) {
const T value = values[i];
ABSL_ASSUME(value > 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment