[compiler-rt] r291346 - tsan: Introducing a function to flush the shadow memory from third-party libraries

Dmitry Vyukov via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 7 03:27:33 PST 2017


Author: dvyukov
Date: Sat Jan  7 05:27:33 2017
New Revision: 291346

URL: http://llvm.org/viewvc/llvm-project?rev=291346&view=rev
Log:
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)


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan.syms.extra
    compiler-rt/trunk/lib/tsan/rtl/tsan_interface.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_interface.h

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan.syms.extra
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan.syms.extra?rev=291346&r1=291345&r2=291346&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan.syms.extra (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan.syms.extra Sat Jan  7 05:27:33 2017
@@ -1,4 +1,5 @@
 __tsan_init
+__tsan_flush_memory
 __tsan_read*
 __tsan_write*
 __tsan_vptr*

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface.cc?rev=291346&r1=291345&r2=291346&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface.cc Sat Jan  7 05:27:33 2017
@@ -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);

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interface.h?rev=291346&r1=291345&r2=291346&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interface.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interface.h Sat Jan  7 05:27:33 2017
@@ -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);




More information about the llvm-commits mailing list