Skip to content
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

coverage: Consolidate creation of covmap/covfun records #132124

Merged
merged 4 commits into from
Oct 26, 2024

Conversation

Zalathar
Copy link
Contributor

This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow.

This PR also includes two semi-related cleanups:

  • Getting the codegen context's coverage_cx state is made infallible, since it should always exist when running the code paths that need it.
  • The value of covfun_section_name is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway.

Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the __llvm_covmap linker section, and per-function information that goes in the __llvm_covfun section (except on Windows, where slightly different section names are used).

There is no need for this code to be split across multiple functions in
multiple files.
In all the situations where this context is needed, it should always be
available.
Adding an extra `OnceCell` to `CrateCoverageContext` is much nicer than trying
to thread this string through multiple layers of function calls that already
have access to the context.
@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Oct 25, 2024
@Zalathar
Copy link
Contributor Author

I was originally planning to do #131962 (comment), but doing this first will make that a little cleaner.

@Zalathar
Copy link
Contributor Author

Rustbot is sleepy.

r? compiler

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 25, 2024
@Zalathar Zalathar added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 25, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this LGTM, minor docs nit. Feel free to r=me with or without addressing those.

@jieyouxu jieyouxu assigned jieyouxu and unassigned pnkfelix Oct 26, 2024
@jieyouxu
Copy link
Member

Thanks, you can r=me after PR CI is green.

@Zalathar
Copy link
Contributor Author

🟩
@bors r=jieyouxu

@bors
Copy link
Contributor

bors commented Oct 26, 2024

📌 Commit 0d653a5 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 26, 2024
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 26, 2024
…eyouxu

coverage: Consolidate creation of covmap/covfun records

This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow.

This PR also includes two semi-related cleanups:
- Getting the codegen context's `coverage_cx` state is made infallible, since it should always exist when running the code paths that need it.
- The value of `covfun_section_name` is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway.

---

Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the `__llvm_covmap` linker section, and per-function information that goes in the `__llvm_covfun` section (except on Windows, where slightly different section names are used).
jieyouxu added a commit to jieyouxu/rust that referenced this pull request Oct 26, 2024
…eyouxu

coverage: Consolidate creation of covmap/covfun records

This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow.

This PR also includes two semi-related cleanups:
- Getting the codegen context's `coverage_cx` state is made infallible, since it should always exist when running the code paths that need it.
- The value of `covfun_section_name` is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway.

---

Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the `__llvm_covmap` linker section, and per-function information that goes in the `__llvm_covfun` section (except on Windows, where slightly different section names are used).
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2024
Rollup of 4 pull requests

Successful merges:

 - rust-lang#132124 (coverage: Consolidate creation of covmap/covfun records)
 - rust-lang#132167 (Replace some LLVMRust wrappers with calls to the LLVM C API)
 - rust-lang#132169 (Deny calls to non-`#[const_trait]` methods in MIR constck)
 - rust-lang#132174 (x86 target features: make pclmulqdq imply sse2)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2024
Rollup of 5 pull requests

Successful merges:

 - rust-lang#132124 (coverage: Consolidate creation of covmap/covfun records)
 - rust-lang#132140 (Enable LSX feature for LoongArch Linux targets)
 - rust-lang#132169 (Deny calls to non-`#[const_trait]` methods in MIR constck)
 - rust-lang#132174 (x86 target features: make pclmulqdq imply sse2)
 - rust-lang#132180 (Print unsafety of attribute in AST pretty print)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c26280a into rust-lang:master Oct 26, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Oct 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2024
Rollup merge of rust-lang#132124 - Zalathar:consolidate-covstar, r=jieyouxu

coverage: Consolidate creation of covmap/covfun records

This code for creating covmap/covfun records during codegen was split across multiple functions and files for dubious historical reasons. Having it all in one place makes it easier to follow.

This PR also includes two semi-related cleanups:
- Getting the codegen context's `coverage_cx` state is made infallible, since it should always exist when running the code paths that need it.
- The value of `covfun_section_name` is saved in the codegen context, since it never changes at runtime, and the code that needs it has access to the context anyway.

---

Background: Coverage instrumentation generates two kinds of metadata that are embedded in the final binary. There is per-CGU information that goes in the `__llvm_covmap` linker section, and per-function information that goes in the `__llvm_covfun` section (except on Windows, where slightly different section names are used).
@Zalathar Zalathar deleted the consolidate-covstar branch October 26, 2024 22:14
@Zalathar
Copy link
Contributor Author

I've seen at least one report of coverage_cx() causing an ICE in the wild, so it looks like I'll need to revert that part until I have a better idea of what's going on.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 31, 2024
coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable

In rust-lang#132124, `coverage_cx()` was changed to panic if the context was unavailable, under the assumption that it would always be available whenever coverage instrumentation is enabled.

However, there have been reports of this change causing ICEs in `polars` CI.

I don't yet understand why this is happening, but for now it seems wisest to revert that part of the change, restoring the two early returns that had been replaced with panics.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 31, 2024
coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable

In rust-lang#132124, `coverage_cx()` was changed to panic if the context was unavailable, under the assumption that it would always be available whenever coverage instrumentation is enabled.

However, there have been reports of this change causing ICEs in `polars` CI.

I don't yet understand why this is happening, but for now it seems wisest to revert that part of the change, restoring the two early returns that had been replaced with panics.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 31, 2024
Rollup merge of rust-lang#132395 - Zalathar:coverage-cx-ice, r=jieyouxu

coverage: Avoid ICE when `coverage_cx` is unexpectedly unavailable

In rust-lang#132124, `coverage_cx()` was changed to panic if the context was unavailable, under the assumption that it would always be available whenever coverage instrumentation is enabled.

However, there have been reports of this change causing ICEs in `polars` CI.

I don't yet understand why this is happening, but for now it seems wisest to revert that part of the change, restoring the two early returns that had been replaced with panics.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants