Skip to content
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

Extend Polonius fact generation for (some) move tracking #62800

Merged
merged 8 commits into from
Sep 5, 2019
Merged

Extend Polonius fact generation for (some) move tracking #62800

merged 8 commits into from
Sep 5, 2019

Conversation

amandasystems
Copy link
Contributor

This PR will extend rustc to emit facts used for tracking moves and initialization in Polonius. It is most likely the final part of my master's thesis work.

@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 19, 2019
@amandasystems
Copy link
Contributor Author

r? @nikomatsakis

(for now!)

@rust-highfive

This comment has been minimized.

@joelpalmer
Copy link

Ping from triage. This PR is in need of review. Should it be re-assigned? @nikomatsakis @cramertj
cc: @AlbinS

@amandasystems
Copy link
Contributor Author

Ping from triage. This PR is in need of review. Should it be re-assigned? @nikomatsakis @cramertj
cc: @AlbinS

@joelpalmer Thanks for asking, but it's still very WIP; the fact generation is currently slightly wrong. I expect to fix it this week, but there are probably more issues than that hiding behind that issue.

However, before this PR can be merged, Polonius needs to be updated from another branch (I will rebase and fixup the commit using my local Polonius to in stead pull the new release).

So in short; I suspect @nikomatsakis might be back from their vacation before I'm done. If not, I'll ask around in the Polonius working group. Please don't reassign for now, thank you!

@jonas-schievink jonas-schievink added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 29, 2019
@bors
Copy link
Contributor

bors commented Aug 2, 2019

