[PATCH] tsan: do not instrument not captured values

Dmitry Vyukov dvyukov at google.com
Tue Jan 20 08:54:20 PST 2015


Hi kcc, samsonov, eugenis,

Consider the following code:

P p;
p.x = 1;
p.y = 2;
foo(&p);

P escapes and so tsan instruments accesses to it. However, before address of the variable is actually taken, it is not shared and so cannot participate in data races. So there is no point in instrumenting these initial memory accesses.

I've built some tests in WebRTC with and without this change. With this change number of __tsan_read/write calls is reduced by 20-40%, binary size decreases by 5-10% and execution time drops by ~5%. For example:

$ ls -l old/modules_unittests new/modules_unittests
-rwxr-x--- 1 dvyukov 41708976 Jan 20 18:35 old/modules_unittests
-rwxr-x--- 1 dvyukov 38294008 Jan 20 18:29 new/modules_unittests
$ objdump -d old/modules_unittests | egrep "callq.*__tsan_(read|write|unaligned)" | wc -l
239871
$ objdump -d new/modules_unittests | egrep "callq.*__tsan_(read|write|unaligned)" | wc -l
148365

http://reviews.llvm.org/D7069

Files:
  lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  test/Instrumentation/ThreadSanitizer/capture.ll

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7069.18439.patch
Type: text/x-patch
Size: 6512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150120/8e102c02/attachment.bin>


More information about the llvm-commits mailing list