[TSan] Slightly improve check_analyze script.
authorAlexey Samsonov <vonosmas@gmail.com>
Mon, 7 Dec 2015 20:18:50 +0000 (20:18 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Mon, 7 Dec 2015 20:18:50 +0000 (20:18 +0000)
De-hardcode path to TSan-ified executable: pass it as an input to
the scripts. Fix them so that they don't write to the current
directory. Remove their invocation from Makefile.old: they are
broken there anyway, as check_analyze.sh now matches trunk Clang.

llvm-svn: 254936

compiler-rt/lib/tsan/Makefile.old
compiler-rt/lib/tsan/analyze_libtsan.sh
compiler-rt/lib/tsan/check_analyze.sh

index 72b472d..79f5d8a 100644 (file)
@@ -79,7 +79,6 @@ presubmit:
        $(MAKE) -f Makefile.old clean
        $(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++
        ./check_memcpy.sh
-       ./check_analyze.sh
        # Sanity check for Go runtime
        (cd go && ./buildgo.sh)
        # Check cmake build
index 705e4c5..ae29f1b 100755 (executable)
@@ -1,10 +1,17 @@
 #!/bin/bash
+#
+# Script that prints information about generated code in TSan runtime.
 
 set -e
 set -u
 
+if [[ "$#" != 1 ]]; then
+  echo "Usage: $0 /path/to/binary/built/with/tsan"
+  exit 1
+fi
+
 get_asm() {
-  grep __tsan_$1.: -A 10000 libtsan.objdump | \
+  grep __tsan_$1.: -A 10000 ${OBJDUMP_CONTENTS} | \
     awk "/[^:]$/ {print;} />:/ {c++; if (c == 2) {exit}}"
 }
 
@@ -19,15 +26,19 @@ list="write1 \
       func_entry \
       func_exit"
 
-BIN=`dirname $0`/tsan_test
-objdump -d $BIN  > libtsan.objdump
-nm -S $BIN | grep "__tsan_" > libtsan.nm
+BIN=$1
+OUTPUT_DIR=$(mktemp -t -d analyze_libtsan_out.XXXXXXXX)
+OBJDUMP_CONTENTS=${OUTPUT_DIR}/libtsan_objdump
+NM_CONTENTS=${OUTPUT_DIR}/libtsan_nm
+
+objdump -d $BIN  > ${OBJDUMP_CONTENTS}
+nm -S $BIN | grep "__tsan_" > ${NM_CONTENTS}
 
 for f in $list; do
-  file=asm_$f.s
+  file=${OUTPUT_DIR}/asm_$f.s
   get_asm $f > $file
   tot=$(wc -l < $file)
-  size=$(grep __tsan_$f$ libtsan.nm | awk --non-decimal-data '{print ("0x"$2)+0}')
+  size=$(grep __tsan_$f$ ${NM_CONTENTS} | awk --non-decimal-data '{print ("0x"$2)+0}')
   rsp=$(grep '(%rsp)' $file | wc -l)
   push=$(grep 'push' $file | wc -l)
   pop=$(grep 'pop' $file | wc -l)
index 9d45cc0..0f6cc06 100755 (executable)
@@ -1,7 +1,17 @@
 #!/bin/bash
+#
+# Script that checks that critical functions in TSan runtime have correct number
+# of push/pop/rsp instructions to verify that runtime is efficient enough.
+
 set -u
 
-RES=$(./analyze_libtsan.sh)
+if [[ "$#" != 1 ]]; then
+  echo "Usage: $0 /path/to/binary/built/with/tsan"
+  exit 1
+fi
+
+SCRIPTDIR=$(dirname $0)
+RES=$(${SCRIPTDIR}/analyze_libtsan.sh $1)
 PrintRes() {
   printf "%s\n" "$RES"
 }