tsan: change ReportMutex::id type to int

We used to use u64 as mutex id because it was some
tricky identifier built from address and reuse count.
Now it's just the mutex index in the report (0, 1, 2...),
so use int to represent it.

Depends on D112603.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D113980
This commit is contained in:
Dmitry Vyukov 2021-11-16 09:09:14 +01:00
parent a6f56a622d
commit 69807fe161
3 changed files with 10 additions and 10 deletions

View File

@ -126,7 +126,7 @@ static void PrintMutexSet(Vector<ReportMopMutex> const& mset) {
if (i == 0)
Printf(" (mutexes:");
const ReportMopMutex m = mset[i];
Printf(" %s M%llu", m.write ? "write" : "read", m.id);
Printf(" %s M%u", m.write ? "write" : "read", m.id);
Printf(i == mset.Size() - 1 ? ")" : ",");
}
}
@ -211,13 +211,13 @@ static void PrintLocation(const ReportLocation *loc) {
static void PrintMutexShort(const ReportMutex *rm, const char *after) {
Decorator d;
Printf("%sM%lld%s%s", d.Mutex(), rm->id, d.Default(), after);
Printf("%sM%d%s%s", d.Mutex(), rm->id, d.Default(), after);
}
static void PrintMutexShortWithAddress(const ReportMutex *rm,
const char *after) {
Decorator d;
Printf("%sM%lld (%p)%s%s", d.Mutex(), rm->id,
Printf("%sM%d (%p)%s%s", d.Mutex(), rm->id,
reinterpret_cast<void *>(rm->addr), d.Default(), after);
}
@ -225,11 +225,11 @@ static void PrintMutex(const ReportMutex *rm) {
Decorator d;
if (rm->destroyed) {
Printf("%s", d.Mutex());
Printf(" Mutex M%llu is already destroyed.\n\n", rm->id);
Printf(" Mutex M%u is already destroyed.\n\n", rm->id);
Printf("%s", d.Default());
} else {
Printf("%s", d.Mutex());
Printf(" Mutex M%llu (%p) created at:\n", rm->id,
Printf(" Mutex M%u (%p) created at:\n", rm->id,
reinterpret_cast<void *>(rm->addr));
Printf("%s", d.Default());
PrintStack(rm->stack);
@ -460,12 +460,12 @@ void PrintReport(const ReportDesc *rep) {
} else if (rep->typ == ReportTypeDeadlock) {
Printf("WARNING: DEADLOCK\n");
for (uptr i = 0; i < rep->mutexes.Size(); i++) {
Printf("Goroutine %d lock mutex %llu while holding mutex %llu:\n", 999,
Printf("Goroutine %d lock mutex %u while holding mutex %u:\n", 999,
rep->mutexes[i]->id,
rep->mutexes[(i + 1) % rep->mutexes.Size()]->id);
PrintStack(rep->stacks[2*i]);
Printf("\n");
Printf("Mutex %llu was previously locked here:\n",
Printf("Mutex %u was previously locked here:\n",
rep->mutexes[(i + 1) % rep->mutexes.Size()]->id);
PrintStack(rep->stacks[2*i + 1]);
Printf("\n");

View File

@ -43,7 +43,7 @@ struct ReportStack {
};
struct ReportMopMutex {
u64 id;
int id;
bool write;
};
@ -91,7 +91,7 @@ struct ReportThread {
};
struct ReportMutex {
u64 id;
int id;
uptr addr;
bool destroyed;
ReportStack *stack;

View File

@ -193,7 +193,7 @@ void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s,
mop->stack->suppressable = true;
for (uptr i = 0; i < mset->Size(); i++) {
MutexSet::Desc d = mset->Get(i);
u64 id = this->AddMutex(d.addr, d.stack_id);
int id = this->AddMutex(d.addr, d.stack_id);
ReportMopMutex mtx = {id, d.write};
mop->mset.PushBack(mtx);
}