[compiler-rt] r203116 - tsan: update interface for Go

Dmitry Vyukov dvyukov at google.com
Thu Mar 6 05:17:29 PST 2014


Author: dvyukov
Date: Thu Mar  6 07:17:28 2014
New Revision: 203116

URL: http://llvm.org/viewvc/llvm-project?rev=203116&view=rev
Log:
tsan: update interface for Go
this is required to fix:
https://code.google.com/p/go/issues/detail?id=7460


Modified:
    compiler-rt/trunk/lib/tsan/go/test.c
    compiler-rt/trunk/lib/tsan/go/tsan_go.cc

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=203116&r1=203115&r2=203116&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/test.c (original)
+++ compiler-rt/trunk/lib/tsan/go/test.c Thu Mar  6 07:17:28 2014
@@ -22,7 +22,7 @@ void __tsan_read(void *thr, void *addr,
 void __tsan_write(void *thr, void *addr, void *pc);
 void __tsan_func_enter(void *thr, void *pc);
 void __tsan_func_exit(void *thr);
-void __tsan_malloc(void *thr, void *p, unsigned long sz, void *pc);
+void __tsan_malloc(void *p, unsigned long sz);
 void __tsan_acquire(void *thr, void *addr);
 void __tsan_release(void *thr, void *addr);
 void __tsan_release_merge(void *thr, void *addr);
@@ -37,10 +37,11 @@ void barfoo() {}
 int main(void) {
   void *thr0 = 0;
   char *buf = (char*)((unsigned long)buf0 + (64<<10) - 1 & ~((64<<10) - 1));
+  __tsan_malloc(buf, 10);
   __tsan_init(&thr0, symbolize_cb);
   __tsan_map_shadow(buf, 4096);
   __tsan_func_enter(thr0, (char*)&main + 1);
-  __tsan_malloc(thr0, buf, 10, 0);
+  __tsan_malloc(buf, 10);
   __tsan_release(thr0, buf);
   __tsan_release_merge(thr0, buf);
   void *thr1 = 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=203116&r1=203115&r2=203116&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/go/tsan_go.cc (original)
+++ compiler-rt/trunk/lib/tsan/go/tsan_go.cc Thu Mar  6 07:17:28 2014
@@ -85,6 +85,7 @@ ReportStack *SymbolizeCode(uptr addr) {
 extern "C" {
 
 static ThreadState *main_thr;
+static bool inited;
 
 static ThreadState *AllocGoroutine() {
   ThreadState *thr = (ThreadState*)internal_alloc(MBlockThreadContex,
@@ -98,6 +99,7 @@ void __tsan_init(ThreadState **thrp, voi
   ThreadState *thr = AllocGoroutine();
   main_thr = *thrp = thr;
   Initialize(thr);
+  inited = true;
 }
 
 void __tsan_fini() {
@@ -151,10 +153,10 @@ void __tsan_func_exit(ThreadState *thr)
   FuncExit(thr);
 }
 
-void __tsan_malloc(ThreadState *thr, void *p, uptr sz, void *pc) {
-  if (thr == 0)  // probably before __tsan_init()
+void __tsan_malloc(void *p, uptr sz) {
+  if (!inited)
     return;
-  MemoryResetRange(thr, (uptr)pc, (uptr)p, sz);
+  MemoryResetRange(0, 0, (uptr)p, sz);
 }
 
 void __tsan_go_start(ThreadState *parent, ThreadState **pthr, void *pc) {





More information about the llvm-commits mailing list