-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Conversation
r? @eholk (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
This comment has been minimized.
This comment has been minimized.
75e7dc9
to
cdca6e2
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #106430) made this pull request unmergeable. Please resolve the merge conflicts. |
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. |
9f519e6
to
5785cda
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
Thanks for the rebase, and sorry about my delay in reviewing it. This looks good! @bors r+ |
☀️ Test successful - checks-actions |
☀️ Test successful - checks-actions |
Finished benchmarking commit (68c8fda): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 649.476s -> 649.387s (-0.01%) |
…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.
…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.
…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.
reuses rust-lang/rust#113089 and the corresponding nightly
Take `&mut Results` in `ResultsVisitor` This fixes a small oversight from rust-lang#108293.
Take `&mut Results` in `ResultsVisitor` This fixes a small oversight from rust-lang#108293.
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 whatMaybeRequiresStorage
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 beClone
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 aRefCell
, but the graphviz formatter now does. It could be removed, but that would require even more changes and doesn't really seem necessary.