[compiler-rt] r229396 - tsan: remove everything related to rss/background thread in Go mode

Dmitry Vyukov dvyukov at google.com
Mon Feb 16 06:49:34 PST 2015


Author: dvyukov
Date: Mon Feb 16 08:49:34 2015
New Revision: 229396

URL: http://llvm.org/viewvc/llvm-project?rev=229396&view=rev
Log:
tsan: remove everything related to rss/background thread in Go mode

In Go mode the background thread is not started (internal_thread_start is empty).
There is no sense in having this code compiled in.
Also removes dependency on sanitizer_linux_libcdep.cc which is good,
ideally Go runtime does not depend on libc at all.


Modified:
    compiler-rt/trunk/lib/tsan/go/buildgo.sh
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc

Modified: compiler-rt/trunk/lib/tsan/go/buildgo.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/buildgo.sh?rev=229396&r1=229395&r2=229396&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Mon Feb 16 08:49:34 2015
@@ -45,7 +45,6 @@ if [ "`uname -a | grep Linux`" != "" ];
 		../../sanitizer_common/sanitizer_procmaps_common.cc
 		../../sanitizer_common/sanitizer_procmaps_linux.cc
 		../../sanitizer_common/sanitizer_linux.cc
-		../../sanitizer_common/sanitizer_linux_libcdep.cc
 		../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
 	"
 elif [ "`uname -a | grep FreeBSD`" != "" ]; then
@@ -60,7 +59,6 @@ elif [ "`uname -a | grep FreeBSD`" != ""
                 ../../sanitizer_common/sanitizer_procmaps_common.cc
                 ../../sanitizer_common/sanitizer_procmaps_freebsd.cc
                 ../../sanitizer_common/sanitizer_linux.cc
-                ../../sanitizer_common/sanitizer_linux_libcdep.cc
                 ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
         "
 elif [ "`uname -a | grep Darwin`" != "" ]; then

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=229396&r1=229395&r2=229396&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Mon Feb 16 08:49:34 2015
@@ -126,6 +126,7 @@ ThreadState::ThreadState(Context *ctx, i
 {
 }
 
+#ifndef SANITIZER_GO
 static void MemoryProfiler(Context *ctx, fd_t fd, int i) {
   uptr n_threads;
   uptr n_running_threads;
@@ -136,13 +137,11 @@ static void MemoryProfiler(Context *ctx,
 }
 
 static void BackgroundThread(void *arg) {
-#ifndef SANITIZER_GO
   // This is a non-initialized non-user thread, nothing to see here.
   // We don't use ScopedIgnoreInterceptors, because we want ignores to be
   // enabled even when the thread function exits (e.g. during pthread thread
   // shutdown code).
   cur_thread()->ignore_interceptors++;
-#endif
   const u64 kMs2Ns = 1000 * 1000;
 
   fd_t mprof_fd = kInvalidFd;
@@ -200,7 +199,6 @@ static void BackgroundThread(void *arg)
     if (mprof_fd != kInvalidFd)
       MemoryProfiler(ctx, mprof_fd, i);
 
-#ifndef SANITIZER_GO
     // Flush symbolizer cache if requested.
     if (flags()->flush_symbolizer_ms > 0) {
       u64 last = atomic_load(&ctx->last_symbolize_time_ns,
@@ -212,7 +210,6 @@ static void BackgroundThread(void *arg)
         atomic_store(&ctx->last_symbolize_time_ns, 0, memory_order_relaxed);
       }
     }
-#endif
   }
 }
 
@@ -220,7 +217,6 @@ static void StartBackgroundThread() {
   ctx->background_thread = internal_start_thread(&BackgroundThread, 0);
 }
 
-#ifndef SANITIZER_GO
 static void StopBackgroundThread() {
   atomic_store(&ctx->stop_background_thread, 1, memory_order_relaxed);
   internal_join_thread(ctx->background_thread);
@@ -334,9 +330,7 @@ void Initialize(ThreadState *thr) {
 #ifndef SANITIZER_GO
   InitializeLibIgnore();
   Symbolizer::GetOrInit()->AddHooks(EnterSymbolizer, ExitSymbolizer);
-#endif
   StartBackgroundThread();
-#ifndef SANITIZER_GO
   SetSandboxingCallback(StopBackgroundThread);
 #endif
   if (common_flags()->detect_deadlocks)
@@ -431,7 +425,7 @@ void ForkChildAfter(ThreadState *thr, up
   VPrintf(1, "ThreadSanitizer: forked new process with pid %d,"
       " parent had %d threads\n", (int)internal_getpid(), (int)nthread);
   if (nthread == 1) {
-    internal_start_thread(&BackgroundThread, 0);
+    StartBackgroundThread();
   } else {
     // We've just forked a multi-threaded process. We cannot reasonably function
     // after that (some mutexes may be locked before fork). So just enable

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=229396&r1=229395&r2=229396&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Mon Feb 16 08:49:34 2015
@@ -241,6 +241,7 @@ void ThreadStart(ThreadState *thr, int t
   uptr stk_size = 0;
   uptr tls_addr = 0;
   uptr tls_size = 0;
+#ifndef SANITIZER_GO
   GetThreadStackAndTls(tid == 0, &stk_addr, &stk_size, &tls_addr, &tls_size);
 
   if (tid) {
@@ -261,6 +262,7 @@ void ThreadStart(ThreadState *thr, int t
           thr_end, tls_addr + tls_size - thr_end);
     }
   }
+#endif
 
   ThreadRegistry *tr = ctx->thread_registry;
   OnStartedArgs args = { thr, stk_addr, stk_size, tls_addr, tls_size };





More information about the llvm-commits mailing list