diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2012-07-28 15:27:41 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2012-07-28 15:27:41 +0000 |
commit | 904d3f9c06b9acf059e1bc74f11cb5e9f12c043d (patch) | |
tree | 298039352ce163b3ea90bc66d833f14d58d00c77 /compiler-rt | |
parent | 44f9b5343d840f74095c3fe98cc3d5d6a742ef02 (diff) | |
download | bcm5719-llvm-904d3f9c06b9acf059e1bc74f11cb5e9f12c043d.tar.gz bcm5719-llvm-904d3f9c06b9acf059e1bc74f11cb5e9f12c043d.zip |
tsan: add ReleaseStore() function that merely copies vector clock rather than combines two clocks
fix clock setup for finalizer goroutine (Go runtime)
llvm-svn: 160918
Diffstat (limited to 'compiler-rt')
-rwxr-xr-x | compiler-rt/lib/tsan/go/buildgo.sh | 2 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/go/test.c | 1 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/go/tsan_go.cc | 3 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_clock.cc | 16 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_clock.h | 3 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_rtl.h | 1 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc | 10 | ||||
-rw-r--r-- | compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc | 2 |
8 files changed, 31 insertions, 7 deletions
diff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh index 0015b5d60e0..a0d2f6761b4 100755 --- a/compiler-rt/lib/tsan/go/buildgo.sh +++ b/compiler-rt/lib/tsan/go/buildgo.sh @@ -74,5 +74,5 @@ echo as gotsan.s -o race_$SUFFIX.syso as gotsan.s -o race_$SUFFIX.syso gcc test.c race_$SUFFIX.syso -lpthread -o test -./test +TSAN_OPTIONS="exitcode=0" ./test diff --git a/compiler-rt/lib/tsan/go/test.c b/compiler-rt/lib/tsan/go/test.c index 5ef81be96c9..a9a5b3dbfca 100644 --- a/compiler-rt/lib/tsan/go/test.c +++ b/compiler-rt/lib/tsan/go/test.c @@ -46,7 +46,6 @@ int main(void) { __tsan_read(0, buf, 0); __tsan_free(buf); __tsan_func_exit(0); - printf("OK\n"); __tsan_fini(); return 0; } diff --git a/compiler-rt/lib/tsan/go/tsan_go.cc b/compiler-rt/lib/tsan/go/tsan_go.cc index f0e2e456fb6..4b3076c46ce 100644 --- a/compiler-rt/lib/tsan/go/tsan_go.cc +++ b/compiler-rt/lib/tsan/go/tsan_go.cc @@ -165,7 +165,7 @@ void __tsan_acquire(int goid, void *addr) { void __tsan_release(int goid, void *addr) { ThreadState *thr = goroutines[goid]; thr->in_rtl++; - Release(thr, 0, (uptr)addr); + ReleaseStore(thr, 0, (uptr)addr); thr->in_rtl--; } @@ -173,7 +173,6 @@ void __tsan_release_merge(int goid, void *addr) { ThreadState *thr = goroutines[goid]; thr->in_rtl++; Release(thr, 0, (uptr)addr); - //ReleaseMerge(thr, 0, (uptr)addr); thr->in_rtl--; } diff --git a/compiler-rt/lib/tsan/rtl/tsan_clock.cc b/compiler-rt/lib/tsan/rtl/tsan_clock.cc index 1918f8df1fa..087219211e2 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_clock.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_clock.cc @@ -88,14 +88,28 @@ void ThreadClock::release(SyncClock *dst) const { } } +void ThreadClock::ReleaseStore(SyncClock *dst) const { + DCHECK(nclk_ <= kMaxTid); + DCHECK(dst->clk_.Size() <= kMaxTid); + + if (dst->clk_.Size() < nclk_) + dst->clk_.Resize(nclk_); + for (uptr i = 0; i < nclk_; i++) + dst->clk_[i] = clk_[i]; + for (uptr i = nclk_; i < dst->clk_.Size(); i++) + dst->clk_[i] = 0; +} + void ThreadClock::acq_rel(SyncClock *dst) { acquire(dst); release(dst); } -void ThreadClock::Disable() { +void ThreadClock::Disable(unsigned tid) { + u64 c0 = clk_[tid]; for (uptr i = 0; i < kMaxTidInClock; i++) clk_[i] = (u64)-1; + clk_[tid] = c0; } SyncClock::SyncClock() diff --git a/compiler-rt/lib/tsan/rtl/tsan_clock.h b/compiler-rt/lib/tsan/rtl/tsan_clock.h index c6a8062562d..02ddb9abdb3 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_clock.h +++ b/compiler-rt/lib/tsan/rtl/tsan_clock.h @@ -61,7 +61,7 @@ struct ThreadClock { nclk_ = tid + 1; } - void Disable(); + void Disable(unsigned tid); uptr size() const { return nclk_; @@ -70,6 +70,7 @@ struct ThreadClock { void acquire(const SyncClock *src); void release(SyncClock *dst) const; void acq_rel(SyncClock *dst); + void ReleaseStore(SyncClock *dst) const; private: uptr nclk_; diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h index 40643516f32..c559cb2f080 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h @@ -449,6 +449,7 @@ void MutexReadOrWriteUnlock(ThreadState *thr, uptr pc, uptr addr); void Acquire(ThreadState *thr, uptr pc, uptr addr); void Release(ThreadState *thr, uptr pc, uptr addr); +void ReleaseStore(ThreadState *thr, uptr pc, uptr addr); // The hacky call uses custom calling convention and an assembly thunk. // It is considerably faster that a normal call for the caller diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc index 959001ca612..882def83565 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc @@ -207,4 +207,14 @@ void Release(ThreadState *thr, uptr pc, uptr addr) { s->mtx.Unlock(); } +void ReleaseStore(ThreadState *thr, uptr pc, uptr addr) { + CHECK_GT(thr->in_rtl, 0); + DPrintf("#%d: ReleaseStore %zx\n", thr->tid, addr); + SyncVar *s = CTX()->synctab.GetAndLock(thr, pc, addr, true); + thr->clock.set(thr->tid, thr->fast_state.epoch()); + thr->clock.ReleaseStore(&s->clock); + StatInc(thr, StatSyncRelease); + s->mtx.Unlock(); +} + } // namespace __tsan diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc index 65449ffd99f..f7d5f13dca7 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc +++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc @@ -299,7 +299,7 @@ void ThreadDetach(ThreadState *thr, uptr pc, int tid) { } void ThreadFinalizerGoroutine(ThreadState *thr) { - thr->clock.Disable(); + thr->clock.Disable(thr->tid); } void MemoryAccessRange(ThreadState *thr, uptr pc, uptr addr, |