diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2017-01-07 11:27:33 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2017-01-07 11:27:33 +0000 |
commit | adc3b42fa48f90ec82806a47e827dac8df44fe27 (patch) | |
tree | 75fc6a0efc6af5f0163b2663200f44b18b1e87a2 | |
parent | cba3c85d7e7b1d394c7ec39a5738ed8719004488 (diff) | |
download | compiler-rt-adc3b42fa48f90ec82806a47e827dac8df44fe27.tar.gz |
tsan: Introducing a function to flush the shadow memory from third-party libraries
As discussed with Dmitry (https://goo.gl/SA4izd), I would like to introduce a function to be called from a third-party library to flush the shadow memory.
In particular, we ran some experiments with our tool Archer (an OpenMP data race detector based on Tsan, https://github.com/PRUNER/archer) and flushing the memory at the end of an outer parallel region, slightly increase the runtime overhead, but reduce the memory overhead of about 30%. This feature would come very handy in case of very large OpenMP applications that may cause an "out of memory" exception when checked with Tsan.
Reviewed in: https://reviews.llvm.org/D28443
Author: Simone Atzeni (simoatze)
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@291346 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/tsan/rtl/tsan.syms.extra | 1 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_interface.cc | 4 | ||||
-rw-r--r-- | lib/tsan/rtl/tsan_interface.h | 2 |
3 files changed, 7 insertions, 0 deletions
diff --git a/lib/tsan/rtl/tsan.syms.extra b/lib/tsan/rtl/tsan.syms.extra index 1bc1d9329..22dfde914 100644 --- a/lib/tsan/rtl/tsan.syms.extra +++ b/lib/tsan/rtl/tsan.syms.extra @@ -1,4 +1,5 @@ __tsan_init +__tsan_flush_memory __tsan_read* __tsan_write* __tsan_vptr* diff --git a/lib/tsan/rtl/tsan_interface.cc b/lib/tsan/rtl/tsan_interface.cc index 809d2abeb..ad9b1fe9a 100644 --- a/lib/tsan/rtl/tsan_interface.cc +++ b/lib/tsan/rtl/tsan_interface.cc @@ -28,6 +28,10 @@ void __tsan_init() { Initialize(cur_thread()); } +void __tsan_flush_memory() { + FlushShadowMemory(); +} + void __tsan_read16(void *addr) { MemoryRead(cur_thread(), CALLERPC, (uptr)addr, kSizeLog8); MemoryRead(cur_thread(), CALLERPC, (uptr)addr + 8, kSizeLog8); diff --git a/lib/tsan/rtl/tsan_interface.h b/lib/tsan/rtl/tsan_interface.h index bae01bd70..4e342a58a 100644 --- a/lib/tsan/rtl/tsan_interface.h +++ b/lib/tsan/rtl/tsan_interface.h @@ -32,6 +32,8 @@ extern "C" { // before any instrumented code is executed and before any call to malloc. SANITIZER_INTERFACE_ATTRIBUTE void __tsan_init(); +SANITIZER_INTERFACE_ATTRIBUTE void __tsan_flush_memory(); + SANITIZER_INTERFACE_ATTRIBUTE void __tsan_read1(void *addr); SANITIZER_INTERFACE_ATTRIBUTE void __tsan_read2(void *addr); SANITIZER_INTERFACE_ATTRIBUTE void __tsan_read4(void *addr); |