Skip to content

Remove some Regions from HAIR #56638

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

Merged
merged 1 commit into from
Jan 8, 2019
Merged

Conversation

matthewjasper
Copy link
Contributor

@matthewjasper matthewjasper commented Dec 8, 2018

Use ReErased for any regions that need to be created in RValue::Ref
in MIR generation. We will change them to all to ReVar before borrow
checking anyway.

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2018
@matthewjasper
Copy link
Contributor Author

@bors try - want to check perf

@bors
Copy link
Collaborator

bors commented Dec 8, 2018

⌛ Trying commit 1bfa367e19efaa5f670378c482e5c03652932c31 with merge 7c4c3b8da31eead5a65508346fe8352b7ef85023...

@matthewjasper
Copy link
Contributor Author

@bors try

@bors
Copy link
Collaborator

bors commented Dec 8, 2018

⌛ Trying commit 74d3462 with merge 34d39ce...

bors added a commit that referenced this pull request Dec 8, 2018
Remove `Region` from `mir::Rvalue::Ref`

This was only used for borrow checking, but we will create a fresh
`RegionVid` for each borrow anyway, so there's no need for us to store
it in the MIR.

Also removes `Region`s from various places where they're no longer
needed. Uses `ReErased` for any regions that need to be created in
MIR generation.

r? @nikomatsakis
@rust-highfive

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 8, 2018

☀️ Test successful - status-travis
State: approved= try=True

@matthewjasper
Copy link
Contributor Author

@rust-lang/infra Please can I have a perf run?

@pietroalbini
Copy link
Member

@rust-timer build 34d39ce

@rust-timer
Copy link
Collaborator

Success: Queued 34d39ce with parent 9772d02, comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 34d39ce

@matthewjasper
Copy link
Contributor Author

Hmm, results aren't great. This seems to have affected incremental for the worse.

@Mark-Simulacrum
Copy link
Member

Those benchmarks are high-variance -- I would expect that any delta seen is just noise. If this is not intended as a performance optimization, then the performance aspect can be ignored; it has not changed.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Not sure what I think yet -- see below. I'd like to ponder it and/or discuss the motivation a bit =)

let place_ty = place.ty(local_decls, tcx).to_ty(tcx);
tcx.mk_ref(reg,
tcx.mk_ref(tcx.types.re_erased,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I'm not sure how I feel about this. It seems to add some non-trivial complexity that the result of rvalue.ty cannot be used in the type-checker and kind of may introduce erased regions, even when all regions that appear in the MIR have been "renumbered".

What's the motivation exactly for removing this from the MIR? (As opposed to (eventually) encoding a 'erased 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.

The reason for this was that it seemed a bit wasteful to have Regions that are almost always erased in MIR (which was my original intention).

@@ -1962,6 +1970,8 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
| Rvalue::UnaryOp(..)
| Rvalue::Discriminant(..) => {}
}

rvalue.ty(mir, tcx)
Copy link
Contributor

Choose a reason for hiding this comment

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

...this is the case that bothers me. Now we have to know that sometimes we can use this, sometimes we can't...

@nikomatsakis
Copy link
Contributor

Sorry for leaving this for so long. I appreciate the motivation here, but it doesn't quite feel worth it to me. Soon enough, all regions will be erased anyway, so we're just saving a word. (Maybe we can even make the MIR parametric over the region type at some point.)

Curious to hear what @pnkfelix or other @rust-lang/wg-compiler-nll folks think.

Use `ReErased` for any regions that need to be created in RValue::Ref
in MIR generation.
@matthewjasper matthewjasper changed the title Remove Region from mir::Rvalue::Ref Remove some Regions from HAIR Jan 5, 2019
@matthewjasper
Copy link
Contributor Author

Region is now back in Rvalue::Ref

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 8, 2019

📌 Commit 4f3c469 has been approved by nikomatsakis

@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 Jan 8, 2019
@bors
Copy link
Collaborator

bors commented Jan 8, 2019

⌛ Testing commit 4f3c469 with merge d22fa2d...

bors added a commit that referenced this pull request Jan 8, 2019
Remove some `Region`s from HAIR

Use `ReErased` for any regions that need to be created in RValue::Ref
in MIR generation. We will change them to all to `ReVar` before borrow
checking anyway.

r? @nikomatsakis
@bors
Copy link
Collaborator

bors commented Jan 8, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing d22fa2d to master...

@bors bors merged commit 4f3c469 into rust-lang:master Jan 8, 2019
@matthewjasper matthewjasper deleted the remove-ref-region branch February 3, 2019 08:41
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.

7 participants