Skip to content

Mir: refactor how scopes are represented #29768

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

Closed
nikomatsakis opened this issue Nov 11, 2015 · 2 comments
Closed

Mir: refactor how scopes are represented #29768

nikomatsakis opened this issue Nov 11, 2015 · 2 comments
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Mir currently tracks scopes using these graph extents. These are a pain. They are hard to keep in sync, for one thing, as we transform the MIR. I now think we should instead store, for each statement, the innermost scope. This will allow us to recover the full set of scopes for debuginfo, as well as computing whether a statement is in an unsafe block or what.

However, for borrowck, we also need to have scopes be grouped into continuous regions of the control-flow-graph, and we need to know as we exit a scope. For this purpose, the graph extents are tolerably good, or it seems useful to have a "SCOPE-ENTRY" and "SCOPE-EXIT" sort of statement. We might just do the borrowck before we do any optimization.

In a non-lexical lifetimes world, though, introducing SCOPE-ENTRY and SCOPE-EXIT statements for all regions would be horrible and a pain. So it seems better that we keep the notion of graph extents for the purposes of borrowck, and we just avoid changing the structure between computing graph extents and running borrowck -- or else we keep the graph extents up to date.

@nikomatsakis
Copy link
Contributor Author

cc @Doener @arielb1

@steveklabnik steveklabnik added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. labels Nov 11, 2015
@nikomatsakis
Copy link
Contributor Author

This work is ongoing, but I think this issue doesn't add much value, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants