summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-02-07 14:04:04 +0000
committerDmitry Vyukov <dvyukov@google.com>2019-02-07 14:04:04 +0000
commitbdfba86047cd8731b7c4748f16af78fddbbeebc1 (patch)
tree91947b45a1a81a25cb8620d5d49137c5222a48a3 /compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc
parent67f6d842fab6d3ac8c949721be8e131cf6b17578 (diff)
downloadbcm5719-llvm-bdfba86047cd8731b7c4748f16af78fddbbeebc1.tar.gz
bcm5719-llvm-bdfba86047cd8731b7c4748f16af78fddbbeebc1.zip
tsan: add more benchmarks
func_entry_exit.cc is for __tsan_func_entry/exit (spends ~75% there), we don't yet have any. mop.cc is for memory access functions, as compared to mini_bench_local/shared.cc this benchmark passes through deduplication logic (ContainsSameAccess). llvm-svn: 353407
Diffstat (limited to 'compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc')
-rw-r--r--compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc b/compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc
new file mode 100644
index 00000000000..5e0ba1d6981
--- /dev/null
+++ b/compiler-rt/lib/tsan/benchmarks/func_entry_exit.cc
@@ -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);
+}
OpenPOWER on IntegriCloud