[compiler-rt] r229581 - [TSan] Provide default values for compile definitions.

Alexey Samsonov vonosmas at gmail.com
Tue Feb 17 15:23:10 PST 2015


Author: samsonov
Date: Tue Feb 17 17:23:10 2015
New Revision: 229581

URL: http://llvm.org/viewvc/llvm-project?rev=229581&view=rev
Log:
[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.

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=229581&r1=229580&r2=229581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Tue Feb 17 17:23:10 2015
@@ -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;

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=229581&r1=229580&r2=229581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Tue Feb 17 17:23:10 2015
@@ -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

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=229581&r1=229580&r2=229581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Tue Feb 17 17:23:10 2015
@@ -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
 }
 
 
-#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
 }

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=229581&r1=229580&r2=229581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Tue Feb 17 17:23:10 2015
@@ -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;

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=229581&r1=229580&r2=229581&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Tue Feb 17 17:23:10 2015
@@ -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++)





More information about the llvm-commits mailing list