Index: test-suite/trunk/MicroBenchmarks/XRay/CMakeLists.txt =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/CMakeLists.txt +++ test-suite/trunk/MicroBenchmarks/XRay/CMakeLists.txt @@ -1,23 +1,2 @@ -check_cxx_compiler_flag(-fxray-instrument COMPILER_HAS_FXRAY_INSTRUMENT) -if(ARCH STREQUAL "x86" AND COMPILER_HAS_FXRAY_INSTRUMENT) - file(COPY lit.local.cfg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - - list(APPEND CPPFLAGS -std=c++11 -Wl,--gc-sections -fxray-instrument) - list(APPEND LDFLAGS -fxray-instrument) - llvm_test_run(--benchmark_filter=dummy_skip_ignore) - llvm_test_executable(retref-bench retref-bench.cc) - target_link_libraries(retref-bench benchmark) - - file(COPY retref-bench_BM_ReturnNeverInstrumented.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY retref-bench_BM_ReturnInstrumentedUnPatched.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY retref-bench_BM_ReturnInstrumentedPatched.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY retref-bench_BM_RDTSCP_Cost.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) - file(COPY retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -endif() +add_subdirectory(ReturnReference) +add_subdirectory(FDRMode) Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/CMakeLists.txt =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/CMakeLists.txt +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/CMakeLists.txt @@ -0,0 +1,23 @@ +check_cxx_compiler_flag(-fxray-instrument COMPILER_HAS_FXRAY_INSTRUMENT) +if(ARCH STREQUAL "x86" AND COMPILER_HAS_FXRAY_INSTRUMENT) + file(COPY lit.local.cfg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + + list(APPEND CPPFLAGS -std=c++11 -Wl,--gc-sections -fxray-instrument) + list(APPEND LDFLAGS -fxray-instrument) + llvm_test_run(--benchmark_filter=dummy_skip_ignore) + llvm_test_executable(fdrmode-bench fdrmode-bench.cc) + target_link_libraries(fdrmode-bench benchmark) + + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_1_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_2_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_4_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_8_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_16_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY fdrmode-bench_BM_XRayFDRMultiThreaded_32_thread.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endif() Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc @@ -0,0 +1,86 @@ +//===- fdrmode-bench.cc - XRay Instrumentation Benchmarks ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Define benchmarks for measuring the cost of XRay instrumentation when using +// flight data recorder mode. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include "benchmark/benchmark.h" +#include "xray/xray_interface.h" +#include "xray/xray_log_interface.h" + +namespace { + +// This needs to be a global value so that the compiler doesn't end up writing +// to data on the stack. We also mark it volatile to preserve all the loads and +// stores performed on this variable. +volatile int val = 0; + +__xray::FDRLoggingOptions Options; + +} // namespace + +// We define a multi-threaded benchmark which measures the overall costs +// introduced by the XRay handlers upstream. This will exercise a tight loop +// calling a single function that practically does nothing. +[[clang::xray_always_instrument]] __attribute__((noinline)) __attribute__((weak)) int +EmptyFunction() { + return 0; +} + +volatile bool log_initialized = false; + +// Force installation of the FDR logging implementation upstream, with the +// caveat that we're writing the log out to /dev/null. +[[clang::xray_never_instrument]] void SetUpXRayFDRMultiThreaded( + benchmark::State& state) { + if (!log_initialized) { + Options.ReportErrors = true; + Options.Fd = open("/dev/null", O_WRONLY); + assert((Options.Fd != -1) && "Cannot open /dev/null!"); + __xray_log_init(getpagesize(), 1 << 16, &Options, + sizeof(__xray::FDRLoggingOptions)); + __xray_remove_customevent_handler(); + __xray_patch(); + log_initialized = true; + } +} + +[[clang::xray_never_instrument]] void TearDownXRayFDRMultiThreaded( + benchmark::State& state) { + if (log_initialized) { + log_initialized = false; + __xray_log_finalize(); + __xray_log_flushLog(); + __xray_unpatch(); + } +} + +[[clang::xray_never_instrument]] static void BM_XRayFDRMultiThreaded( + benchmark::State& state) { + if (state.thread_index == 0) { + SetUpXRayFDRMultiThreaded(state); + } + while (state.KeepRunning()) { + val = EmptyFunction(); + benchmark::DoNotOptimize(val); + } + if (state.thread_index == 0) { + TearDownXRayFDRMultiThreaded(state); + } +} + +BENCHMARK(BM_XRayFDRMultiThreaded) + ->ThreadRange(1, 32); // Number of threads + +BENCHMARK_MAIN(); Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_16_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_16_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_16_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:16$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_1_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_1_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_1_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:1$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_2_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_2_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_2_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:2$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_32_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_32_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_32_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:32$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_4_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_4_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_4_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:4$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_8_thread.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_8_thread.test +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/fdrmode-bench_BM_XRayFDRMultiThreaded_8_thread.test @@ -0,0 +1 @@ +RUN: %S/fdrmode-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_XRayFDRMultiThreaded/threads:8$ Index: test-suite/trunk/MicroBenchmarks/XRay/FDRMode/lit.local.cfg =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/FDRMode/lit.local.cfg +++ test-suite/trunk/MicroBenchmarks/XRay/FDRMode/lit.local.cfg @@ -0,0 +1,8 @@ +config.environment['XRAY_OPTIONS'] = 'patch_premain=false xray_naive_log=false xray_fdr_log=true' +test_modules = config.test_modules +if 'run' in test_modules: + # Insert microbenchmark module behind 'run' + test_modules.insert(test_modules.index('run')+1, 'microbenchmark') + # Timeit results are not useful for microbenchmarks + if 'timeit' in test_modules: + test_modules.remove('timeit') Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/CMakeLists.txt =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/CMakeLists.txt +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/CMakeLists.txt @@ -0,0 +1,23 @@ +check_cxx_compiler_flag(-fxray-instrument COMPILER_HAS_FXRAY_INSTRUMENT) +if(ARCH STREQUAL "x86" AND COMPILER_HAS_FXRAY_INSTRUMENT) + file(COPY lit.local.cfg DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + + list(APPEND CPPFLAGS -std=c++11 -Wl,--gc-sections -fxray-instrument) + list(APPEND LDFLAGS -fxray-instrument) + llvm_test_run(--benchmark_filter=dummy_skip_ignore) + llvm_test_executable(retref-bench retref-bench.cc) + target_link_libraries(retref-bench benchmark) + + file(COPY retref-bench_BM_ReturnNeverInstrumented.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY retref-bench_BM_ReturnInstrumentedUnPatched.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY retref-bench_BM_ReturnInstrumentedPatched.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY retref-bench_BM_RDTSCP_Cost.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endif() Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/lit.local.cfg =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/lit.local.cfg +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/lit.local.cfg @@ -0,0 +1,8 @@ +config.environment['XRAY_OPTIONS'] = 'patch_premain=false xray_naive_log=false' +test_modules = config.test_modules +if 'run' in test_modules: + # Insert microbenchmark module behind 'run' + test_modules.insert(test_modules.index('run')+1, 'microbenchmark') + # Timeit results are not useful for microbenchmarks + if 'timeit' in test_modules: + test_modules.remove('timeit') Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench.cc =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench.cc +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench.cc @@ -0,0 +1,117 @@ +//===- retref-bench.cc - XRay Instrumentation Benchmarks ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Define benchmarks for measuring the cost of XRay instrumentation (the sleds, +// the trampolines). +// +//===----------------------------------------------------------------------===// + +#include + +#include "benchmark/benchmark.h" +#include "xray/xray_interface.h" + +[[clang::xray_never_instrument]] __attribute__((noinline)) int +neverInstrumented() { + benchmark::ClobberMemory(); + return 0; +} + +[[clang::xray_never_instrument]] static void BM_ReturnNeverInstrumented( + benchmark::State& state) { + while (state.KeepRunning()) { + benchmark::DoNotOptimize(neverInstrumented()); + } +} + +BENCHMARK(BM_ReturnNeverInstrumented); + +[[clang::xray_always_instrument]] __attribute__((noinline)) int +alwaysInstrumented() { + benchmark::ClobberMemory(); + return 0; +} + +[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedUnPatched( + benchmark::State& state) { + __xray_unpatch(); + while (state.KeepRunning()) { + int x; + benchmark::DoNotOptimize(x = alwaysInstrumented()); + benchmark::ClobberMemory(); + } +} + +BENCHMARK(BM_ReturnInstrumentedUnPatched); + + +[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedPatchedThenUnpatched( + benchmark::State& state) { + __xray_patch(); + __xray_unpatch(); + while (state.KeepRunning()) { + int x; + benchmark::DoNotOptimize(x = alwaysInstrumented()); + benchmark::ClobberMemory(); + } +} + +BENCHMARK(BM_ReturnInstrumentedPatchedThenUnpatched); + + +[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedPatched( + benchmark::State& state) { + __xray_patch(); + while (state.KeepRunning()) { + int x; + benchmark::DoNotOptimize(alwaysInstrumented()); + benchmark::ClobberMemory(); + } +} + +BENCHMARK(BM_ReturnInstrumentedPatched); + +[[clang::xray_never_instrument]] static void BM_RDTSCP_Cost( + benchmark::State& state) { + while (state.KeepRunning()) { + unsigned cpu; + unsigned tsc; + benchmark::DoNotOptimize(tsc = __rdtscp(&cpu)); + benchmark::ClobberMemory(); + } +} + +volatile unsigned global_cpu; +volatile unsigned tsc; +[[clang::xray_never_instrument]] void benchmark_handler(int32_t, + XRayEntryType) { + unsigned cpu; + benchmark::DoNotOptimize(tsc = __rdtscp(&cpu)); + global_cpu = cpu; + benchmark::ClobberMemory(); +} + +BENCHMARK(BM_RDTSCP_Cost); + +[[clang::xray_never_instrument]] static void +BM_ReturnInstrumentedPatchedWithLogHandler(benchmark::State& state) { + __xray_set_handler(benchmark_handler); + __xray_patch(); + benchmark::ClobberMemory(); + while (state.KeepRunning()) { + int x; + benchmark::DoNotOptimize(x = alwaysInstrumented()); + benchmark::ClobberMemory(); + } + __xray_remove_handler(); +} + +BENCHMARK(BM_ReturnInstrumentedPatchedWithLogHandler); + +BENCHMARK_MAIN(); Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_RDTSCP_Cost.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_RDTSCP_Cost.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_RDTSCP_Cost.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_RDTSCP_Cost Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatched.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatched Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatchedThenUnpatched Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatchedWithLogHandler Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedUnPatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedUnPatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnInstrumentedUnPatched.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedUnPatched Index: test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnNeverInstrumented.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnNeverInstrumented.test +++ test-suite/trunk/MicroBenchmarks/XRay/ReturnReference/retref-bench_BM_ReturnNeverInstrumented.test @@ -0,0 +1 @@ +RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnNeverInstrumented Index: test-suite/trunk/MicroBenchmarks/XRay/lit.local.cfg =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/lit.local.cfg +++ test-suite/trunk/MicroBenchmarks/XRay/lit.local.cfg @@ -1,8 +0,0 @@ -config.environment['XRAY_OPTIONS'] = 'patch_premain=false xray_naive_log=false' -test_modules = config.test_modules -if 'run' in test_modules: - # Insert microbenchmark module behind 'run' - test_modules.insert(test_modules.index('run')+1, 'microbenchmark') - # Timeit results are not useful for microbenchmarks - if 'timeit' in test_modules: - test_modules.remove('timeit') Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench.cc =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench.cc +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench.cc @@ -1,117 +0,0 @@ -//===- retref-bench.cc - XRay Instrumentation Benchmarks ------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Define benchmarks for measuring the cost of XRay instrumentation (the sleds, -// the trampolines). -// -//===----------------------------------------------------------------------===// - -#include - -#include "benchmark/benchmark.h" -#include "xray/xray_interface.h" - -[[clang::xray_never_instrument]] __attribute__((noinline)) int -neverInstrumented() { - benchmark::ClobberMemory(); - return 0; -} - -[[clang::xray_never_instrument]] static void BM_ReturnNeverInstrumented( - benchmark::State& state) { - while (state.KeepRunning()) { - benchmark::DoNotOptimize(neverInstrumented()); - } -} - -BENCHMARK(BM_ReturnNeverInstrumented); - -[[clang::xray_always_instrument]] __attribute__((noinline)) int -alwaysInstrumented() { - benchmark::ClobberMemory(); - return 0; -} - -[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedUnPatched( - benchmark::State& state) { - __xray_unpatch(); - while (state.KeepRunning()) { - int x; - benchmark::DoNotOptimize(x = alwaysInstrumented()); - benchmark::ClobberMemory(); - } -} - -BENCHMARK(BM_ReturnInstrumentedUnPatched); - - -[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedPatchedThenUnpatched( - benchmark::State& state) { - __xray_patch(); - __xray_unpatch(); - while (state.KeepRunning()) { - int x; - benchmark::DoNotOptimize(x = alwaysInstrumented()); - benchmark::ClobberMemory(); - } -} - -BENCHMARK(BM_ReturnInstrumentedPatchedThenUnpatched); - - -[[clang::xray_never_instrument]] static void BM_ReturnInstrumentedPatched( - benchmark::State& state) { - __xray_patch(); - while (state.KeepRunning()) { - int x; - benchmark::DoNotOptimize(alwaysInstrumented()); - benchmark::ClobberMemory(); - } -} - -BENCHMARK(BM_ReturnInstrumentedPatched); - -[[clang::xray_never_instrument]] static void BM_RDTSCP_Cost( - benchmark::State& state) { - while (state.KeepRunning()) { - unsigned cpu; - unsigned tsc; - benchmark::DoNotOptimize(tsc = __rdtscp(&cpu)); - benchmark::ClobberMemory(); - } -} - -volatile unsigned global_cpu; -volatile unsigned tsc; -[[clang::xray_never_instrument]] void benchmark_handler(int32_t, - XRayEntryType) { - unsigned cpu; - benchmark::DoNotOptimize(tsc = __rdtscp(&cpu)); - global_cpu = cpu; - benchmark::ClobberMemory(); -} - -BENCHMARK(BM_RDTSCP_Cost); - -[[clang::xray_never_instrument]] static void -BM_ReturnInstrumentedPatchedWithLogHandler(benchmark::State& state) { - __xray_set_handler(benchmark_handler); - __xray_patch(); - benchmark::ClobberMemory(); - while (state.KeepRunning()) { - int x; - benchmark::DoNotOptimize(x = alwaysInstrumented()); - benchmark::ClobberMemory(); - } - __xray_remove_handler(); -} - -BENCHMARK(BM_ReturnInstrumentedPatchedWithLogHandler); - -BENCHMARK_MAIN(); Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_RDTSCP_Cost.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_RDTSCP_Cost.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_RDTSCP_Cost.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_RDTSCP_Cost Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatched.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatched Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedThenUnpatched.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatchedThenUnpatched Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedPatchedWithLogHandler.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedPatchedWithLogHandler Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedUnPatched.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedUnPatched.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnInstrumentedUnPatched.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnInstrumentedUnPatched Index: test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnNeverInstrumented.test =================================================================== --- test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnNeverInstrumented.test +++ test-suite/trunk/MicroBenchmarks/XRay/retref-bench_BM_ReturnNeverInstrumented.test @@ -1 +0,0 @@ -RUN: %S/retref-bench --benchmark_repetitions=10 --benchmark_report_aggregates_only=true --benchmark_filter=BM_ReturnNeverInstrumented