Page MenuHomePhabricator

Add -fprofile-update={atomic,prefer-atomic,single}
ClosedPublic

Authored by MaskRay on Sep 15 2020, 8:39 PM.

Details

Summary

GCC 7 introduced -fprofile-update={atomic,prefer-atomic} (prefer-atomic is for
best efforts (some targets do not support atomics)) to increment counters
atomically, which is exactly what we have done with -fprofile-instr-generate
(D50867) and -fprofile-arcs (b5ef137c11b1cc6ae839ee75b49233825772bdd0).
This patch adds the option to clang to surface the internal options at driver level.

GCC 7 also turned on -fprofile-update=prefer-atomic when -pthread is specified,
but it has performance regression
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89307). So we don't follow suit.

Diff Detail

Event Timeline

MaskRay created this revision.Sep 15 2020, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2020, 8:39 PM
MaskRay requested review of this revision.Sep 15 2020, 8:39 PM

I think an interesting extension (not in GCC) is -fprofile-update=set, a boolean counter like -covermode set in go: sometimes we don't need the numbers at all.

davidxl accepted this revision.Sep 24 2020, 11:28 PM

Looks good. Makes the tsan and instrumentation interaction also cleaner.

clang/test/CodeGen/code-coverage-tsan.c
1–3

Fix typo: atmomic

This revision is now accepted and ready to land.Sep 24 2020, 11:28 PM
MaskRay updated this revision to Diff 294232.Sep 24 2020, 11:33 PM
MaskRay marked an inline comment as done.

Thanks for review! I will wait until next week.

Fixed a typo.

Perhaps also add clang option manual description.

MaskRay updated this revision to Diff 294781.Sep 28 2020, 12:36 PM

Add documentation to UserManual.rst

This revision was automatically updated to reflect the committed changes.