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

Make source-based code coverage compatible with MIR inlining #83080

Merged
merged 5 commits into from
Mar 18, 2021

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Mar 13, 2021

When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.

Fixes #83061

@richkadel
Copy link
Contributor

Nice! I didn't realize you could still get the instance from the source_scope, but that definitely simplified things over what I thought was needed per #83061 .

Thank you @tmiasko !

Are you willing to add some tests in src/test/run-make-fulldeps/coverage/assert.rs or elsewhere?

@richkadel
Copy link
Contributor

Oh, this test also should be removed (now that the warning is deleted):

src/test/ui/mir/mir-inlining/inline-instrument-coverage-fail.rs

@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 13, 2021

Thanks. I removed now obsolete test for incompatibility, I also adjusted the computation of reachable functions to account for situation where function does not have its code generated directly, but is still reachable after being inlined into another. I will look into adding some test cases that combine code coverage and inlining.

@richkadel
Copy link
Contributor

BTW I can do another review when done, but I don't have Compiler Team approval privileges, so you'll need someone to do that (likely @wesleywiser or @tmandry) to push to bors, when ready.

When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.
Consider functions to be reachable for code coverage purposes, either
when they reach the code generation directly, or indirectly as inlined
part of another function.
@rust-log-analyzer

This comment has been minimized.

@tmiasko
Copy link
Contributor Author

tmiasko commented Mar 16, 2021

Added support for compile-flags to coverage tests and used it to create a MIR inlining test case.

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

This is great!

Comment on lines +99 to +103
if let Some(previous_expression) = self.expressions[expression_index].replace(Expression {
lhs,
op,
rhs,
region: region.clone(),
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Might be slightly nicer to extract a local for Expression { lhs, op, rhs ... } and then use it in both places instead of constructing twice.

@wesleywiser
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Mar 17, 2021

📌 Commit 0d84e0b has been approved by wesleywiser

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 17, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 17, 2021
Make source-based code coverage compatible with MIR inlining

When codegenning code coverage use the instance that coverage data was
originally generated for, to ensure basic level of compatibility with
MIR inlining.

Fixes rust-lang#83061
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 17, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#82191 (Vec::dedup_by optimization)
 - rust-lang#82270 (Emit error when trying to use assembler syntax directives in `asm!`)
 - rust-lang#82434 (Add more links between hash and btree collections)
 - rust-lang#83080 (Make source-based code coverage compatible with MIR inlining)
 - rust-lang#83168 (Extend `proc_macro_back_compat` lint to `procedural-masquerade`)
 - rust-lang#83192 (ci/docker: Add SDK/NDK level 21 to android docker for 32bit platforms)
 - rust-lang#83204 (Simplify C compilation for Fortanix-SGX target)
 - rust-lang#83216 (Allow registering tool lints with `register_tool`)
 - rust-lang#83223 (Display error details when a `mmap` call fails)
 - rust-lang#83228 (Don't show HTML diff if tidy isn't installed for rustdoc tests)
 - rust-lang#83231 (Switch riscvgc-unknown-none-elf use lp64d ABI)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b688b69 into rust-lang:master Mar 18, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 18, 2021
@tmiasko tmiasko deleted the inline-coverage branch March 18, 2021 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible solution to allow MIR inlining with -Zinstrument-coverage
6 participants