Skip to content

[frozen-multimap] Add support for erasing once we have finished constructing the map. #31378

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

Conversation

gottesmm
Copy link
Contributor

I implemented this in a similar way to the way blotting is implemented in a blot
map vector:

  1. I changed this to store (Key, Optional) pairs.

  2. I made it so that once frozen, we can "erase" things from the multimap by
    setting all Optional to none.

  3. I changed the range we vend to be an OptionalTransformRange instead of just a
    TransformRange so we skip all keys with .none values, meaning that a user will
    get the nice behavior that getRange() still works after erasing.

One interesting thing to note is that one /cannot/ erase elements when
initializing the frozen multi-map since we haven't sorted it yet. At first this
seems weird, but it actually fits with the use case of this data structure:
building up state by processing IR in a readonly way and then later working with
it in a worklist like way (and perhaps checking for unhandled cases at the end
of processing).

The nice thing additional thing is that I was able to ensure that the actual
exposed API did not change in terms of how one uses it. I just changed the
underlying iterators/etc.


I tested my tests locally with ASAN, but I am going to do an additional ASAN test as well just to be careful.

…ructing the map.

I implemented this in a similar way to the way blotting is implemented in a blot
map vector:

1. I changed this to store (Key, Optional<Value>) pairs.

2. I made it so that once frozen, we can "erase" things from the multimap by
setting all Optional<Value> to none.

3. I changed the range we vend to be an OptionalTransformRange instead of just a
TransformRange so we skip all keys with .none values, meaning that a user will
get the nice behavior that getRange() still works after erasing.

One interesting thing to note is that one /cannot/ erase elements when
initializing the frozen multi-map since we haven't sorted it yet. At first this
seems weird, but it actually fits with the use case of this data structure:
building up state by processing IR in a readonly way and then later working with
it in a worklist like way (and perhaps checking for unhandled cases at the end
of processing).

The nice thing additional thing is that I was able to ensure that the actual
exposed API did not change in terms of how one uses it. I just changed the
underlying iterators/etc.
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci asan test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9568d53

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test OS X platform

@gottesmm
Copy link
Contributor Author

The OS X failure was one of the spurious:

17:22:20 lldb-api :: lang/swift/unknown_self/TestSwiftUnknownSelf.py

that we have been seeing recently. It isn't from this commit.

@gottesmm gottesmm merged commit d523eba into swiftlang:master Apr 29, 2020
@gottesmm gottesmm deleted the pr-35eea56e6569c03ea51fcc7badd585b257dea90b branch April 29, 2020 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants