Skip to content

Commit 19ba259

Browse files
committed
RSan: Use TSan epoch
1 parent 89b3a55 commit 19ba259

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

compiler-rt/lib/tsan/rtl/rsan_defs.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ namespace Robustness{
1616
using __tsan::s64;
1717
using __tsan::u64;
1818
using __tsan::uptr;
19-
typedef s64 timestamp_t;
19+
using __tsan::Epoch;
20+
using __tsan::EpochInc;
21+
using __tsan::EpochOverflow;
22+
using __tsan::kEpochZero;
23+
using __tsan::kEpochOver;
24+
using __tsan::kEpochLast;
25+
typedef __tsan::Epoch timestamp_t;
2026
typedef s64 ssize_t;
2127
typedef u64 uint64_t;
2228
typedef s64 int64_t;

compiler-rt/lib/tsan/rtl/rsan_robustnessmodel.hpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ namespace Robustness {
2828
};
2929
//! Location component
3030
struct Location{
31-
timestamp_t stamp = 0;
32-
timestamp_t stampu = 0;
31+
timestamp_t stamp = kEpochZero;
32+
timestamp_t stampu = kEpochZero;
3333
VectorClock m, w;
3434
VectorClock mu, wu;
3535
};
@@ -53,12 +53,12 @@ namespace Robustness {
5353
* Memory order is ignored for SC
5454
*/
5555
void updateStoreStatement(ThreadId , LocationId a, Thread &ts, Location &ls, morder, u64 val){
56-
ls.m |= timestamp(a, ++ls.stamp);
56+
ls.m |= timestamp(a, EpochInc(ls.stamp));
5757
ts.v |= ls.m;
5858
ls.w = ts.v;
5959
ls.m = ts.v;
6060

61-
ls.mu |= timestamp(a, ++ls.stampu);
61+
ls.mu |= timestamp(a, EpochInc(ls.stampu));
6262
ts.vu |= ls.mu;
6363
ls.wu = ts.vu;
6464
ls.mu = ts.vu;
@@ -71,7 +71,7 @@ namespace Robustness {
7171
*/
7272
void updateRmwStatement(ThreadId t, LocationId a, Thread &ts, Location &ls, morder mo, u64 val){
7373
//return updateStoreStatement(t, a, ts, ls, mo);
74-
ls.m |= timestamp(a, ++ls.stamp);
74+
ls.m |= timestamp(a, EpochInc(ls.stamp));
7575
ts.v |= ls.m;
7676
ls.w = ts.v;
7777
ls.m = ts.v;
@@ -91,12 +91,6 @@ namespace Robustness {
9191
timestamp_t getLastTimeStampU(ThreadId , LocationId l, Thread &ts, Location &ls) const{
9292
return ts.vu[l].ts;
9393
}
94-
timestamp_t getLastTimeStampV(ThreadId , LocationId l, Thread &ts, Location &ls, u64 val) const{
95-
return ts.v[l].ts - 1;
96-
}
97-
timestamp_t getLastTimeStampUV(ThreadId , LocationId l, Thread &ts, Location &ls, u64 val) const{
98-
return ts.vu[l].ts - 1;
99-
}
10094

10195
//! Remove locations when freeing memory
10296
void freeLocation(LocationId l, Location &ls){
@@ -138,7 +132,7 @@ namespace Robustness {
138132
};
139133
//! Location component
140134
struct Location{
141-
timestamp_t writeStamp = 0, writeStampU = 0;
135+
timestamp_t writeStamp = kEpochZero, writeStampU = kEpochZero;
142136
VectorClock w;
143137
VectorClock wu;
144138
};
@@ -162,8 +156,8 @@ namespace Robustness {
162156

163157
//! Update store statement
164158
void updateStoreStatement(ThreadId t, LocationId a, Thread &ts, Location &ls, morder mo, uint64_t oldValue){
165-
const auto timestampV = timestamp(a, ++ls.writeStamp);
166-
const auto timestampVU = timestamp(a, ++ls.writeStampU);
159+
const auto timestampV = timestamp(a, EpochInc(ls.writeStamp));
160+
const auto timestampVU = timestamp(a, EpochInc(ls.writeStampU));
167161
ls.w |= timestampV;
168162
ls.wu |= timestampVU;
169163
ts.va |= timestampV;
@@ -185,7 +179,7 @@ namespace Robustness {
185179

186180
//! Update RMW statement
187181
void updateRmwStatement(ThreadId t, LocationId a, Thread &ts, Location &ls, morder mo, uint64_t oldValue){
188-
const auto timestampV = timestamp(a, ++ls.writeStamp);
182+
const auto timestampV = timestamp(a, EpochInc(ls.writeStamp));
189183
ls.w |= timestampV;
190184
ts.va |= timestampV;
191185
ts.vc |= timestampV;

compiler-rt/lib/tsan/rtl/rsan_vectorclock.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ template <typename T>
1313
class Timestamp{
1414
public:
1515
T key{};
16-
timestamp_t ts = 0;
16+
timestamp_t ts = kEpochZero;
1717

1818
/// Check if the timestamp is newer than rhs
1919
public:
@@ -50,7 +50,7 @@ class VectorClock {
5050
/// Increment a timestamp t in the vector
5151
auto inc(LocationId t){
5252
impl.ensureSize(t+1);
53-
timestamp(t, ++impl[t]);
53+
timestamp(t, EpochInc(impl[t]));
5454
}
5555
/// Reset the vector clock
5656
void reset(){
@@ -96,7 +96,7 @@ class VectorClock {
9696
if (impl[i] < rhs.impl[i])
9797
return false;
9898
for (; i < S2; ++i)
99-
if (rhs.impl[i] > 0)
99+
if (rhs.impl[i] > kEpochZero)
100100
return false;
101101
return true;
102102
}
@@ -105,7 +105,7 @@ class VectorClock {
105105
if (t < impl.size()) {
106106
return timestamp(t, impl[t]);
107107
}
108-
return timestamp(t, 0);
108+
return timestamp(t, kEpochZero);
109109
}
110110

111111
bool contains(const Timestamp<LocationId> &rhs) const{

0 commit comments

Comments
 (0)