This is an archive of the discontinued LLVM Phabricator instance.

tsan: unit-test all mappings
ClosedPublic

Authored by dvyukov on Aug 9 2021, 12:52 AM.

Details

Summary

Move the mapping checking logic from startup to unit tests
and test all mapping instead of just the active one.
This makes it much more feasible to make any global changes
to the mappings since we have 17 of them.

Depends on D107740.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Aug 9 2021, 12:52 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2021, 12:52 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver accepted this revision.Aug 9 2021, 6:34 AM
melver added inline comments.
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

minor: align '=' as well?

268

minor: Ignore clang-format and align with others.

This revision is now accepted and ready to land.Aug 9 2021, 6:34 AM
dvyukov added inline comments.Aug 9 2021, 10:16 AM
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

I can't. All new code is formatted by clang-format. And I can't even do 'arc diff' w/o it running clang-format and amending results...
I agree this is ugly. We can either give up on alignment and re-format everything with clang-format, or add annotations to disable clang-format and re-align everything. Any preferences?
But let me do it separately after landing these series because it causes conflicts.

268

same here

melver added inline comments.Aug 9 2021, 10:24 AM
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

Sigh. Annotations to disable ("// clang-format off"?) are probably worse.

Somehow there must be a way to hack it so 'arc diff' doesn't do this. I hate that clang-format is "the law" now, because it's not perfect and makes mistakes, too (especially all the cases where it does something like "type var =<newline>" is just awful).

But no point in wasting time on it, so disregard.

dvyukov added inline comments.Aug 9 2021, 10:31 AM
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

Sigh. Annotations to disable ("// clang-format off"?) are probably worse.

Yes, these annotations.
I don't think they will be too bad here. We will surround very limited and specific part of code formatted as a table.

Somehow there must be a way to hack it so 'arc diff' doesn't do this. I hate that clang-format is "the law" now, because it's not perfect and makes mistakes, too

FWIW I like it :)
I don't need to argue about formatting anymore.
If one can randomly disregard it, then we get to where we start. Arguing about style. And do you know if I intentionally disregarded it or just forgot to format?

(especially all the cases where it does something like "type var =<newline>" is just awful).

Yes, not very nice. I think part of the problem with this particular one is interaction of our verbose naming style with 80 column requirement. That's why I wanted to increase line width.

But no point in wasting time on it, so disregard.

vitalybuka accepted this revision.Aug 9 2021, 11:24 AM
vitalybuka added inline comments.
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

Yeh, leave it to clang-format and let it to what ever it does.
Also "AlignConsecutiveAssignments: true" into tsan/.clang-format ?

743
dvyukov updated this revision to Diff 365244.Aug 9 2021, 11:47 AM

changed SelectMapping to use template Arg and rebased

dvyukov added inline comments.Aug 9 2021, 12:04 PM
compiler-rt/lib/tsan/rtl/tsan_platform.h
211

AlignConsecutiveAssignments produces quite a diff, and some of the edits are quite dubious:
https://github.com/dvyukov/llvm-project/commit/c0065f73f601514ff7f0c5a2f534af2fd09d64a6
So I don't think we want to enable it because of tables in this file.

dvyukov added inline comments.Aug 9 2021, 12:36 PM
compiler-rt/lib/tsan/rtl/tsan_platform.h
743

Interesting. But it does not produce better output :)

[----------] 1 test from MappingTest/0, where TypeParam = <type>
[ RUN      ] MappingTest/0.Test
[       OK ] MappingTest/0.Test (0 ms)
[----------] 1 test from MappingTest/0 (0 ms total)

[----------] 1 test from MappingTest/1, where TypeParam = <type>
[ RUN      ] MappingTest/1.Test
[       OK ] MappingTest/1.Test (0 ms)
[----------] 1 test from MappingTest/1 (0 ms total)

[----------] 1 test from MappingTest/2, where TypeParam = <type>
[ RUN      ] MappingTest/2.Test
[       OK ] MappingTest/2.Test (0 ms)
[----------] 1 test from MappingTest/2 (0 ms total)

I guess that's because we don't have rtti enabled.

The reason I wanted the mapping list to be in tsan_platform.h is because when a new mapping is added, the chances that it will be added to tests/unit/tsan_shadow_test.cpp are close to 0 :)

I don't have strong preference either way. Do you?

dvyukov added inline comments.Aug 10 2021, 8:23 AM
compiler-rt/lib/tsan/rtl/tsan_platform.h
743

I will proceed with merging this series (I have other pending changes on top).
If you prefer any additional changes, please say and I will fix separately.

This revision was landed with ongoing or failed builds.Aug 10 2021, 11:07 AM
This revision was automatically updated to reflect the committed changes.
vitalybuka added inline comments.Aug 10 2021, 12:04 PM
compiler-rt/lib/tsan/rtl/tsan_platform.h
743

no strong preference, feel free to keep either way