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

Take MIR dataflow analyses by mutable reference #108293

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Feb 21, 2023

The main motivation here is any analysis requiring dynamically sized scratch memory to work. One concrete example would be pointer target tracking, where tracking the results of a dereference can result in multiple possible targets. This leads to processing multi-level dereferences requiring the ability to handle a changing number of potential targets per step. A (simplified) function for this would be fn apply_deref(potential_targets: &mut Vec<Target>) which would use the scratch space contained in the analysis to send arguments and receive the results.

The alternative to this would be to wrap everything in a RefCell, which is what MaybeRequiresStorage currently does. This comes with a small perf cost and loses the compiler's guarantee that we don't try to take multiple borrows at the same time.

For the implementation:

  • AnalysisResults is an unfortunate requirement to avoid an unconstrained type parameter error.
  • CloneAnalysis could just be Clone instead, but that would result in more work than is required to have multiple cursors over the same result set.
  • ResultsVisitor now takes the results type on in each function as there's no other way to have access to the analysis without cloning it. This could use an associated type rather than a type parameter, but the current approach makes it easier to not care about the type when it's not necessary.
  • MaybeRequiresStorage now no longer uses a RefCell, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.

@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 2023

r? @eholk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 21, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 21, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rust-log-analyzer

This comment has been minimized.

@Jarcho Jarcho force-pushed the mut_analyses branch 2 times, most recently from 75e7dc9 to cdca6e2 Compare February 21, 2023 05:11
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 25, 2023

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

@eholk
Copy link
Contributor

eholk commented Mar 27, 2023

Hey, sorry for the delay in reviewing this! It looks pretty good to me, but unfortunately we've gotten some merge conflicts. If you go ahead and rebase it I can r+ it for you.

@apiraino
Copy link
Contributor

apiraino commented May 3, 2023

Switching to waiting on author to update this branch (sorry I only notice this now because the PR was still labelled as waiting on a review).

@Jarcho Feel free to request a review again with @rustbot ready, thanks!

@rustbot author

@rustbot rustbot 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 May 3, 2023
@Jarcho Jarcho force-pushed the mut_analyses branch 2 times, most recently from 9f519e6 to 5785cda Compare May 18, 2023 20:22
@rust-log-analyzer

This comment has been minimized.

@Jarcho
Copy link
Contributor Author

Jarcho commented May 19, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2023
@eholk
Copy link
Contributor

eholk commented Jun 8, 2023

Thanks for the rebase, and sorry about my delay in reviewing it. This looks good!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 8, 2023

📌 Commit eaddc37 has been approved by eholk

It is now in the queue for this repository.

@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 Jun 8, 2023
@bors
Copy link
Contributor

bors commented Jun 8, 2023

⌛ Testing commit eaddc37 with merge 68c8fda...

@bors
Copy link
Contributor

bors commented Jun 9, 2023

☀️ Test successful - checks-actions
Approved by: eholk
Pushing 68c8fda to master...

@bors
Copy link
Contributor

bors commented Jun 9, 2023

☀️ Test successful - checks-actions
Approved by: eholk
Pushing 68c8fda to master...

@bors bors added merged-by-bors This PR was explicitly merged by bors. labels Jun 9, 2023
@bors bors merged commit 68c8fda into rust-lang:master Jun 9, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 9, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (68c8fda): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [0.4%, 2.7%] 10
Regressions ❌
(secondary)
2.9% [2.7%, 3.0%] 2
Improvements ✅
(primary)
-1.3% [-1.3%, -1.3%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.2% [-1.3%, 2.7%] 11

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 649.476s -> 649.387s (-0.01%)

TaKO8Ki added a commit to TaKO8Ki/rust that referenced this pull request Jun 27, 2023
…r=oli-obk

Export AnalysisResults trait in rustc_mir_dataflow

Followup to rust-lang#108293
Re-exports the new trait defined in mentioned PR to make ResultsCursor::seek_before_primary_effect, ResultsCursor::seek_after_primary_effect... usable again outside the compiler itself.
TaKO8Ki added a commit to TaKO8Ki/rust that referenced this pull request Jun 27, 2023
…r=oli-obk

Export AnalysisResults trait in rustc_mir_dataflow

Followup to rust-lang#108293
Re-exports the new trait defined in mentioned PR to make ResultsCursor::seek_before_primary_effect, ResultsCursor::seek_after_primary_effect... usable again outside the compiler itself.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 27, 2023
…r=oli-obk

Export AnalysisResults trait in rustc_mir_dataflow

Followup to rust-lang#108293
Re-exports the new trait defined in mentioned PR to make ResultsCursor::seek_before_primary_effect, ResultsCursor::seek_after_primary_effect... usable again outside the compiler itself.
rust-cloud-vms bot pushed a commit to b-naber/rust that referenced this pull request Jun 29, 2023
floriangru added a commit to floriangru/creusot that referenced this pull request Jul 6, 2023
reuses rust-lang/rust#113089 and the corresponding nightly
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 4, 2023
Take `&mut Results` in `ResultsVisitor`

This fixes a small oversight from rust-lang#108293.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 5, 2023
Take `&mut Results` in `ResultsVisitor`

This fixes a small oversight from rust-lang#108293.
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants