696d846a56
libsanitizer/ 2015-10-20 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * All source files: Merge from upstream r250806. * configure.ac (link_sanitizer_common): Add -lrt flag. * configure.tgt: Enable TSAN and LSAN for aarch64-linux targets. Set CXX_ABI_NEEDED=true for darwin. * asan/Makefile.am (asan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0 and remove unused and legacy DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0. * asan/Makefile.in: Regenerate. * ubsan/Makefile.am (ubsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=1. (libubsan_la_LIBADD): Add -lc++abi if CXX_ABI_NEEDED is true. * ubsan/Makefile.in: Regenerate. * tsan/Makefile.am (tsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. * sanitizer_common/Makefile.in: Regenerate. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r229111
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
//===-- tsan_update_shadow_word_inl.h ---------------------------*- C++ -*-===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
//
|
|
// Body of the hottest inner loop.
|
|
// If we wrap this body into a function, compilers (both gcc and clang)
|
|
// produce sligtly less efficient code.
|
|
//===----------------------------------------------------------------------===//
|
|
do {
|
|
StatInc(thr, StatShadowProcessed);
|
|
const unsigned kAccessSize = 1 << kAccessSizeLog;
|
|
u64 *sp = &shadow_mem[idx];
|
|
old = LoadShadow(sp);
|
|
if (old.IsZero()) {
|
|
StatInc(thr, StatShadowZero);
|
|
if (store_word)
|
|
StoreIfNotYetStored(sp, &store_word);
|
|
// The above StoreIfNotYetStored could be done unconditionally
|
|
// and it even shows 4% gain on synthetic benchmarks (r4307).
|
|
break;
|
|
}
|
|
// is the memory access equal to the previous?
|
|
if (Shadow::Addr0AndSizeAreEqual(cur, old)) {
|
|
StatInc(thr, StatShadowSameSize);
|
|
// same thread?
|
|
if (Shadow::TidsAreEqual(old, cur)) {
|
|
StatInc(thr, StatShadowSameThread);
|
|
if (old.IsRWWeakerOrEqual(kAccessIsWrite, kIsAtomic))
|
|
StoreIfNotYetStored(sp, &store_word);
|
|
break;
|
|
}
|
|
StatInc(thr, StatShadowAnotherThread);
|
|
if (HappensBefore(old, thr)) {
|
|
if (old.IsRWWeakerOrEqual(kAccessIsWrite, kIsAtomic))
|
|
StoreIfNotYetStored(sp, &store_word);
|
|
break;
|
|
}
|
|
if (old.IsBothReadsOrAtomic(kAccessIsWrite, kIsAtomic))
|
|
break;
|
|
goto RACE;
|
|
}
|
|
// Do the memory access intersect?
|
|
if (Shadow::TwoRangesIntersect(old, cur, kAccessSize)) {
|
|
StatInc(thr, StatShadowIntersect);
|
|
if (Shadow::TidsAreEqual(old, cur)) {
|
|
StatInc(thr, StatShadowSameThread);
|
|
break;
|
|
}
|
|
StatInc(thr, StatShadowAnotherThread);
|
|
if (old.IsBothReadsOrAtomic(kAccessIsWrite, kIsAtomic))
|
|
break;
|
|
if (HappensBefore(old, thr))
|
|
break;
|
|
goto RACE;
|
|
}
|
|
// The accesses do not intersect.
|
|
StatInc(thr, StatShadowNotIntersect);
|
|
break;
|
|
} while (0);
|