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

Limit storage duration of inlined always live locals #79027

Merged
merged 1 commit into from
Nov 17, 2020

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Nov 13, 2020

Closes #76375.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 13, 2020
@tmiasko tmiasko changed the title Limit storage duration of always live locals in inlined functions Limit storage duration of inlined always live locals Nov 13, 2020
@tmiasko tmiasko force-pushed the inline-always-live-locals branch 3 times, most recently from 6569ec7 to 832d02d Compare November 13, 2020 19:42
compiler/rustc_mir/src/transform/inline.rs Outdated Show resolved Hide resolved
Comment on lines 73 to 76
// FIXME: MIR optimization that run at mir-opt-level >= 2 might remove storage makers for
// some locals. This breaks compatibility with state transform that runs after inlining.
// As a workaround, we give such locals a storage for the duration of the call.
insert_storage_markers: tcx.sess.opts.debugging_opts.mir_opt_level >= 2,
Copy link
Contributor

Choose a reason for hiding this comment

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

So the real fix would be to make sure we do not lose storage markers? Are you sure it's lost storage markers and not simply "never added" ones? I was sure we have lots of locals without storage markers.

Or maybe we should just go for full #68622 anyway...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the real fix would be to make sure we do not lose storage markers?

This is what I had in mind originally, but we can also consider it to be a valid transformation even if it is suboptimal.

I was sure we have lots of locals without storage markers.

Locals marked as internal do not participate in validation performed by the state transform. Though, In that context I think it makes sense to always limit storage of those locals simply to help stack space optimizations.

maybe we should just go for full #68622 anyway...

It is unclear to me how the end of storage could be determined, especially for any local whose address escapes at some point.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is unclear to me how the end of storage could be determined, especially for any local whose address escapes at some point.

Ah, we'd still have a "StorageDead" of sorts: InvalidateBorrows. It's not quite the same thing, but it will allow us to figure out that if we manually computed a StorageDead, it could not be before an InvalidateBorrows of the same local.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 14, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Nov 14, 2020

📌 Commit e7b6b61 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 Nov 14, 2020
@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 14, 2020

Blocked on #78966 (tests need to be updated after it lands).

@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 15, 2020

Updated tests. This is now unblocked.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 15, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Nov 15, 2020

📌 Commit f27d56d has been approved by oli-obk

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Nov 17, 2020
…r=oli-obk

Limit storage duration of inlined always live locals

Closes rust-lang#76375.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 17, 2020
Rollup of 9 pull requests

Successful merges:

 - rust-lang#77939 (Ensure that the source code display is working with DOS backline)
 - rust-lang#78138 (Upgrade dlmalloc to version 0.2)
 - rust-lang#78967 (Make codegen tests compatible with extra inlining)
 - rust-lang#79027 (Limit storage duration of inlined always live locals)
 - rust-lang#79077 (document that __rust_alloc is also magic to our LLVM fork)
 - rust-lang#79088 (clarify `span_label` documentation)
 - rust-lang#79097 (Code block invalid html tag lint)
 - rust-lang#79105 (std: Fix test `symlink_hard_link` on Windows)
 - rust-lang#79107 (build-manifest: strip newline from rustc version)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 336dc18 into rust-lang:master Nov 17, 2020
@rustbot rustbot added this to the 1.50.0 milestone Nov 17, 2020
@tmiasko tmiasko deleted the inline-always-live-locals branch November 17, 2020 12:03
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.

Broken MIR: generator contains type ... after copy & destination propagation
6 participants