-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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: Skip instrumenting a function if no spans were extracted from MIR #118852
Conversation
r? @b-naber (rustbot has picked a reviewer for you, use r? to override) |
@rustbot label +A-code-coverage |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Another thing I tried was having the However, that doesn't work because |
Either of the patches should fix the issue on their own, but I think they're both worthwhile. (If we skip instrumenting a function with no spans, then the function won't have |
5779766
to
9884e13
Compare
Coverage marker statements should have no effect on codegen, but in some cases they could have the side-effect of creating a `func_coverage` entry for their enclosing function. That can lead to an ICE for functions that don't actually have any coverage spans.
@bors r+ |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#118852 (coverage: Skip instrumenting a function if no spans were extracted from MIR) - rust-lang#118905 ([AIX] Fix XCOFF metadata) - rust-lang#118967 (Add better ICE messages for some undescriptive panics) - rust-lang#119051 (Replace `FileAllocationInfo` with `FileEndOfFileInfo`) - rust-lang#119059 (Deny `~const` trait bounds in inherent impl headers) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#118852 - Zalathar:no-spans, r=cjgillot coverage: Skip instrumenting a function if no spans were extracted from MIR The immediate symptoms of rust-lang#118643 were fixed by rust-lang#118666, but some users reported that their builds now encounter another coverage-related ICE: ``` error: internal compiler error: compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs:98:17: A used function should have had coverage mapping data but did not: (...) ``` I was able to reproduce at least one cause of this error: if no relevant spans could be extracted from a function, but the function contains `CoverageKind::SpanMarker` statements, then codegen still thinks the function is instrumented and complains about the fact that it has no coverage spans. This PR prevents that from happening in two ways: - If we didn't extract any relevant spans from MIR, skip instrumenting the entire function and don't create a `FunctionCoverateInfo` for it. - If coverage codegen sees a `CoverageKind::SpanMarker` statement, skip it early and avoid creating `func_coverage`. --- Fixes rust-lang#118850.
The immediate symptoms of #118643 were fixed by #118666, but some users reported that their builds now encounter another coverage-related ICE:
I was able to reproduce at least one cause of this error: if no relevant spans could be extracted from a function, but the function contains
CoverageKind::SpanMarker
statements, then codegen still thinks the function is instrumented and complains about the fact that it has no coverage spans.This PR prevents that from happening in two ways:
FunctionCoverateInfo
for it.CoverageKind::SpanMarker
statement, skip it early and avoid creatingfunc_coverage
.Fixes #118850.