[llvm-commits] [compiler-rt] r162021 - in /compiler-rt/trunk/lib/tsan/rtl: tsan_rtl_mutex.cc tsan_sync.cc tsan_sync.h

Dmitry Vyukov dvyukov at google.com
Thu Aug 16 07:21:09 PDT 2012


Author: dvyukov
Date: Thu Aug 16 09:21:09 2012
New Revision: 162021

URL: http://llvm.org/viewvc/llvm-project?rev=162021&view=rev
Log:
tsan: support for linker initializer mutexes with static storage duration

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc?rev=162021&r1=162020&r2=162021&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc Thu Aug 16 09:21:09 2012
@@ -24,10 +24,12 @@
   CHECK_GT(thr->in_rtl, 0);
   DPrintf("#%d: MutexCreate %zx\n", thr->tid, addr);
   StatInc(thr, StatMutexCreate);
-  MemoryWrite1Byte(thr, pc, addr);
+  if (!linker_init)
+    MemoryWrite1Byte(thr, pc, addr);
   SyncVar *s = ctx->synctab.GetAndLock(thr, pc, addr, true);
   s->is_rw = rw;
   s->is_recursive = recursive;
+  s->is_linker_init = linker_init;
   s->mtx.Unlock();
 }
 
@@ -36,16 +38,18 @@
   CHECK_GT(thr->in_rtl, 0);
   DPrintf("#%d: MutexDestroy %zx\n", thr->tid, addr);
   StatInc(thr, StatMutexDestroy);
-  MemoryWrite1Byte(thr, pc, addr);
   SyncVar *s = ctx->synctab.GetAndRemove(thr, pc, addr);
   if (s == 0)
     return;
-  if (s->owner_tid != SyncVar::kInvalidTid && !s->is_broken) {
-    s->is_broken = true;
-    ScopedReport rep(ReportTypeMutexDestroyLocked);
-    rep.AddMutex(s);
-    rep.AddLocation(s->addr, 1);
-    OutputReport(rep);
+  if (!s->is_linker_init) {
+    MemoryWrite1Byte(thr, pc, addr);
+    if (s->owner_tid != SyncVar::kInvalidTid && !s->is_broken) {
+      s->is_broken = true;
+      ScopedReport rep(ReportTypeMutexDestroyLocked);
+      rep.AddMutex(s);
+      rep.AddLocation(s->addr, 1);
+      OutputReport(rep);
+    }
   }
   DestroyAndFree(s);
 }

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc?rev=162021&r1=162020&r2=162021&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc Thu Aug 16 09:21:09 2012
@@ -24,7 +24,8 @@
   , recursion()
   , is_rw()
   , is_recursive()
-  , is_broken() {
+  , is_broken()
+  , is_linker_init() {
 }
 
 SyncTab::Part::Part()

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h?rev=162021&r1=162020&r2=162021&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.h Thu Aug 16 09:21:09 2012
@@ -64,6 +64,7 @@
   bool is_rw;
   bool is_recursive;
   bool is_broken;
+  bool is_linker_init;
   SyncVar *next;  // In SyncTab hashtable.
 
   uptr GetMemoryConsumption();





More information about the llvm-commits mailing list