-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Put Local, Static and Promoted as one Base variant of Place #58631
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Note that this will cause a max-rss regression, so we'll merge it after the beta cutoff, so we have 6 weeks to fix it (which should happen with the enum Place
-> struct Place
refactoring discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/place.202.2E0/near/159082516
@@ -1813,7 +1815,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'tcx> { | |||
let tcx = self.infcx.tcx; | |||
match place { | |||
Place::Local(_) | Place::Static(_) | Place::Promoted(_) => { | |||
Place::Base(PlaceBase::Local(_)) | | |||
Place::Base(PlaceBase::Static(_)) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the indent is off here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, vim does that :). Fixing it.
@@ -1910,7 +1915,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
"annotate_argument_and_return_for_borrow: target={:?} stmt={:?}", | |||
target, stmt | |||
); | |||
if let StatementKind::Assign(Place::Local(assigned_to), box rvalue) = &stmt.kind | |||
if let StatementKind::Assign( | |||
Place::Base(PlaceBase::Local(assigned_to)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd indentation here. Maybe write
if let StatementKind::Assign(
Place::Base(PlaceBase::Local(assigned_to)),
box rvalue,
) = &stmt.kind {
@@ -384,7 +384,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { | |||
// Just point to the function, to reduce the chance of overlapping spans. | |||
let function_span = match func { | |||
Operand::Constant(c) => c.span, | |||
Operand::Copy(Place::Local(l)) | Operand::Move(Place::Local(l)) => { | |||
Operand::Copy(Place::Base(PlaceBase::Local(l))) | | |||
Operand::Move(Place::Base(PlaceBase::Local(l))) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the same indent as the Operand::Copy
Operand::Copy(Place::Local(from)) | | ||
Operand::Move(Place::Local(from)) if *from == target => { | ||
Operand::Copy(Place::Base(PlaceBase::Local(from))) | | ||
Operand::Move(Place::Base(PlaceBase::Local(from))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
Operand::Copy(Place::Local(from)) | | ||
Operand::Move(Place::Local(from)) if *from == target => { | ||
Operand::Copy(Place::Base(PlaceBase::Local(from))) | | ||
Operand::Move(Place::Base(PlaceBase::Local(from))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
Place::Static(_) => { | ||
Place::Base(PlaceBase::Promoted(_)) | | ||
Place::Base(PlaceBase::Local(_)) | // search yielded this leaf | ||
Place::Base(PlaceBase::Static(_)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, just use the Place::Base(_)
pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
||
// initialize the box contents: | ||
unpack!(block = this.into(&Place::Local(result).deref(), block, value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pull Place::Local(result)
into a variable before this statement and use that variable here and in the next statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deref
takes ownership so that's not possible
src/librustc_mir/build/mod.rs
Outdated
@@ -956,7 +956,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { | |||
} | |||
|
|||
let body = self.hir.mirror(ast_body); | |||
self.into(&Place::Local(RETURN_PLACE), block, body) | |||
self.into(&Place::Base(PlaceBase::Local(RETURN_PLACE)), block, body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a Place::RETURN_PLACE
associated constant to Place
to make all of these Place::Base(PlaceBase::Local(RETURN_PLACE))
shorter.
Local { .. } | | ||
Promoted { .. } | | ||
Static { .. } => | ||
Base(PlaceBase::Local { .. }) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use Base(_)
let length_or_end = if ptr_based { | ||
Place::Local(self.new_temp(iter_ty)) | ||
Place::Base(PlaceBase::Local(self.new_temp(iter_ty))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a FIXME to new_temp
to check if we want to make it return a Place
directly if all use sites want a Place::Base
anyway.
☔ The latest upstream changes (presumably #56113) made this pull request unmergeable. Please resolve the merge conflicts. |
7e9b0f8
to
4b9d48f
Compare
@oli-obk fixed, rebased and force pushed :). |
@bors r+ |
📌 Commit 4b9d48f0a4f006480f64bb16b56714fef9f66db3 has been approved by |
@bors p=1 |
@oli-obk What happened to this? |
⌛ Testing commit 4b9d48f0a4f006480f64bb16b56714fef9f66db3 with merge 8601df9996e847f042bc7a4c9d97fad4b6b0448a... |
💔 Test failed - checks-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
☔ The latest upstream changes (presumably #57609) made this pull request unmergeable. Please resolve the merge conflicts. |
3534f50
to
4cfe141
Compare
@oli-obk just in case conversation in Zulip went unnoticed. This is ready to r+. |
@bors r+ |
Seems to be a bit-rotty PR, so @bors p=20 |
@bors r+ |
📌 Commit 0f993d5 has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
Tested on commit rust-lang/rust@17add24. Direct link to PR: <rust-lang/rust#58631> 💔 miri on windows: test-fail → build-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra). 💔 miri on linux: test-fail → build-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
Place::Local(x) is now Place::Base(PlaceBase::Local(x)) We need to merge this after the beta cut for this rust-lang/rust#58631 to work. /cc @oli-obk
FWIW, I was just looking at peak memory usage and I identified the In other words, I noticed this change. |
@nnethercote this was an intermediate step, we are going after this ... struct Place {
base: PlaceBase,
projection: PlaceProjection,
}
enum PlaceProjection {
Base,
Projection(Box<PlaceProjection>),
Deref,
Index(..),
...
} Going to provide a PR for this probably this week. |
That's makes |
Since the final layout will be struct Place<'tcx> {
base: PlaceBase,
projection: &'tcx [PlaceProjection],
}
enum PlaceProjection {
Projection(Box<PlaceProjection>),
Deref,
Index(..),
...
} we can also box I think that ideally we'd be able to have all occurences of struct Place {
base: PlaceBase,
projection: [PlaceProjection],
} But I don't know how to initialize such a type without statically knowing the length of the |
FWIW Also, we shouldn't combine the base and the projections, IMO. |
I expect And a @nnethercote Does that work for you? |
Yes, sorry. I've pasted an intermediate step. The final layout as @eddyb has said is ... struct Place<'tcx> {
base: PlaceBase,
projection: &'tcx [PlaceProjection],
}
enum PlaceProjection {
Projection(Box<PlaceProjection>),
Deref,
Index(..),
...
} |
Not quite, @eddyb is right, struct Place<'tcx> {
base: PlaceBase,
projection: &'tcx ty::List<PlaceProjection>,
}
enum PlaceProjection {
Projection(Box<PlaceProjection>),
Deref,
Index(..),
...
} |
What is the point of the recursive |
Ups, that's just a copy paste bug. In the enum Place {
Base(PlaceBase)
Projection(Box<PlaceProjection>),
}
struct PlaceProjection {
base: Place,
projection: PlaceProjectionElem,
}
enum PlaceProjectionElem {
Leaf,
Deref,
Index(..),
...
} while the target situation is struct Place {
base: PlaceBase
projections: &'tcx ty::List<PlaceProjectionElem>,
}
// Note: no more PlaceProjection
enum PlaceProjectionElem {
// Note: no more "Leaf"
Deref,
Index(..),
...
} |
I'm a bit confused by all the above back and forth. |
@nnethercote The plan is for it to become 16 bytes ( But also, |
Yeah, sorry my bad I was confusing you a lot. Thanks @eddyb for clarying it. |
I can see that an array is better than a linked list. But note that the size of Anyway, if the final size will be 16 bytes, that's great. |
Related to #52708
The
Place
2.0 representation use aBase
variant forLocal
,Static
andPromoted
so we start making this change in the currentPlace
to make the following steps simpler.r? @oli-obk