This is an archive of the discontinued LLVM Phabricator instance.

tsan: introduce Tid and StackID typedefs
ClosedPublic

Authored by dvyukov on Jul 30 2021, 4:56 AM.

Details

Summary

Currently we inconsistently use u32 and int for thread ids,
there are also "unique tid" and "os tid" and just lots of other
things identified by integers.
Additionally new tsan runtime will introduce yet another
thread identifier that is very different from current tids.
Similarly for stack IDs, it's easy to confuse u32 with other
integer identifiers. And when a function accepts u32 or a struct
contains u32 field, it's not always clear what it is.

Add Tid and StackID typedefs to make it clear what is what.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Jul 30 2021, 4:56 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2021, 4:56 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver added inline comments.Jul 30 2021, 6:50 AM
compiler-rt/lib/tsan/rtl/tsan_defs.h
37 ↗(On Diff #363036)

Does it make sense to put this into sanitizer_common?

Because there you have

compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:constexpr u32 kInvalidTid = -1;

which is used to assign to Tids.

melver added inline comments.Jul 30 2021, 6:52 AM
compiler-rt/lib/tsan/rtl/tsan_defs.h
37 ↗(On Diff #363036)

(Applies to line 36 of course, but perhaps both can be moved if appropriate.)

dvyukov updated this revision to Diff 363103.Jul 30 2021, 8:18 AM

moved Tid/StackID to sanitizer_common

dvyukov marked 2 inline comments as done.Jul 30 2021, 8:19 AM
dvyukov added inline comments.
compiler-rt/lib/tsan/rtl/tsan_defs.h
37 ↗(On Diff #363036)

Done. PTAL.

melver accepted this revision.Jul 30 2021, 8:56 AM
This revision is now accepted and ready to land.Jul 30 2021, 8:56 AM
dvyukov updated this revision to Diff 363129.Jul 30 2021, 9:46 AM
dvyukov marked an inline comment as done.

use kInvalidTid/StackID instead of 0's

This revision was landed with ongoing or failed builds.Jul 31 2021, 12:05 AM
This revision was automatically updated to reflect the committed changes.