tsan: address several review comments
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@168789 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/tsan/rtl/tsan_defs.h b/lib/tsan/rtl/tsan_defs.h
index 2ffe2ef..6d8e9cf 100644
--- a/lib/tsan/rtl/tsan_defs.h
+++ b/lib/tsan/rtl/tsan_defs.h
@@ -25,8 +25,12 @@
namespace __tsan {
#ifdef TSAN_GO
+const bool kGoMode = true;
+const bool kCppMode = false;
const char *const kTsanOptionsEnv = "GORACE";
#else
+const bool kGoMode = false;
+const bool kCppMode = true;
const char *const kTsanOptionsEnv = "TSAN_OPTIONS";
#endif
diff --git a/lib/tsan/rtl/tsan_flags.cc b/lib/tsan/rtl/tsan_flags.cc
index 942d392..e3a18da 100644
--- a/lib/tsan/rtl/tsan_flags.cc
+++ b/lib/tsan/rtl/tsan_flags.cc
@@ -56,11 +56,7 @@
f->stop_on_start = false;
f->running_on_valgrind = false;
f->external_symbolizer_path = "";
- f->history_size = 2;
-
-#ifdef TSAN_GO
- f->history_size = 1; // There are a lot of goroutines.
-#endif
+ f->history_size = kGoMode ? 1 : 2; // There are a lot of goroutines in Go.
// Let a frontend override.
OverrideFlags(f);
diff --git a/lib/tsan/rtl/tsan_flags.h b/lib/tsan/rtl/tsan_flags.h
index 41a8a78..86c2af5 100644
--- a/lib/tsan/rtl/tsan_flags.h
+++ b/lib/tsan/rtl/tsan_flags.h
@@ -69,7 +69,7 @@
// Path to external symbolizer.
const char *external_symbolizer_path;
// Per-thread history size, controls how many previous memory accesses
- // is remembered per thread. Possible values are [0..7].
+ // are remembered per thread. Possible values are [0..7].
// history_size=0 amounts to 32K memory accesses. Each next value doubles
// the amount of memory accesses, up to history_size=7 that amounts to
// 4M memory accesses. The default value is 2 (128K memory accesses).
diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h
index 79075f0..eab2af5 100644
--- a/lib/tsan/rtl/tsan_rtl.h
+++ b/lib/tsan/rtl/tsan_rtl.h
@@ -568,8 +568,8 @@
void ALWAYS_INLINE INLINE TraceAddEvent(ThreadState *thr, FastState fs,
EventType typ, uptr addr) {
StatInc(thr, StatEvents);
- u64 epoch = fs.GetTracePos();
- if (UNLIKELY((epoch % kTracePartSize) == 0)) {
+ u64 pos = fs.GetTracePos();
+ if (UNLIKELY((pos % kTracePartSize) == 0)) {
#ifndef TSAN_GO
HACKY_CALL(__tsan_trace_switch);
#else
@@ -577,7 +577,7 @@
#endif
}
Event *trace = (Event*)GetThreadTrace(fs.tid());
- Event *evp = &trace[epoch];
+ Event *evp = &trace[pos];
Event ev = (u64)addr | ((u64)typ << 61);
*evp = ev;
}