[compiler-rt] r254936 - [TSan] Slightly improve check_analyze script.
Alexey Samsonov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 12:18:51 PST 2015
Author: samsonov
Date: Mon Dec 7 14:18:50 2015
New Revision: 254936
URL: http://llvm.org/viewvc/llvm-project?rev=254936&view=rev
Log:
[TSan] Slightly improve check_analyze script.
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.
Modified:
compiler-rt/trunk/lib/tsan/Makefile.old
compiler-rt/trunk/lib/tsan/analyze_libtsan.sh
compiler-rt/trunk/lib/tsan/check_analyze.sh
Modified: compiler-rt/trunk/lib/tsan/Makefile.old
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/Makefile.old?rev=254936&r1=254935&r2=254936&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/Makefile.old (original)
+++ compiler-rt/trunk/lib/tsan/Makefile.old Mon Dec 7 14:18:50 2015
@@ -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
Modified: compiler-rt/trunk/lib/tsan/analyze_libtsan.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/analyze_libtsan.sh?rev=254936&r1=254935&r2=254936&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/analyze_libtsan.sh (original)
+++ compiler-rt/trunk/lib/tsan/analyze_libtsan.sh Mon Dec 7 14:18:50 2015
@@ -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)
Modified: compiler-rt/trunk/lib/tsan/check_analyze.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/check_analyze.sh?rev=254936&r1=254935&r2=254936&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/check_analyze.sh (original)
+++ compiler-rt/trunk/lib/tsan/check_analyze.sh Mon Dec 7 14:18:50 2015
@@ -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"
}
More information about the llvm-commits
mailing list