This is an archive of the discontinued LLVM Phabricator instance.

tsan: store ThreadRegistry in Context by value
ClosedPublic

Authored by dvyukov on Jul 29 2021, 1:29 AM.

Details

Summary

It's unclear why we allocate ThreadRegistry separately,
I assume it's some historical leftover.
Embed ThreadRegistry into Context.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Jul 29 2021, 1:29 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2021, 1:29 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver added inline comments.Jul 29 2021, 2:44 AM
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
80

Some strange alignment requirements perhaps?

Is
https://reviews.llvm.org/rGcadbb9241627eefc9f589ae4376fd9ed3e272ecc
still relevant? opaque_storage is gone though.

I see the same "placeholder" idiom used for Context itself. git blame doesn't lead me very far, so I hope you or Vitaly remember the historical background.

dvyukov added inline comments.Jul 29 2021, 2:55 AM
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
80

Re https://reviews.llvm.org/rGcadbb9241627eefc9f589ae4376fd9ed3e272ecc
Context itself is 64-byte aligned, so we now should satisfy any alignment requirement for all Context members including ThreadRegistry and any Mutexes within ThreadRegistry.

I see the same "placeholder" idiom used for Context itself

Because that's the only way we can allocate anything. We can't declare and use typed global vars.

I hope you or Vitaly remember the historical background.

No, I don't. It was like 10 years ago. I remember initially ThreadRegistry was defined within tsan runtime only, then moved to sanitizer_common and generalized. Lots of things changed at that point.

melver accepted this revision.Jul 29 2021, 2:57 AM

In that case, this makes sense.

This revision is now accepted and ready to land.Jul 29 2021, 2:57 AM
This revision was automatically updated to reflect the committed changes.