[compiler-rt] r204326 - tsan: use stack depot for goroutine creation stacks (as C++ threads do)
Dmitry Vyukov
dvyukov at google.com
Thu Mar 20 03:19:03 PDT 2014
Author: dvyukov
Date: Thu Mar 20 05:19:02 2014
New Revision: 204326
URL: http://llvm.org/viewvc/llvm-project?rev=204326&view=rev
Log:
tsan: use stack depot for goroutine creation stacks (as C++ threads do)
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc
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=204326&r1=204325&r2=204326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Thu Mar 20 05:19:02 2014
@@ -485,11 +485,7 @@ class ThreadContext : public ThreadConte
explicit ThreadContext(int tid);
~ThreadContext();
ThreadState *thr;
-#ifdef TSAN_GO
- StackTrace creation_stack;
-#else
u32 creation_stack_id;
-#endif
SyncClock sync;
// Epoch at which the thread had started.
// If we see an event from the thread stamped by an older epoch,
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=204326&r1=204325&r2=204326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Thu Mar 20 05:19:02 2014
@@ -104,8 +104,9 @@ static void StackStripMain(ReportStack *
#endif
}
-#ifndef TSAN_GO
ReportStack *SymbolizeStackId(u32 stack_id) {
+ if (stack_id == 0)
+ return 0;
uptr ssz = 0;
const uptr *stack = StackDepotGet(stack_id, &ssz);
if (stack == 0)
@@ -114,7 +115,6 @@ ReportStack *SymbolizeStackId(u32 stack_
trace.Init(stack, ssz);
return SymbolizeStack(trace);
}
-#endif
static ReportStack *SymbolizeStack(const StackTrace& trace) {
if (trace.IsEmpty())
@@ -201,11 +201,7 @@ void ScopedReport::AddThread(const Threa
rt->name = internal_strdup(tctx->name);
rt->parent_tid = tctx->parent_tid;
rt->stack = 0;
-#ifdef TSAN_GO
- rt->stack = SymbolizeStack(tctx->creation_stack);
-#else
rt->stack = SymbolizeStackId(tctx->creation_stack_id);
-#endif
}
#ifndef TSAN_GO
@@ -266,10 +262,7 @@ void ScopedReport::AddMutex(const SyncVa
rm->id = s->uid;
rm->addr = s->addr;
rm->destroyed = false;
- rm->stack = 0;
-#ifndef TSAN_GO
rm->stack = SymbolizeStackId(s->creation_stack_id);
-#endif
}
u64 ScopedReport::AddMutex(u64 id) {
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=204326&r1=204325&r2=204326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Thu Mar 20 05:19:02 2014
@@ -59,11 +59,7 @@ void ThreadContext::OnCreated(void *arg)
// Can't increment epoch w/o writing to the trace as well.
TraceAddEvent(args->thr, args->thr->fast_state, EventTypeMop, 0);
ReleaseImpl(args->thr, 0, &sync);
-#ifdef TSAN_GO
- creation_stack.ObtainCurrent(args->thr, args->pc);
-#else
creation_stack_id = CurrentStackId(args->thr, args->pc);
-#endif
if (reuse_count == 0)
StatInc(args->thr, StatThreadMaxTid);
}
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=204326&r1=204325&r2=204326&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_sync.cc Thu Mar 20 05:19:02 2014
@@ -23,6 +23,7 @@ SyncVar::SyncVar(uptr addr, u64 uid)
: mtx(MutexTypeSyncVar, StatMtxSyncVar)
, addr(addr)
, uid(uid)
+ , creation_stack_id()
, owner_tid(kInvalidTid)
, last_lock()
, recursion()
@@ -64,9 +65,9 @@ SyncVar* SyncTab::Create(ThreadState *th
void *mem = internal_alloc(MBlockSync, sizeof(SyncVar));
const u64 uid = atomic_fetch_add(&uid_gen_, 1, memory_order_relaxed);
SyncVar *res = new(mem) SyncVar(addr, uid);
-#ifndef TSAN_GO
- res->creation_stack_id = CurrentStackId(thr, pc);
-#endif
+ res->creation_stack_id = 0;
+ if (!kGoMode) // Go does not use them
+ res->creation_stack_id = CurrentStackId(thr, pc);
if (flags()->detect_deadlocks)
DDMutexInit(thr, pc, res);
return res;
More information about the llvm-commits
mailing list