diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-08-16 14:21:09 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-08-16 14:21:09 +0000 |
commit | 2e933fc077595b18de37d2ed44e8f14c6053a432 (patch) | |
tree | bb8495b7cc1d0d4881873b707e6983de9fe8bcc9 /lib/tsan/rtl/tsan_rtl_mutex.cc | |
parent | 539121b7be56780045ba1e9c0aea826626cb638a (diff) | |
download | compiler-rt-2e933fc077595b18de37d2ed44e8f14c6053a432.tar.gz compiler-rt-2e933fc077595b18de37d2ed44e8f14c6053a432.tar.bz2 compiler-rt-2e933fc077595b18de37d2ed44e8f14c6053a432.tar.xz |
tsan: support for linker initializer mutexes with static storage duration
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/tsan/rtl/tsan_rtl_mutex.cc')
-rw-r--r-- | lib/tsan/rtl/tsan_rtl_mutex.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/tsan/rtl/tsan_rtl_mutex.cc b/lib/tsan/rtl/tsan_rtl_mutex.cc index 9e7c78da..44c400b8 100644 --- a/lib/tsan/rtl/tsan_rtl_mutex.cc +++ b/lib/tsan/rtl/tsan_rtl_mutex.cc @@ -24,10 +24,12 @@ void MutexCreate(ThreadState *thr, uptr pc, uptr addr, 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 @@ void MutexDestroy(ThreadState *thr, uptr pc, uptr addr) { 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); } |