Skip to content

[SILOpt] Used SetVector for fast contains check. #59057

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

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented May 24, 2022

IterableBackwardReachability just requires an iterable list of gens. ShrinkBorrowScope, LexicalDestroyHoisting, and SSADestroyHoisting all need to be able to check whether a given instruction is scope ending quickly. Use a SmallSetVector rather than a SmallVector for the gens in all three.

IterableBackwardReachability just requires an iterable list of gens.
ShrinkBorrowScope, LexicalDestroyHoisting, and SSADestroyHoisting all
need to be able to check whether a given instruction is scope ending
quickly.  Use a SmallSetVector rather than a SmallVector for the gens in
all three.
@nate-chandler nate-chandler force-pushed the perf/20220524/use-setvector-for-gens branch from b6536af to 8775148 Compare May 24, 2022 21:15
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux platform

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

@nate-chandler nate-chandler merged commit 0b2b9a3 into swiftlang:main May 25, 2022
@nate-chandler nate-chandler deleted the perf/20220524/use-setvector-for-gens branch May 25, 2022 14:23
@atrick
Copy link
Contributor

atrick commented May 25, 2022

LGTM

For the record, this probably was not an issue in practice. We need to be careful not to iterate over all uses. But if we know the "use set" only contains scope ending instructions (destroys or end_borrows), then there can only be one per block. So you would need some kind of giant switch where the destroys were all hoisted.

@nate-chandler
Copy link
Contributor Author

Except for destroy_addrs which can occur more than once per block.

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