Skip to content

[5.9] [Profiler] A couple of coverage fixes #66058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented May 22, 2023

5.9 cherry-pick of #66019 + #66053

  • Explanation: Fixes code coverage to not emit coverage maps for macro expansions for now, and fixes the filename emission to be consistent with version 6 of the coverage mapping format.
  • Scope: Affects code coverage generation.
  • Issue: rdar://109562235, Swift 5.8 bumps Coverage Mapping version from 5 to 6 without using the corresponding format #65964
  • Risk: Low. The macro expansion change is very low risk, as it only excludes data from the coverage map. The filename change is also fairly low risk considering that it should only affect cases that use a coverage prefix map, and the previous behavior was completely broken.
  • Testing: Added tests to the test suite
  • Reviewer: Ben Barham

We may want to revisit this in the future, but for
now let's avoid profiling code in generated
buffers. To make this work we'll need to come up
with a scheme for writing out the generated buffers
such that tools like `llvm-cov` can reference them.

rdar://109562235
The coverage format version we use is automatically
set to whatever the latest version LLVM has. This
resulting in us outputting version 6 as our
format without having made the changes necessary
to reflect the new format. Update the emission
logic to take account for [the new changes in
version 6][1] (we need to include the current
working directory as the first element of the list
of files we output). Additionally, add a
`static_assert` so we don't get caught out by
version bumps in the future. Note we can't pin our
version, as it must stay in sync with the version
Clang is using.

[1]: https://llvm.org/docs/CoverageMappingFormat.html#llvm-ir-representation
Previously we were doing a `std::find` over the
files for each coverage mapping, which would be
quadratic for WMO. Switch to using a DenseMap
instead.
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.9 labels May 22, 2023
@hamishknight hamishknight requested a review from a team as a code owner May 22, 2023 17:22
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit c2a1dce into swiftlang:release/5.9 Jun 5, 2023
@hamishknight hamishknight deleted the cover-for-your-cover-5.9 branch June 5, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants