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

Fixed conflict with drop elaboration and coverage #80072

Merged
merged 1 commit into from
Dec 17, 2020

Conversation

richkadel
Copy link
Contributor

See
#80045 (comment)

Coverage statements are moved to the beginning of the BCB. This does
also affect what's counted before a panic, changing some results, but I
think these results may even be preferred? In any case, there are no
guarantees about what's counted when a panic occurs (by design).

r? @tmandry

FYI @wesleywiser @ecstatic-morse

See
rust-lang#80045 (comment)

Coverage statements are moved to the beginning of the BCB. This does
also affect what's counted before a panic, changing some results, but I
think these results may even be preferred? In any case, there are no
guarantees about what's counted when a panic occurs (by design).
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 16, 2020
@@ -470,7 +470,7 @@ fn inject_statement(
code_region: some_code_region,
}),
};
data.statements.push(statement);
data.statements.insert(0, statement);
Copy link
Member

Choose a reason for hiding this comment

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

This is always going to be slower than appending at the end. I'd prefer to skip over coverage statements in the elaborate drops pass rather than work around it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually prefer it this way and I think the overall impact will be negligible.

Yes, functionally, we have the option of inserting the statement anywhere in the BCB, but it is standard practice to insert() into the statements vec in MIR processing when order is critical.

As I was trying to say in my reply here (though maybe not clearly):

#80045 (comment)

I believe inserting the coverage statement between the last statement and the terminator is going to break up some sequences in unexpected ways.

It wouldn't be a problem if I could insert the coverage statement after the terminator (which is impossible without a new BB, and that's much worse).

But the Terminator is really just a special case of a Statement, and the sequence from one statement to another is sometimes important, analytically at least. (Possibly even important at runtime, for context switching reasons, in fact.)

To drive the point: Think about a typical instruction sequence like, Load followed by Add (adding to the value that was just loaded). Most people would expect these to come in uninterrupted sequence, so injecting code to increment a global counter between the two, even if possible, would not be right.

I would rather not insert Coverage statements between a Statement and it's following Terminator, and it's not just about this one issue.

Copy link
Member

Choose a reason for hiding this comment

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

I missed your comment there, makes sense.

@tmandry
Copy link
Member

tmandry commented Dec 16, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Dec 16, 2020

📌 Commit 1d6b455 has been approved by tmandry

@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 Dec 16, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 17, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#79051 (Implement if-let match guards)
 - rust-lang#79877 (Allow `since="TBD"` for rustc_deprecated)
 - rust-lang#79882 (Fix issue rust-lang#78496)
 - rust-lang#80026 (expand-yaml-anchors: Make the output directory separator-insensitive)
 - rust-lang#80039 (Remove unused `TyEncoder::tcx` required method)
 - rust-lang#80069 (Test that `core::assert!` is valid)
 - rust-lang#80072 (Fixed conflict with drop elaboration and coverage)
 - rust-lang#80073 (Add support for target aliases)
 - rust-lang#80082 (Revert rust-lang#78790 - rust-src vendoring)
 - rust-lang#80097 (Add `popcount` and `popcnt` as doc aliases for `count_ones` methods.)
 - rust-lang#80103 (Remove docs for non-existent parameters in `rustc_expand`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a5b1d22 into rust-lang:master Dec 17, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 17, 2020
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.

5 participants