summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2013-02-01 10:02:55 +0000
committerDmitry Vyukov <dvyukov@google.com>2013-02-01 10:02:55 +0000
commit71242b064e16416f8de1d3f2a3bf4652f74b3a28 (patch)
treec3b3178d3b5deb58f4e86f9a0d257e6ed1c3426d
parentba4291480de895ca922ab7bfdaa6edf4914998d5 (diff)
downloadbcm5719-llvm-71242b064e16416f8de1d3f2a3bf4652f74b3a28.tar.gz
bcm5719-llvm-71242b064e16416f8de1d3f2a3bf4652f74b3a28.zip
tsan: flip is_write bit in shadow to is_read
this makes calculation of interesting predicates faster llvm-svn: 174164
-rw-r--r--compiler-rt/lib/tsan/rtl/tsan_rtl.h26
-rw-r--r--compiler-rt/lib/tsan/tests/unit/tsan_shadow_test.cc2
2 files changed, 14 insertions, 14 deletions
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 1d57060d950..40743fa96c0 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -174,7 +174,7 @@ class FastState {
// tid : kTidBits
// epoch : kClkBits
// is_atomic : 1
-// is_write : 1
+// is_read : 1
// size_log : 2
// addr0 : 3
class Shadow : public FastState {
@@ -198,9 +198,9 @@ class Shadow : public FastState {
}
void SetWrite(unsigned kAccessIsWrite) {
- DCHECK_EQ(x_ & 32, 0);
- if (kAccessIsWrite)
- x_ |= 32;
+ DCHECK_EQ(x_ & kReadBit, 0);
+ if (!kAccessIsWrite)
+ x_ |= kReadBit;
DCHECK_EQ(kAccessIsWrite, IsWrite());
}
@@ -264,8 +264,8 @@ class Shadow : public FastState {
}
u64 addr0() const { return x_ & 7; }
u64 size() const { return 1ull << size_log(); }
- bool IsWrite() const { return x_ & 32; }
- bool IsRead() const { return !IsWrite(); }
+ bool IsWrite() const { return !IsRead(); }
+ bool IsRead() const { return x_ & kReadBit; }
// The idea behind the freed bit is as follows.
// When the memory is freed (or otherwise unaccessible) we write to the shadow
@@ -287,15 +287,15 @@ class Shadow : public FastState {
}
bool IsBothReadsOrAtomic(bool kIsWrite, bool kIsAtomic) const {
- // analyzes 5-th bit (is_write) and 6-th bit (is_atomic)
- bool v = ((x_ ^ kWriteBit)
- & u64(((kIsWrite ^ 1) << kWriteShift) | (kIsAtomic << kAtomicShift)));
+ // analyzes 5-th bit (is_read) and 6-th bit (is_atomic)
+ bool v = x_ & u64(((kIsWrite ^ 1) << kReadShift)
+ | (kIsAtomic << kAtomicShift));
DCHECK_EQ(v, (!IsWrite() && !kIsWrite) || (IsAtomic() && kIsAtomic));
return v;
}
bool IsRWNotWeaker(bool kIsWrite, bool kIsAtomic) const {
- bool v = (((x_ >> kWriteShift) & 3) ^ 1)
+ bool v = ((x_ >> kReadShift) & 3)
<= u64((kIsWrite ^ 1) | (kIsAtomic << 1));
DCHECK_EQ(v, (IsAtomic() < kIsAtomic) ||
(IsAtomic() == kIsAtomic && !IsWrite() <= !kIsWrite));
@@ -303,7 +303,7 @@ class Shadow : public FastState {
}
bool IsRWWeakerOrEqual(bool kIsWrite, bool kIsAtomic) const {
- bool v = (((x_ >> kWriteShift) & 3) ^ 1)
+ bool v = ((x_ >> kReadShift) & 3)
>= u64((kIsWrite ^ 1) | (kIsAtomic << 1));
DCHECK_EQ(v, (IsAtomic() > kIsAtomic) ||
(IsAtomic() == kIsAtomic && !IsWrite() >= !kIsWrite));
@@ -311,8 +311,8 @@ class Shadow : public FastState {
}
private:
- static const u64 kWriteShift = 5;
- static const u64 kWriteBit = 1ull << kWriteShift;
+ static const u64 kReadShift = 5;
+ static const u64 kReadBit = 1ull << kReadShift;
static const u64 kAtomicShift = 6;
static const u64 kAtomicBit = 1ull << kAtomicShift;
diff --git a/compiler-rt/lib/tsan/tests/unit/tsan_shadow_test.cc b/compiler-rt/lib/tsan/tests/unit/tsan_shadow_test.cc
index d37a2693554..17b17977bf8 100644
--- a/compiler-rt/lib/tsan/tests/unit/tsan_shadow_test.cc
+++ b/compiler-rt/lib/tsan/tests/unit/tsan_shadow_test.cc
@@ -25,7 +25,7 @@ TEST(Shadow, FastState) {
EXPECT_EQ(s.GetHistorySize(), 0);
EXPECT_EQ(s.addr0(), (u64)0);
EXPECT_EQ(s.size(), (u64)1);
- EXPECT_EQ(s.IsWrite(), false);
+ EXPECT_EQ(s.IsWrite(), true);
s.IncrementEpoch();
EXPECT_EQ(s.epoch(), (u64)23);
OpenPOWER on IntegriCloud