-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
NLL: experiment with inverting liveness #53314
Conversation
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 |
809bc05
to
49b6773
Compare
@bors try |
☀️ Test successful - status-travis |
@rust-timer build 0d2e1bf |
Success: Queued 0d2e1bf with parent d5a448b, comparison URL. |
Looks nice, except for |
Curious. I suspect that is not meaningful, though, since NLL is not enabled in that configuration. Still...weird. |
OK, well, this seems to have enough widespread benefits to be worth landing. |
|
||
/// A little data structure that makes it more efficient to find the | ||
/// predecessors of each point. | ||
crate struct PointIndexMap<'me, 'tcx> { |
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.
oh, hmm, I had thought about removing this code and merging this into RegionValueElements
. Maybe I should do that before landing.
/// read or modified. e.g., `y` is used in `x = y` but not `x`. | ||
first_use_at: IndexVec<LocalWithRegion, Option<AppearanceIndex>>, | ||
|
||
/// Head of a linked list of **uses** of each variable -- use in |
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.
this comment seems like it needs a sed -e 's/use/drop/g
, no?
/// read or modified. e.g., `y` is used in `x = y` but not `x`. | ||
first_drop_at: IndexVec<LocalWithRegion, Option<AppearanceIndex>>, | ||
|
||
appearances: IndexVec<AppearanceIndex, Appearance>, |
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.
silly question: there is an invariant that the linked lists formed in this store of Appearances
never share tails, right? At first I had thought there might be some reason that you used a single datatype for all three of the lists above, but now I'm figuring it must just be expedience, right?
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 expedience. Originally I thought I would have to do more forms of inter-linking -- i.e., maybe I would want to iterate not just "all places that a local is used" but also "all locals used at this place" -- but that did not turn out to be true. If that had been true, then I think a single type might have been more useful.
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
my gut reaction is: "Is this somehow reinventing a dataflow analysis that we don't currently support because our dataflow infrastructure only supports forward-flows?" Maybe I'm missing something crucially different that a hypothetical generalized dataflow could not provide. (Or maybe its simpler to just write some one-off code like this for now until we have at least two analyses that require a backward flow...) |
No, this is one iteration past that. In particular, But what this code does is to rewrite that. In particular, instead of computing the "set of live variables at a given block" we now answer the question "for which blocks is a variable live". This turns out to be a better question to answer efficiency wise (though not by that much) -- in part because the resulting bitset is exactly what our regions want as input (whereas with the older style, we had to "invert" the result). |
Ah yes. That is a pretty important (and succinct) insight. |
@pnkfelix I added the comments you requested. I think I will (a) rebase and then (b) try to do one more "cleanup" pass on the code. I guess your final comment means that you at least agree with the general concept of this PR? :) |
0671a53
to
4b76fe2
Compare
This comment has been minimized.
This comment has been minimized.
4b76fe2
to
2bd4ba5
Compare
@nikomatsakis hmm I thought I had put a comment on here with an r=me once xyz is addressed. Well I'll try to double-check the commit series tomorrow to make sure I'm not mixing this up with a different PR. |
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 |
4aed373
to
2a37e03
Compare
f4e0e0c
to
09feec6
Compare
@bors r=pnkfelix |
📌 Commit 09feec6 has been approved by |
⌛ Testing commit 09feec6 with merge b51bd0babd32f4e50d7ee895d9b1dded660b376d... |
💔 Test failed - status-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 |
which does not have as many feature gates enabled.
@bors r+ |
📌 Commit 8d231ec has been approved by |
☀️ Test successful - status-appveyor, status-travis |
I got inspired to see what would happen here.
Fixes #52460
r? @pnkfelix