xref: /netbsd-src/sys/external/bsd/compiler_rt/dist/lib/tsan/check_analyze.sh (revision a7c257b03e4462df2b1020128fb82716512d7856)
1#!/bin/bash
2#
3# Script that checks that critical functions in TSan runtime have correct number
4# of push/pop/rsp instructions to verify that runtime is efficient enough.
5#
6# This test can fail when backend code generation changes the output for various
7# tsan interceptors. When such a change happens, you can ensure that the
8# performance has not regressed by running the following benchmarks before and
9# after the breaking change to verify that the values in this file are safe to
10# update:
11# ./projects/compiler-rt/lib/tsan/tests/rtl/TsanRtlTest-x86_64-Test
12#   --gtest_also_run_disabled_tests --gtest_filter=DISABLED_BENCH.Mop*
13
14set -u
15
16if [[ "$#" != 1 ]]; then
17  echo "Usage: $0 /path/to/binary/built/with/tsan"
18  exit 1
19fi
20
21SCRIPTDIR=$(dirname $0)
22RES=$(${SCRIPTDIR}/analyze_libtsan.sh $1)
23PrintRes() {
24  printf "%s\n" "$RES"
25}
26
27PrintRes
28
29check() {
30  res=$(PrintRes | egrep "$1 .* $2 $3; ")
31  if [ "$res" == "" ]; then
32    echo FAILED $1 must contain $2 $3
33    exit 1
34  fi
35}
36
37for f in write1 write2 write4 write8 read2 read4; do
38  check $f rsp 1
39  check $f push 1
40  check $f pop 6
41done
42
43for f in read1 read8; do
44  check $f rsp 1
45  check $f push 2
46  check $f pop 12
47done
48
49for f in func_entry func_exit; do
50  check $f rsp 0
51  check $f push 0
52  check $f pop 0
53  check $f call 1  # TraceSwitch()
54done
55
56echo LGTM
57