summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-02-17 23:23:10 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-02-17 23:23:10 +0000
commite194dfa6be88729d7de7f1fee77072eb55b55e77 (patch)
tree2165edd4671713fc9613501e806fa641d02f0217 /compiler-rt
parent8c77768609010c760c266f5ee7c753e4158ed037 (diff)
downloadbcm5719-llvm-e194dfa6be88729d7de7f1fee77072eb55b55e77.tar.gz
bcm5719-llvm-e194dfa6be88729d7de7f1fee77072eb55b55e77.zip
[TSan] Provide default values for compile definitions.
Provide defaults for TSAN_COLLECT_STATS and TSAN_NO_HISTORY. Replace #ifdef directives with #if. This fixes a bug introduced in r229112, where building TSan runtime with -DTSAN_COLLECT_STATS=0 would still enable stats collection and reporting. llvm-svn: 229581
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_defs.h11
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.h8
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc2
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_stat.cc2
5 files changed, 17 insertions, 8 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_defs.h b/compiler-rt/lib/tsan/rtl/tsan_defs.h
index 971178d8a3e..910a483127d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_defs.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_defs.h
@@ -18,6 +18,15 @@
#include "sanitizer_common/sanitizer_libc.h"
#include "tsan_stat.h"
+// Setup defaults for compile definitions.
+#ifndef TSAN_NO_HISTORY
+# define TSAN_NO_HISTORY 0
+#endif
+
+#ifndef TSAN_COLLECT_STATS
+# define TSAN_COLLECT_STATS 0
+#endif
+
namespace __tsan {
#ifdef SANITIZER_GO
@@ -63,7 +72,7 @@ const uptr kMetaShadowCell = 8;
// Size of a single meta shadow value (u32).
const uptr kMetaShadowSize = 4;
-#if defined(TSAN_NO_HISTORY) && TSAN_NO_HISTORY
+#if TSAN_NO_HISTORY
const bool kCollectHistory = false;
#else
const bool kCollectHistory = true;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
index 4317894a4e6..0d2c70bbc72 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cc
@@ -397,7 +397,7 @@ int Finalize(ThreadState *thr) {
failed = OnFinalize(failed);
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
StatAggregate(ctx->stat, thr->stat);
StatOutput(ctx->stat);
#endif
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 440d60ae2d5..570c8d6d40e 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -351,7 +351,7 @@ struct ThreadState {
Vector<JmpBuf> jmp_bufs;
int ignore_interceptors;
#endif
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
u64 stat[StatCnt];
#endif
const int tid;
@@ -543,18 +543,18 @@ void ObtainCurrentStack(ThreadState *thr, uptr toppc, StackTraceTy *stack) {
}
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
void StatAggregate(u64 *dst, u64 *src);
void StatOutput(u64 *stat);
#endif
void ALWAYS_INLINE StatInc(ThreadState *thr, StatType typ, u64 n = 1) {
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
thr->stat[typ] += n;
#endif
}
void ALWAYS_INLINE StatSet(ThreadState *thr, StatType typ, u64 n) {
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
thr->stat[typ] = n;
#endif
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
index 3ca9793e699..8ed1fbf2eda 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
@@ -145,7 +145,7 @@ void ThreadContext::OnFinished() {
AllocatorThreadFinish(thr);
#endif
thr->~ThreadState();
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
StatAggregate(ctx->stat, thr->stat);
#endif
thr = 0;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_stat.cc b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
index 203ee1d5f3b..15fa43d6f8a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_stat.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_stat.cc
@@ -15,7 +15,7 @@
namespace __tsan {
-#ifdef TSAN_COLLECT_STATS
+#if TSAN_COLLECT_STATS
void StatAggregate(u64 *dst, u64 *src) {
for (int i = 0; i < StatCnt; i++)
OpenPOWER on IntegriCloud