☔ The latest upstream changes (presumably #61393) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-highfive

This comment has been minimized.

@amandasystems
Copy link
Contributor Author

This pull request is waiting for rust-lang/polonius#110 to be merged into Polonius.

@rust-highfive

This comment has been minimized.

@hdhoang hdhoang added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 16, 2019
@hdhoang
Copy link
Contributor

hdhoang commented Aug 16, 2019

Thank you for your update, triage-wg have updated this PR's label accordingly.

@rust-highfive

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 19, 2019

☔ The latest upstream changes (presumably #63579) made this pull request unmergeable. Please resolve the merge conflicts.

Albin Stjerna added 7 commits September 4, 2019 09:44
- var_starts_path
- parent
- initialized_at
- moved_out_at

This also switches to the intended emission of `var_drop_used` fact emission,
where that fact is always emitted on a drop-use of a variable, regardless of its
initialization status, as Polonius now handles that.
@amandasystems amandasystems changed the title [WIP] Extend Polonius fact generation for (some) move tracking Extend Polonius fact generation for (some) move tracking Sep 4, 2019
@amandasystems
Copy link
Contributor Author

r? @nikomatsakis

Ready for review, as rust-lang/polonius#110 has landed! 🎉

This should be enough facts to implement move analysis and liveness tracking in Polonius, meaning that an entire new part of the Polonius analysis is finally fully unlocked!

@rust-highfive

This comment has been minimized.

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Sep 4, 2019
all_facts.var_starts_path.extend(move_data.rev_lookup.iter_locals_enumerated().map(|(v, &m)| (v, m)));

for (idx, move_path) in move_data.move_paths.iter_enumerated() {
all_facts.parent.extend(move_path.parents(&move_data.move_paths).iter().map(|&parent| (parent, idx)));
Copy link
Contributor

Choose a reason for hiding this comment

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

as noted in the polonius PR, ultimately I think we should leave the transitive computation here to polonius. But I guess I don't wnat to do that in this PR.

// The initialization happened in (or rather, when arriving at)
// the successors, but not in the unwind block.
let first_statement = Location { block: successor, statement_index: 0};
all_facts.initialized_at.push((init.path, location_table.start_index(first_statement)));
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting quirk. I guess this makes sense.

Copy link
Contributor Author

@amandasystems amandasystems Sep 4, 2019

Choose a reason for hiding this comment

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

Let's just say I scratched my head for quite some time before I figured out why this happened. The results were completely wrong otherwise. If you are curious about the details, there's a ton of logs on Zulip where I figure this out in the initialization topic.

self.path_accessed_at.push((path, self.location_to_index(location)));
}

fn place_to_mpi(&self, place: &Place<'_>) -> Option<MovePathIndex> {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be nice to have some docs here -- when does this return None?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it is when the place is rooted in a static, though

@nikomatsakis
Copy link
Contributor

I'm not going to block on those nits. Doesn't seem worth it.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 4, 2019

📌 Commit 28312b5 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 Sep 4, 2019
@bors
Copy link
Contributor

bors commented Sep 5, 2019

⌛ Testing commit 28312b5 with merge b6eac35c6f9719fb329d9f6c259eda2c47f6fff8...

@bors
Copy link
Contributor

bors commented Sep 5, 2019

💔 Test failed - checks-azure

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-09-05T01:56:52.8631531Z test vec.rs - vec::Vec<T>::with_capacity (line 339) ... ok
2019-09-05T01:56:52.8634946Z 
2019-09-05T01:56:52.8638137Z failures:
2019-09-05T01:56:52.8639846Z 
2019-09-05T01:56:52.8649490Z ---- prelude/mod.rs - prelude (line 6) stdout ----
2019-09-05T01:56:52.8651457Z error[E0523]: found two different crates with name `alloc` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two.
2019-09-05T01:56:52.8651840Z  --> prelude/mod.rs:8:1
2019-09-05T01:56:52.8652019Z 5 | extern crate alloc;
2019-09-05T01:56:52.8652507Z   | ^^^^^^^^^^^^^^^^^^^
2019-09-05T01:56:52.8652589Z 
2019-09-05T01:56:52.8652656Z error: aborting due to previous error
2019-09-05T01:56:52.8652656Z error: aborting due to previous error
2019-09-05T01:56:52.8652720Z 
2019-09-05T01:56:52.8653060Z Couldn't compile the test.
2019-09-05T01:56:52.8653403Z ---- raw_vec.rs - raw_vec::RawVec<T, A>::double (line 261) stdout ----
2019-09-05T01:56:52.8654097Z error[E0523]: found two different crates with name `alloc` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two.
2019-09-05T01:56:52.8654844Z  --> raw_vec.rs:263:1
2019-09-05T01:56:52.8655005Z 4 | extern crate alloc;
2019-09-05T01:56:52.8655214Z   | ^^^^^^^^^^^^^^^^^^^
2019-09-05T01:56:52.8655270Z 
2019-09-05T01:56:52.8655355Z error: aborting due to previous error
2019-09-05T01:56:52.8655355Z error: aborting due to previous error
2019-09-05T01:56:52.8655402Z 
2019-09-05T01:56:52.8655705Z Couldn't compile the test.
2019-09-05T01:56:52.8656017Z ---- raw_vec.rs - raw_vec::RawVec<T, A>::reserve (line 466) stdout ----
2019-09-05T01:56:52.8656482Z error[E0523]: found two different crates with name `alloc` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two.
2019-09-05T01:56:52.8656775Z  --> raw_vec.rs:468:1
2019-09-05T01:56:52.8656934Z 4 | extern crate alloc;
2019-09-05T01:56:52.8657021Z   | ^^^^^^^^^^^^^^^^^^^
2019-09-05T01:56:52.8657078Z 
2019-09-05T01:56:52.8657161Z error: aborting due to previous error
---
2019-09-05T01:56:52.8811600Z == clock drift check ==
2019-09-05T01:56:52.8828346Z   local time: Thu Sep  5 01:56:52 UTC 2019
2019-09-05T01:56:53.0500684Z   network time: Thu, 05 Sep 2019 01:56:53 GMT
2019-09-05T01:56:53.0503670Z == end clock drift check ==
2019-09-05T01:56:53.5693162Z ##[error]Bash exited with code '1'.
2019-09-05T01:56:53.5770296Z ##[section]Starting: Upload CPU usage statistics
2019-09-05T01:56:53.5775860Z ==============================================================================
2019-09-05T01:56:53.5775991Z Task         : Bash
2019-09-05T01:56:53.5776060Z Description  : Run a Bash script on macOS, Linux, or Windows

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 @TimNN. (Feature Requests)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 5, 2019
@Centril
Copy link
Contributor

Centril commented Sep 5, 2019

@bors retry probably spurious

@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 Sep 5, 2019
@bors
Copy link
Contributor

bors commented Sep 5, 2019

⌛ Testing commit 28312b5 with merge 9776723...

bors added a commit that referenced this pull request Sep 5, 2019
Extend Polonius fact generation for (some) move tracking

This PR will extend rustc to emit facts used for tracking moves and initialization in Polonius. It is most likely the final part of my master's thesis work.
@bors
Copy link
Contributor

bors commented Sep 5, 2019

☀️ Test successful - checks-azure
Approved by: nikomatsakis
Pushing 9776723 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 5, 2019
@bors bors merged commit 28312b5 into rust-lang:master Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

10 participants