tsan: remove TSAN_SHADOW_COUNT

TSAN_SHADOW_COUNT is defined to 4 in all environments.
Other values of TSAN_SHADOW_COUNT were never tested and
were broken by recent changes to shadow mapping.
Remove it as there is no reason to fix nor maintain it.

llvm-svn: 226466
This commit is contained in:
Dmitry Vyukov 2015-01-19 15:01:07 +00:00
parent f9b1730d41
commit cc5e40811b
5 changed files with 9 additions and 80 deletions

View File

@ -1,4 +1,4 @@
type tsan_go.cc ..\rtl\tsan_interface_atomic.cc ..\rtl\tsan_clock.cc ..\rtl\tsan_flags.cc ..\rtl\tsan_md5.cc ..\rtl\tsan_mutex.cc ..\rtl\tsan_report.cc ..\rtl\tsan_rtl.cc ..\rtl\tsan_rtl_mutex.cc ..\rtl\tsan_rtl_report.cc ..\rtl\tsan_rtl_thread.cc ..\rtl\tsan_stat.cc ..\rtl\tsan_suppressions.cc ..\rtl\tsan_sync.cc ..\rtl\tsan_stack_trace.cc ..\..\sanitizer_common\sanitizer_allocator.cc ..\..\sanitizer_common\sanitizer_common.cc ..\..\sanitizer_common\sanitizer_flags.cc ..\..\sanitizer_common\sanitizer_stacktrace.cc ..\..\sanitizer_common\sanitizer_libc.cc ..\..\sanitizer_common\sanitizer_printf.cc ..\..\sanitizer_common\sanitizer_suppressions.cc ..\..\sanitizer_common\sanitizer_thread_registry.cc ..\rtl\tsan_platform_windows.cc ..\..\sanitizer_common\sanitizer_win.cc ..\..\sanitizer_common\sanitizer_deadlock_detector1.cc ..\..\sanitizer_common\sanitizer_stackdepot.cc ..\..\sanitizer_common\sanitizer_persistent_allocator.cc > gotsan.cc type tsan_go.cc ..\rtl\tsan_interface_atomic.cc ..\rtl\tsan_clock.cc ..\rtl\tsan_flags.cc ..\rtl\tsan_md5.cc ..\rtl\tsan_mutex.cc ..\rtl\tsan_report.cc ..\rtl\tsan_rtl.cc ..\rtl\tsan_rtl_mutex.cc ..\rtl\tsan_rtl_report.cc ..\rtl\tsan_rtl_thread.cc ..\rtl\tsan_stat.cc ..\rtl\tsan_suppressions.cc ..\rtl\tsan_sync.cc ..\rtl\tsan_stack_trace.cc ..\..\sanitizer_common\sanitizer_allocator.cc ..\..\sanitizer_common\sanitizer_common.cc ..\..\sanitizer_common\sanitizer_flags.cc ..\..\sanitizer_common\sanitizer_stacktrace.cc ..\..\sanitizer_common\sanitizer_libc.cc ..\..\sanitizer_common\sanitizer_printf.cc ..\..\sanitizer_common\sanitizer_suppressions.cc ..\..\sanitizer_common\sanitizer_thread_registry.cc ..\rtl\tsan_platform_windows.cc ..\..\sanitizer_common\sanitizer_win.cc ..\..\sanitizer_common\sanitizer_deadlock_detector1.cc ..\..\sanitizer_common\sanitizer_stackdepot.cc ..\..\sanitizer_common\sanitizer_persistent_allocator.cc > gotsan.cc
gcc -c -o race_windows_amd64.syso gotsan.cc -I..\rtl -I..\.. -I..\..\sanitizer_common -I..\..\..\include -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 -Wno-error=attributes -Wno-attributes -Wno-format -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer gcc -c -o race_windows_amd64.syso gotsan.cc -I..\rtl -I..\.. -I..\..\sanitizer_common -I..\..\..\include -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -Wno-error=attributes -Wno-attributes -Wno-format -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer

View File

