[tsan] Detect races on modifying accesses in Swift code
authorKuba Mracek <mracek@apple.com>
Wed, 3 May 2017 16:51:01 +0000 (16:51 +0000)
committerKuba Mracek <mracek@apple.com>
Wed, 3 May 2017 16:51:01 +0000 (16:51 +0000)
commita7cad4fcb7434e42d1387477c42a7546b9f27259
treeede770d135177ee69617e5e41b8fc225d609dd3b
parent03ccf91d85ba1084d9071d5c912855ee1410e4ae
[tsan] Detect races on modifying accesses in Swift code

This patch allows the Swift compiler to emit calls to `__tsan_external_write` before starting any modifying access, which will cause TSan to detect races on arrays, dictionaries and other classes defined in non-instrumented modules. Races on collections from the Swift standard library and user-defined structs and a frequent cause of subtle bugs and it's important that TSan detects those on top of existing LLVM IR instrumentation, which already detects races in direct memory accesses.

Differential Revision: https://reviews.llvm.org/D31630

llvm-svn: 302050
compiler-rt/include/sanitizer/tsan_interface.h
compiler-rt/lib/tsan/rtl/tsan_defs.h
compiler-rt/lib/tsan/rtl/tsan_external.cc
compiler-rt/lib/tsan/rtl/tsan_interface.h
compiler-rt/lib/tsan/rtl/tsan_report.cc
compiler-rt/lib/tsan/rtl/tsan_report.h
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/test/tsan/Darwin/external-dups.cc
compiler-rt/test/tsan/Darwin/external-swift.cc [new file with mode: 0644]
compiler-rt/test/tsan/Darwin/external.cc