-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Introduce drop range tracking to generator interior analysis #91032
Merged
Commits on Jan 18, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 4be32f8 - Browse repository at this point
Copy the full SHA 4be32f8View commit details -
Track drop points in generator_interior
This change adds the basic infrastructure for tracking drop ranges in generator interior analysis, which allows us to exclude dropped types from the generator type. Not yet complete, but many of the async/await and generator tests pass. The main missing piece is tracking branching control flow (e.g. around an `if` expression). The patch does include support, however, for multiple yields in th e same block. Issue rust-lang#57478
Configuration menu - View commit details
-
Copy full SHA for f712df8 - Browse repository at this point
Copy the full SHA f712df8View commit details -
Configuration menu - View commit details
-
Copy full SHA for c4dee40 - Browse repository at this point
Copy the full SHA c4dee40View commit details -
Make generator and async-await tests pass
The main change needed to make this work is to do a pessimistic over- approximation for AssignOps. The existing ScopeTree analysis in region.rs works by doing both left to right and right to left order and then choosing the most conservative ordering. This behavior is needed because AssignOp's evaluation order depends on whether it is a primitive type or an overloaded operator, which runs as a method call. This change mimics the same behavior as region.rs in generator_interior.rs. Issue rust-lang#57478
Configuration menu - View commit details
-
Copy full SHA for f664cfc - Browse repository at this point
Copy the full SHA f664cfcView commit details -
Attribute drop to parent expression of the consume point
This is needed to handle cases like `[a, b.await, c]`. `ExprUseVisitor` considers `a` to be consumed when it is passed to the array, but the array is not quite live yet at that point. This means we were missing the `a` value across the await point. Attributing drops to the parent expression means we do not consider the value consumed until the consuming expression has finished. Issue rust-lang#57478
Configuration menu - View commit details
-
Copy full SHA for f246c0b - Browse repository at this point
Copy the full SHA f246c0bView commit details -
This adds support for branching and merging control flow and uses this to correctly handle the case where a value is dropped in one branch of an if expression but not another. There are other cases we need to handle, which will come in follow up patches. Issue rust-lang#57478
Configuration menu - View commit details
-
Copy full SHA for aa029d4 - Browse repository at this point
Copy the full SHA aa029d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9611770 - Browse repository at this point
Copy the full SHA 9611770View commit details -
Configuration menu - View commit details
-
Copy full SHA for 298ca2f - Browse repository at this point
Copy the full SHA 298ca2fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4574152 - Browse repository at this point
Copy the full SHA 4574152View commit details -
Configuration menu - View commit details
-
Copy full SHA for ba7d127 - Browse repository at this point
Copy the full SHA ba7d127View commit details -
Revamped DropRange data structure
Not currently working. Need to flow drop information.
Configuration menu - View commit details
-
Copy full SHA for ff0e8f4 - Browse repository at this point
Copy the full SHA ff0e8f4View commit details -
Configuration menu - View commit details
-
Copy full SHA for c7afaa1 - Browse repository at this point
Copy the full SHA c7afaa1View commit details -
Fix control flow handling in generator_interior
All tests pass now! The issue was that we weren't handling all edges correctly, but now they are handled consistently. This includes code to dump a graphviz file for the CFG we built for drop tracking. Also removes old DropRanges tests.
Configuration menu - View commit details
-
Copy full SHA for b39fb9b - Browse repository at this point
Copy the full SHA b39fb9bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 904c270 - Browse repository at this point
Copy the full SHA 904c270View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5feb4d0 - Browse repository at this point
Copy the full SHA 5feb4d0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 46760b4 - Browse repository at this point
Copy the full SHA 46760b4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 006f547 - Browse repository at this point
Copy the full SHA 006f547View commit details -
1. Add test case for partial drops 2. Simplify code in `propagate_to_fixpoint` and remove most clones 3. Clean up PostOrderIndex creation
Configuration menu - View commit details
-
Copy full SHA for 30e1b1e - Browse repository at this point
Copy the full SHA 30e1b1eView commit details -
Splits drop_ranges into drop_ranges::record_consumed_borrow, drop_ranges::cfg_build, and drop_ranges::cfg_propagate. The top level drop_ranges module has an entry point that does all the coordination of the other three phases, using code original in generator_interior.
Configuration menu - View commit details
-
Copy full SHA for f5f98d7 - Browse repository at this point
Copy the full SHA f5f98d7View commit details -
This cleans up the refactoring from the previous patch and cleans things up a bit. Each module has a clear entry point and everything else is private.
Configuration menu - View commit details
-
Copy full SHA for 9347bf4 - Browse repository at this point
Copy the full SHA 9347bf4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6a28afb - Browse repository at this point
Copy the full SHA 6a28afbView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d82e4f - Browse repository at this point
Copy the full SHA 7d82e4fView commit details -
The refactoring mainly keeps the separation between the modules clearer. For example, process_deferred_edges function moved to cfg_build.rs since that is really part of building the CFG, not finding the fixpoint. Also, we use PostOrderId instead of usize in a lot more places now.
Configuration menu - View commit details
-
Copy full SHA for 2af02cf - Browse repository at this point
Copy the full SHA 2af02cfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4a70de7 - Browse repository at this point
Copy the full SHA 4a70de7View commit details -
Explicitly list all ExprKinds in cfg_build
Also rearranges the existing arms to be more logical. For example, Break and Continue come closer to Loop now.
Configuration menu - View commit details
-
Copy full SHA for 6e281a7 - Browse repository at this point
Copy the full SHA 6e281a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for a7df4e8 - Browse repository at this point
Copy the full SHA a7df4e8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7d11b33 - Browse repository at this point
Copy the full SHA 7d11b33View commit details -
Track changed bitsets in CFG propagation
This reduces the amount of work done, especially in later iterations, by only processing nodes whose predecessors changed in the previous iteration, or earlier in the current iteration. This also has the side effect of completely ignoring all unreachable nodes.
Configuration menu - View commit details
-
Copy full SHA for f730bd0 - Browse repository at this point
Copy the full SHA f730bd0View commit details -
Handle uninhabited return types
This changes drop range analysis to handle uninhabited return types such as `!`. Since these calls to these functions do not return, we model them as ending in an infinite loop.
Configuration menu - View commit details
-
Copy full SHA for 787f4cb - Browse repository at this point
Copy the full SHA 787f4cbView commit details -
The previous commit made the non_sync_with_method_call case pass due to the await being unreachable. Unfortunately, this isn't actually the behavior the test was verifying. This change lifts the panic into a helper function so that the generator analysis still thinks the await is reachable, and therefore we preserve the same testing behavior.
Configuration menu - View commit details
-
Copy full SHA for 887e843 - Browse repository at this point
Copy the full SHA 887e843View commit details -
drop_ranges: Add TrackedValue enum
This makes it clearer what values we are tracking and why.
Configuration menu - View commit details
-
Copy full SHA for 78c5644 - Browse repository at this point
Copy the full SHA 78c5644View commit details -
We previously weren't tracking partial re-inits while being too aggressive around partial drops. With this change, we simply ignore partial drops, which is the safer, more conservative choice.
Configuration menu - View commit details
-
Copy full SHA for 32930d9 - Browse repository at this point
Copy the full SHA 32930d9View commit details -
Configuration menu - View commit details
-
Copy full SHA for e0a5370 - Browse repository at this point
Copy the full SHA e0a5370View commit details -
Configuration menu - View commit details
-
Copy full SHA for d840d0c - Browse repository at this point
Copy the full SHA d840d0cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 76f6b57 - Browse repository at this point
Copy the full SHA 76f6b57View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.