@ -87,7 +87,7 @@ for F in $SRCS; do
cat $F >> gotsan.cc cat $F >> gotsan.cc
done done
FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DTSAN_SHADOW_COUNT=4 -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS" FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++11 -m64 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS"
if [ "$DEBUG" == "" ]; then if [ "$DEBUG" == "" ]; then
FLAGS+=" -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer" FLAGS+=" -DSANITIZER_DEBUG=0 -O3 -msse3 -fomit-frame-pointer"
else else

View File

@ -40,18 +40,8 @@ const int kClkBits = 42;
const unsigned kMaxTidReuse = (1 << (64 - kClkBits)) - 1; const unsigned kMaxTidReuse = (1 << (64 - kClkBits)) - 1;
const uptr kShadowStackSize = 64 * 1024; const uptr kShadowStackSize = 64 * 1024;
#ifdef TSAN_SHADOW_COUNT
# if TSAN_SHADOW_COUNT == 2 \
|| TSAN_SHADOW_COUNT == 4 || TSAN_SHADOW_COUNT == 8
const uptr kShadowCnt = TSAN_SHADOW_COUNT;
# else
# error "TSAN_SHADOW_COUNT must be one of 2,4,8"
# endif
#else
// Count of shadow values in a shadow cell. // Count of shadow values in a shadow cell.
#define TSAN_SHADOW_COUNT 4
const uptr kShadowCnt = 4; const uptr kShadowCnt = 4;
#endif
// That many user bytes are mapped onto a single shadow cell. // That many user bytes are mapped onto a single shadow cell.
const uptr kShadowCell = 8; const uptr kShadowCell = 8;
@ -96,16 +86,6 @@ void build_consistency_stats();
void build_consistency_nostats(); void build_consistency_nostats();
#endif #endif
#if TSAN_SHADOW_COUNT == 1
void build_consistency_shadow1();
#elif TSAN_SHADOW_COUNT == 2
void build_consistency_shadow2();
#elif TSAN_SHADOW_COUNT == 4
void build_consistency_shadow4();
#else
void build_consistency_shadow8();
#endif
static inline void USED build_consistency() { static inline void USED build_consistency() {
#if SANITIZER_DEBUG #if SANITIZER_DEBUG
build_consistency_debug(); build_consistency_debug();
@ -117,15 +97,6 @@ static inline void USED build_consistency() {
#else #else
build_consistency_nostats(); build_consistency_nostats();
#endif #endif
#if TSAN_SHADOW_COUNT == 1
build_consistency_shadow1();
#elif TSAN_SHADOW_COUNT == 2
build_consistency_shadow2();
#elif TSAN_SHADOW_COUNT == 4
build_consistency_shadow4();
#else
build_consistency_shadow8();
#endif
} }
template<typename T> template<typename T>

View File

@ -565,15 +565,7 @@ void MemoryAccessImpl1(ThreadState *thr, uptr addr,
// it's just not worth it (performance- and complexity-wise). // it's just not worth it (performance- and complexity-wise).
Shadow old(0); Shadow old(0);
if (kShadowCnt == 1) {
int idx = 0;
#include "tsan_update_shadow_word_inl.h"
} else if (kShadowCnt == 2) {
int idx = 0;
#include "tsan_update_shadow_word_inl.h"
idx = 1;
#include "tsan_update_shadow_word_inl.h"
} else if (kShadowCnt == 4) {
int idx = 0; int idx = 0;
#include "tsan_update_shadow_word_inl.h" #include "tsan_update_shadow_word_inl.h"
idx = 1; idx = 1;
@ -582,26 +574,6 @@ void MemoryAccessImpl1(ThreadState *thr, uptr addr,
#include "tsan_update_shadow_word_inl.h" #include "tsan_update_shadow_word_inl.h"
idx = 3; idx = 3;
#include "tsan_update_shadow_word_inl.h" #include "tsan_update_shadow_word_inl.h"
} else if (kShadowCnt == 8) {
int idx = 0;
#include "tsan_update_shadow_word_inl.h"
idx = 1;
#include "tsan_update_shadow_word_inl.h"
idx = 2;
#include "tsan_update_shadow_word_inl.h"
idx = 3;
#include "tsan_update_shadow_word_inl.h"
idx = 4;
#include "tsan_update_shadow_word_inl.h"
idx = 5;
#include "tsan_update_shadow_word_inl.h"
idx = 6;
#include "tsan_update_shadow_word_inl.h"
idx = 7;
#include "tsan_update_shadow_word_inl.h"
} else {
CHECK(false);
}
// we did not find any races and had already stored // we did not find any races and had already stored
// the current access info, so we are done // the current access info, so we are done
@ -652,7 +624,7 @@ bool ContainsSameAccessSlow(u64 *s, u64 a, u64 sync_epoch, bool is_write) {
return false; return false;
} }
#if defined(__SSE3__) && TSAN_SHADOW_COUNT == 4 #if defined(__SSE3__)
#define SHUF(v0, v1, i0, i1, i2, i3) _mm_castps_si128(_mm_shuffle_ps( \ #define SHUF(v0, v1, i0, i1, i2, i3) _mm_castps_si128(_mm_shuffle_ps( \
_mm_castsi128_ps(v0), _mm_castsi128_ps(v1), \ _mm_castsi128_ps(v0), _mm_castsi128_ps(v1), \
(i0)*1 + (i1)*4 + (i2)*16 + (i3)*64)) (i0)*1 + (i1)*4 + (i2)*16 + (i3)*64))
@ -712,7 +684,7 @@ bool ContainsSameAccessFast(u64 *s, u64 a, u64 sync_epoch, bool is_write) {
ALWAYS_INLINE ALWAYS_INLINE
bool ContainsSameAccess(u64 *s, u64 a, u64 sync_epoch, bool is_write) { bool ContainsSameAccess(u64 *s, u64 a, u64 sync_epoch, bool is_write) {
#if defined(__SSE3__) && TSAN_SHADOW_COUNT == 4 #if defined(__SSE3__)
bool res = ContainsSameAccessFast(s, a, sync_epoch, is_write); bool res = ContainsSameAccessFast(s, a, sync_epoch, is_write);
// NOTE: this check can fail if the shadow is concurrently mutated // NOTE: this check can fail if the shadow is concurrently mutated
// by other threads. But it still can be useful if you modify // by other threads. But it still can be useful if you modify
@ -1003,16 +975,6 @@ void build_consistency_stats() {}
void build_consistency_nostats() {} void build_consistency_nostats() {}
#endif #endif
#if TSAN_SHADOW_COUNT == 1
void build_consistency_shadow1() {}
#elif TSAN_SHADOW_COUNT == 2
void build_consistency_shadow2() {}
#elif TSAN_SHADOW_COUNT == 4
void build_consistency_shadow4() {}
#else
void build_consistency_shadow8() {}
#endif
} // namespace __tsan } // namespace __tsan
#ifndef SANITIZER_GO #ifndef SANITIZER_GO

View File

@ -46,9 +46,6 @@ TEST(ThreadSanitizer, MemcpyRace1) {
t2.Memcpy(data, data2, 10, true); t2.Memcpy(data, data2, 10, true);
} }
// The test fails with TSAN_SHADOW_COUNT=2,
// because the old racy access is evicted.
#if defined(TSAN_SHADOW_COUNT) && TSAN_SHADOW_COUNT >= 4
TEST(ThreadSanitizer, MemcpyRace2) { TEST(ThreadSanitizer, MemcpyRace2) {
char *data = new char[10]; char *data = new char[10];
char *data1 = new char[10]; char *data1 = new char[10];
@ -57,7 +54,6 @@ TEST(ThreadSanitizer, MemcpyRace2) {
t1.Memcpy(data+5, data1, 1); t1.Memcpy(data+5, data1, 1);
t2.Memcpy(data+3, data2, 4, true); t2.Memcpy(data+3, data2, 4, true);
} }
#endif
TEST(ThreadSanitizer, MemcpyRace3) { TEST(ThreadSanitizer, MemcpyRace3) {
char *data = new char[10]; char *data = new char[10];