diff options
Diffstat (limited to 'lib/tsan/benchmarks/func_entry_exit.cpp')
-rw-r--r-- | lib/tsan/benchmarks/func_entry_exit.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/tsan/benchmarks/func_entry_exit.cpp b/lib/tsan/benchmarks/func_entry_exit.cpp new file mode 100644 index 0000000000000..5e0ba1d6981ba --- /dev/null +++ b/lib/tsan/benchmarks/func_entry_exit.cpp @@ -0,0 +1,20 @@ +// Synthetic benchmark for __tsan_func_entry/exit (spends ~75% there). + +void foo(bool x); + +int main() { + volatile int kRepeat1 = 1 << 30; + const int kRepeat = kRepeat1; + for (int i = 0; i < kRepeat; i++) + foo(false); +} + +__attribute__((noinline)) void bar(volatile bool x) { + if (x) + foo(x); +} + +__attribute__((noinline)) void foo(bool x) { + if (__builtin_expect(x, false)) + bar(x); +} |