[llvm-commits] [compiler-rt] r159856 - in /compiler-rt/trunk/lib/tsan: go/buildgo.sh go/tsan_go.cc rtl/tsan_platform.h rtl/tsan_rtl_report.cc
Dmitry Vyukov
dvyukov at google.com
Fri Jul 6 13:23:59 PDT 2012
Author: dvyukov
Date: Fri Jul 6 15:23:59 2012
New Revision: 159856
URL: http://llvm.org/viewvc/llvm-project?rev=159856&view=rev
Log:
tsan: Go language support fixes
Modified:
compiler-rt/trunk/lib/tsan/go/buildgo.sh
compiler-rt/trunk/lib/tsan/go/tsan_go.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.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=159856&r1=159855&r2=159856&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/buildgo.sh (original)
+++ compiler-rt/trunk/lib/tsan/go/buildgo.sh Fri Jul 6 15:23:59 2012
@@ -33,9 +33,9 @@
cat $F >> gotsan.cc
done
-CFLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -ffreestanding -fno-exceptions -DTSAN_GO -DSANITIZER_GO"
+CFLAGS=" -I../rtl -I../.. -I../../sanitizer_common -fPIC -g -Wall -Werror -ffreestanding -fno-exceptions -DTSAN_GO -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4"
if [ "$DEBUG" == "" ]; then
- CFLAGS+=" -DTSAN_DEBUG=0 -O3 -fno-omit-frame-pointer"
+ CFLAGS+=" -DTSAN_DEBUG=0 -O3 -fomit-frame-pointer"
else
CFLAGS+=" -DTSAN_DEBUG=1 -g"
fi
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=159856&r1=159855&r2=159856&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Fri Jul 6 15:23:59 2012
@@ -22,7 +22,7 @@
uptr opaque[sizeof(ThreadState) / sizeof(uptr) + kCacheLineSize];
};
-static ThreadStatePlaceholder *threads;
+static ThreadState *goroutines[kMaxTid];
void InitializeInterceptors() {
}
@@ -139,11 +139,15 @@
LAST_EVENT // Should not appear.
};
+static void AllocGoroutine(int tid) {
+ goroutines[tid] = (ThreadState*)internal_alloc(MBlockThreadContex,
+ sizeof(ThreadState));
+ internal_memset(goroutines[tid], 0, sizeof(ThreadState));
+}
+
void __tsan_init() {
- threads = (ThreadStatePlaceholder*)internal_alloc(MBlockThreadContex,
- kMaxTid * sizeof(ThreadStatePlaceholder));
- //!!! internal_memset(threads, 0, kMaxTid * sizeof(ThreadStatePlaceholder));
- ThreadState *thr = (ThreadState*)&threads[0];
+ AllocGoroutine(0);
+ ThreadState *thr = goroutines[0];
thr->in_rtl++;
Initialize(thr);
thr->in_rtl--;
@@ -151,7 +155,7 @@
void __tsan_fini() {
// FIXME: Not necessary thread 0.
- ThreadState *thr = (ThreadState*)&threads[0];
+ ThreadState *thr = goroutines[0];
thr->in_rtl++;
int res = Finalize(thr);
thr->in_rtl--;
@@ -159,9 +163,7 @@
}
void __tsan_event(int typ, int tid, void *pc, void *addr, int info) {
- //if (typ != READ && typ != WRITE && typ != SBLOCK_ENTER)
- // Printf("typ=%d tid=%d pc=%p addr=%p info=%d\n", typ, tid, pc, addr, info);
- ThreadState *thr = (ThreadState*)&threads[tid];
+ ThreadState *thr = goroutines[tid];
switch (typ) {
case READ:
MemoryAccess(thr, (uptr)pc, (uptr)addr, 0, false);
@@ -195,23 +197,22 @@
case FREE:
break;
case THR_START: {
- //Printf("typ=%d tid=%d pc=%p addr=%p info=%d\n", typ, tid, pc, addr, info);
if (tid == 0)
return;
- ThreadState *parent = (ThreadState*)&threads[info];
+ ThreadState *parent = goroutines[info];
+ AllocGoroutine(tid);
+ thr = goroutines[tid];
thr->in_rtl++;
parent->in_rtl++;
int tid2 = ThreadCreate(parent, (uptr)pc, 0, true);
- CHECK_EQ(tid2, tid);
ThreadStart(thr, tid2);
parent->in_rtl--;
thr->in_rtl--;
break;
}
default:
- thr->in_rtl++;
- Printf("Event: typ=%d thr=%d\n", typ, tid);
- thr->in_rtl--;
+ Printf("Unknown event type %d\n", typ);
+ Die();
}
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=159856&r1=159855&r2=159856&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Fri Jul 6 15:23:59 2012
@@ -43,7 +43,8 @@
#define MemToShadow(addr) \
(((addr) & ~(kLinuxAppMemMsk | (kShadowCell - 1))) * kShadowCnt)
#else
-#define MemToShadow(addr) (((addr) * kShadowCnt) | kLinuxShadowMsk)
+#define MemToShadow(addr) \
+ ((((addr) & ~(kShadowCell - 1)) * kShadowCnt) | kLinuxShadowMsk)
#endif
static const uptr kLinuxShadowBeg = MemToShadow(kLinuxAppMemBeg);
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=159856&r1=159855&r2=159856&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Fri Jul 6 15:23:59 2012
@@ -43,7 +43,6 @@
}
static void StackStripMain(ReportStack *stack) {
-#ifndef TSAN_GO
ReportStack *last_frame = 0;
ReportStack *last_frame2 = 0;
const char *prefix = "__interceptor_";
@@ -65,6 +64,7 @@
if (last_frame2 == 0)
return;
const char *last = last_frame->func;
+#ifndef TSAN_GO
const char *last2 = last_frame2->func;
// Strip frame above 'main'
if (last2 && 0 == internal_strcmp(last2, "main")) {
@@ -83,6 +83,9 @@
// due to our fault.
TsanPrintf("Bottom stack frame of stack %zx is missed\n", stack->pc);
}
+#else
+ if (last && 0 == internal_strcmp(last, "schedunlock"))
+ last_frame2->next = 0;
#endif
}
More information about the llvm-commits
mailing list