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

Introduce drop range tracking to generator interior analysis #91032

Merged
merged 35 commits into from
Jan 21, 2022

Commits on Jan 18, 2022

  1. Add test case for rust-lang#57478

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    4be32f8 View commit details
    Browse the repository at this point in the history
  2. 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
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    f712df8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c4dee40 View commit details
    Browse the repository at this point in the history
  4. 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
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    f664cfc View commit details
    Browse the repository at this point in the history
  5. 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
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    f246c0b View commit details
    Browse the repository at this point in the history
  6. Support conditional drops

    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
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    aa029d4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    9611770 View commit details
    Browse the repository at this point in the history
  8. Basic loop support

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    298ca2f View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4574152 View commit details
    Browse the repository at this point in the history
  10. More tracing and tests

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    ba7d127 View commit details
    Browse the repository at this point in the history
  11. Revamped DropRange data structure

    Not currently working. Need to flow drop information.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    ff0e8f4 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    c7afaa1 View commit details
    Browse the repository at this point in the history
  13. 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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    b39fb9b View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    904c270 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    5feb4d0 View commit details
    Browse the repository at this point in the history
  16. Update async-fn-nonsend.stderr

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    46760b4 View commit details
    Browse the repository at this point in the history
  17. Add more comments

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    006f547 View commit details
    Browse the repository at this point in the history
  18. Address code review comments

    1. Add test case for partial drops
    2. Simplify code in `propagate_to_fixpoint` and remove most clones
    3. Clean up PostOrderIndex creation
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    30e1b1e View commit details
    Browse the repository at this point in the history
  19. Refactor drop_ranges

    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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    f5f98d7 View commit details
    Browse the repository at this point in the history
  20. Additional cleanup

    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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    9347bf4 View commit details
    Browse the repository at this point in the history
  21. Fixing formatting

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    6a28afb View commit details
    Browse the repository at this point in the history
  22. Update stderr files

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    7d82e4f View commit details
    Browse the repository at this point in the history
  23. More comments and refactoring

    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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    2af02cf View commit details
    Browse the repository at this point in the history
  24. Handle reinits in match guards

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    4a70de7 View commit details
    Browse the repository at this point in the history
  25. 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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    6e281a7 View commit details
    Browse the repository at this point in the history
  26. Handle empty loops better

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    a7df4e8 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    7d11b33 View commit details
    Browse the repository at this point in the history
  28. 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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    f730bd0 View commit details
    Browse the repository at this point in the history
  29. 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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    787f4cb View commit details
    Browse the repository at this point in the history
  30. Update async-fn-nonsend.rs

    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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    887e843 View commit details
    Browse the repository at this point in the history
  31. drop_ranges: Add TrackedValue enum

    This makes it clearer what values we are tracking and why.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    78c5644 View commit details
    Browse the repository at this point in the history
  32. Safely handle partial drops

    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.
    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    32930d9 View commit details
    Browse the repository at this point in the history
  33. Respond to code review comments

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    e0a5370 View commit details
    Browse the repository at this point in the history
  34. Use .. patterns in cfg_build.rs

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    d840d0c View commit details
    Browse the repository at this point in the history
  35. Fix build after rebase

    eholk committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    76f6b57 View commit details
    Browse the repository at this point in the history