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

MIR pass to remove unneeded drops on types not needing drop #76673

Merged
merged 7 commits into from
Sep 23, 2020

Conversation

simonvandel
Copy link
Contributor

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?

@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2020
@petrochenkov
Copy link
Contributor

r? @oli-obk (the first reviewer suggested by github)

@jyn514 jyn514 added A-mir-opt Area: MIR optimizations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 13, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Sep 17, 2020

Do we want to special case replacing a call to std::mem::drop with a goto aswell?

No, we'll want inlining to take care of this at some point

@oli-obk
Copy link
Contributor

oli-obk commented Sep 17, 2020

one thing I'm wondering is whether we should/could just rerun drop elaboration after inlining... That would catch even more cases, but may be expensive.

@simonvandel
Copy link
Contributor Author

Hi @oli-obk
I pushed some cleanup and your suggestion for running simplify-cfg after the optimization.

Note that on mir-opt-level=1 this pass really does nothing as the inliner is not running.

one thing I'm wondering is whether we should/could just rerun drop elaboration after inlining... That would catch even more cases, but may be expensive.

I suggest handling that in another issue. Do you want to elaborate on it yourself in another issue?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 19, 2020

I suggest handling that in another issue

yes let's handle that in the future. It was just random musing, I don't know at all whether any of that is actionable

@bors r+

@bors
Copy link
Contributor

bors commented Sep 19, 2020

📌 Commit 804f673 has been approved by oli-obk

@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 Sep 19, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 19, 2020
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 19, 2020
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 19, 2020
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 21, 2020
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 21, 2020
…r=oli-obk

MIR pass to remove unneeded drops on types not needing drop

This is heavily dependent on MIR inlining running to actually see the drop statement.

Do we want to special case replacing a call to std::mem::drop with a goto aswell?
@simonvandel
Copy link
Contributor Author

Rebased

@ecstatic-morse
Copy link
Contributor

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Sep 22, 2020

📌 Commit ff24163 has been approved by oli-obk

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 22, 2020
@ecstatic-morse
Copy link
Contributor

@bors p=15 (queue fairness)

@bors
Copy link
Contributor

bors commented Sep 23, 2020

⌛ Testing commit ff24163 with merge 1fbc1c2c0ab3279483232bf44b400d18a3275b0e...

@bors
Copy link
Contributor

bors commented Sep 23, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 23, 2020
@simonvandel
Copy link
Contributor Author

Hmm seems like the same error as in the rollup. When I did the rebase I also reblessed but that didn't change any files. Not sure what is wrong at this point.

@RalfJung
Copy link
Member

Maybe the target (wasm32-unknown-unknown) is relevant to reproduce the problem?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 23, 2020

Yea I'd also guess that it's related to the target, as that specific drop impl doesn't seem to have unwinding activated. Check the other mir-opt tests to see if any of them have // ignore-foo flags that relate to unwind, abort or wasm32

@simonvandel
Copy link
Contributor Author

Let's try again with the test ignored on wasm

@RalfJung
Copy link
Member

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Sep 23, 2020

📌 Commit 05f84c6 has been approved by oli-obk

@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 Sep 23, 2020
@bors
Copy link
Contributor

bors commented Sep 23, 2020

⌛ Testing commit 05f84c6 with merge 8b40853...

@bors
Copy link
Contributor

bors commented Sep 23, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: oli-obk
Pushing 8b40853 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 23, 2020
@bors bors merged commit 8b40853 into rust-lang:master Sep 23, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 23, 2020
fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
match terminator.kind {
TerminatorKind::Drop { place, target, .. }
| TerminatorKind::DropAndReplace { place, target, .. } => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The DropAndReplace terminator should never occur in an input to this pass, since it should be removed during drop elaboration. Additionally, its semantics is to drop and assign a new value, so the transformation wouldn't be correct without additional assignment. Either way, I would just remove it from 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.

Hi @tmiasko, thanks! See PR #77165

simonvandel added a commit to simonvandel/rust that referenced this pull request Sep 24, 2020
@simonvandel simonvandel mentioned this pull request Sep 24, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2020
…as-schievink

Rollup of 15 pull requests

Successful merges:

 - rust-lang#75438 (Use adaptive SVG favicon for rustdoc like other rust sites)
 - rust-lang#76304 (Make delegation methods of `std::net::IpAddr` unstably const)
 - rust-lang#76724 (Allow a unique name to be assigned to dataflow graphviz output)
 - rust-lang#76978 (Documented From impls in std/sync/mpsc/mod.rs)
 - rust-lang#77044 (Liballoc bench vec use mem take not replace)
 - rust-lang#77050 (Typo fix: "satsify" -> "satisfy")
 - rust-lang#77074 (add array::from_ref)
 - rust-lang#77078 (Don't use an if guard to check equality with a constant)
 - rust-lang#77079 (Use `Self` in docs when possible)
 - rust-lang#77081 (Merge two almost identical match arms)
 - rust-lang#77121 (Updated html_root_url for compiler crates)
 - rust-lang#77136 (Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`)
 - rust-lang#77160 (Suggest `const_fn_transmute`, not `const_fn`)
 - rust-lang#77164 (Remove workaround for deref issue that no longer exists.)
 - rust-lang#77165 (Followup to rust-lang#76673)

Failed merges:

r? `@ghost`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations merged-by-bors This PR was explicitly merged by bors. 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.