-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Combine HaveBeenBorrowedLocals
and IndirectlyMutableLocals
into one dataflow analysis
#69113
Combine HaveBeenBorrowedLocals
and IndirectlyMutableLocals
into one dataflow analysis
#69113
Conversation
This impl is temporary and will be removed along with the old dataflow framework. It allows us to reuse the transfer function of new dataflow analyses when defining old ones
`MaybeMutBorrowedLocals` serves the same purpose and has a better name.
This uses the new `MaybeMutBorrowedLocals` pass but we keep the `rustc_peek_indirectly_mutable` since the two are interchangable except when inspecting a local after it has been marked `StorageDead`.
It should have the same semantics as `HaveBeenBorrowedLocals`
r? @davidtwco (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
e7d839d
to
0984639
Compare
This comment has been minimized.
This comment has been minimized.
r? @wesleywiser |
@ecstatic-morse Do you there there is the possibility for a compiler performance change here? Should we do a perf run before landing this? |
@wesleywiser It is unlikely. Switching from the old to the new framework for the "initialized places" analyses yielded very small gains, but the "borrowed" analyses are used only for const-checking and generators respectively. The perf queue is a bit full right now, otherwise I would do one just in case. Perhaps rollup=never is sufficient? |
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.
Looks great to me!
@bors r+ rollup=never |
📌 Commit 077a93c has been approved by |
🌲 The tree is currently closed for pull requests below priority 100, this pull request will be tested once the tree is reopened |
@bors p=1 |
…sleywiser Combine `HaveBeenBorrowedLocals` and `IndirectlyMutableLocals` into one dataflow analysis This PR began as an attempt to port `HaveBeenBorrowedLocals` to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code with `IndirectlyMutableLocals` and then found a few bugs in the two analyses: - Neither one marked locals as borrowed after an `Rvalue::AddressOf`. - `IndirectlyMutableLocals` was missing a minor fix that `HaveBeenBorrowedLocals` got in #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day. I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called `MaybeBorrowedLocals` and `MaybeMutBorrowedLocals` to be consistent with the `Maybe{Un,}InitializedPlaces` naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).
☀️ Test successful - checks-azure |
This PR began as an attempt to port
HaveBeenBorrowedLocals
to the new dataflow framework (see #68241 for prior art). Along the way, I noticed that it could share most of its code withIndirectlyMutableLocals
and then found a few bugs in the two analyses:Rvalue::AddressOf
.IndirectlyMutableLocals
was missing a minor fix thatHaveBeenBorrowedLocals
got in Make MIR drop terminators borrow the dropped location #61069. This is not a problem today since it is only used during const-checking, where custom drop glue is forbidden. However, this may change some day.I decided to combine the two analyses so that they wouldn't diverge in the future while ensuring that they remain distinct types (called
MaybeBorrowedLocals
andMaybeMutBorrowedLocals
to be consistent with theMaybe{Un,}InitializedPlaces
naming scheme). I fixed the bugs and switched to exhaustive matching where possible to make them less likely in the future. Finally, I added comments explaining some of the finer points of the transfer function for these analyses (see #61069 and #65006).