-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Do not used Move data flow analysis, make it lazy instead #53403
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
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
@bors try |
☀️ Test successful - status-travis |
@rust-timer build fef1950 |
Success: Queued fef1950 with parent 0f4b498, comparison URL. |
Perf is ready. |
fdbdd51
to
2c2b166
Compare
2c2b166
to
725774a
Compare
725774a
to
ee1b780
Compare
@@ -42,7 +42,7 @@ use dataflow::DataflowResultsConsumer; | |||
use dataflow::FlowAtLocation; | |||
use dataflow::MoveDataParamEnv; | |||
use dataflow::{do_dataflow, DebugFormatted}; | |||
use dataflow::{EverInitializedPlaces, MovingOutStatements}; |
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.
We should also be able to remove the definition of MovingOutStatements
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.
👍, done!
for ii in &self.move_data.init_loc_map[l] { | ||
if self.move_data.inits[*ii].path == mpi { | ||
continue 'dfs; | ||
} |
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 should probably be instead:
use rustc_mir::dataflow::drop_flag_effects;
let mut any_match = false;
drop_flag_effects::for_location_inits(
self.tcx,
self.mir,
self.move_data,
l,
|m| if m == mpi { any_match = true; },
);
This is a helper function that does the walk for you.
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.
That said, there is a subtle case around call returns which I fear this code may get wrong, but I have to think about the example (in particular, for_local_inits
does not walk the initializations due to a call return).
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.
Pushed with your changes to see what happens, but we would need to see the case you're mentioning to see if this code covers that or not.
c66e02b
to
6f30ed9
Compare
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 |
stack.push(l); | ||
} else { | ||
stack.push(Location { block: l.block, statement_index: l.statement_index - 1 }); | ||
} |
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.
As I pointed out on Zulip, this code looks wrong to me. I think you want to add the predecessors_for
function that I spelled out there.
2060884
to
dfaf64a
Compare
@spastorino and I discussed on Zulip. We concluded that the new output is better than the old one, although both could be considered correct. I wanted them to add a comment which I will note here. |
if self.move_data.moves[*moi].path == mpi { | ||
debug!("report_use_of_moved_or_uninitialized: found"); | ||
result.push(*moi); | ||
continue 'dfs; |
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.
Suggested comment:
// Strictly speaking, we could continue our DFS here. There may be
// other moves that can reach the point of error. But it is kind of confusing
// to highlight them.
//
// Example:
//
// ```
// let a = vec![];
// let b = a;
// let c = a;
// drop(a); // <-- current point of error
// ```
//
// Because we stop the DFS here, we only highlight `let c = a`,
// and not `let b = a`. We will of course also report an error at `let c = a`
// which highlights `let b = a` as the move.
ba06cc7
to
3043310
Compare
3043310
to
a6aa5dd
Compare
@bors r+ |
📌 Commit a6aa5dd has been approved by |
Do not used Move data flow analysis, make it lazy instead Close #53394
☀️ Test successful - status-appveyor, status-travis |
Close #53394