61 lines · bash
1#!/usr/bin/env bash2#3# Script that checks that critical functions in TSan runtime have correct number4# 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 various7# tsan interceptors. When such a change happens, you can ensure that the8# performance has not regressed by running the following benchmarks before and9# after the breaking change to verify that the values in this file are safe to10# update:11# ./projects/compiler-rt/lib/tsan/tests/rtl/TsanRtlTest-x86_64-Test12# --gtest_also_run_disabled_tests --gtest_filter=DISABLED_BENCH.Mop*13 14set -u15 16if [[ "$#" != 1 ]]; then17 echo "Usage: $0 /path/to/binary/built/with/tsan"18 exit 119fi20 21SCRIPTDIR=$(dirname $0)22RES=$(${SCRIPTDIR}/analyze_libtsan.sh $1)23PrintRes() {24 printf "%s\n" "$RES"25}26 27PrintRes28 29check() {30 res=$(PrintRes | egrep "$1 .* $2 $3; ")31 if [ "$res" == "" ]; then32 echo FAILED $1 must contain $2 $333 exit 134 fi35}36 37# All hot functions must contain no PUSH/POP38# and no CALLs (everything is tail-called).39for f in write1 write2 write4 write8; do40 check $f rsp 141 check $f push 042 check $f pop 043 check $f call 044done45 46for f in read1 read2 read4 read8; do47 check $f rsp 148 check $f push 049 check $f pop 050 check $f call 051done52 53for f in func_entry func_exit; do54 check $f rsp 055 check $f push 056 check $f pop 057 check $f call 058done59 60echo LGTM61