[llvm-commits] [compiler-rt] r160918 - in /compiler-rt/trunk/lib/tsan: go/buildgo.sh go/test.c go/tsan_go.cc rtl/tsan_clock.cc rtl/tsan_clock.h rtl/tsan_rtl.h rtl/tsan_rtl_mutex.cc rtl/tsan_rtl_thread.cc
Dmitry Vyukov
dvyukov at google.com
Sat Jul 28 08:27:42 PDT 2012
Author: dvyukov
Date: Sat Jul 28 10:27:41 2012
New Revision: 160918
URL: http://llvm.org/viewvc/llvm-project?rev=160918&view=rev
Log:
tsan: add ReleaseStore() function that merely copies vector clock rather than combines two clocks
fix clock setup for finalizer goroutine (Go runtime)
Modified:
compiler-rt/trunk/lib/tsan/go/buildgo.sh
compiler-rt/trunk/lib/tsan/go/test.c
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_clock.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_clock.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.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=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Sat Jul 28 10:27:41 2012
@@ -74,5 +74,5 @@
as gotsan.s -o race_$SUFFIX.syso
gcc test.c race_$SUFFIX.syso -lpthread -o test
-./test
+TSAN_OPTIONS="exitcode=0" ./test
Modified: compiler-rt/trunk/lib/tsan/go/test.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/test.c?rev=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/test.c (original)
+++ compiler-rt/trunk/lib/tsan/go/test.c Sat Jul 28 10:27:41 2012
@@ -46,7 +46,6 @@
__tsan_read(0, buf, 0);
__tsan_free(buf);
__tsan_func_exit(0);
- printf("OK\n");
__tsan_fini();
return 0;
}
Modified: compiler-rt/trunk/lib/tsan/go/tsan_go.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/go/tsan_go.cc?rev=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Sat Jul 28 10:27:41 2012
@@ -165,7 +165,7 @@
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 @@
ThreadState *thr = goroutines[goid];
thr->in_rtl++;
Release(thr, 0, (uptr)addr);
- //ReleaseMerge(thr, 0, (uptr)addr);
thr->in_rtl--;
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_clock.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_clock.cc?rev=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_clock.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_clock.cc Sat Jul 28 10:27:41 2012
@@ -88,14 +88,28 @@
}
}
+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()
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_clock.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_clock.h?rev=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_clock.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_clock.h Sat Jul 28 10:27:41 2012
@@ -61,7 +61,7 @@
nclk_ = tid + 1;
}
- void Disable();
+ void Disable(unsigned tid);
uptr size() const {
return nclk_;
@@ -70,6 +70,7 @@
void acquire(const SyncClock *src);
void release(SyncClock *dst) const;
void acq_rel(SyncClock *dst);
+ void ReleaseStore(SyncClock *dst) const;
private:
uptr nclk_;
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Sat Jul 28 10:27:41 2012
@@ -449,6 +449,7 @@
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
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=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_mutex.cc Sat Jul 28 10:27:41 2012
@@ -207,4 +207,14 @@
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
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=160918&r1=160917&r2=160918&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Sat Jul 28 10:27:41 2012
@@ -299,7 +299,7 @@
}
void ThreadFinalizerGoroutine(ThreadState *thr) {
- thr->clock.Disable();
+ thr->clock.Disable(thr->tid);
}
void MemoryAccessRange(ThreadState *thr, uptr pc, uptr addr,
More information about the llvm-commits
mailing list