Skip to content

Update global init optimization to work with vars #29122

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

Merged
merged 5 commits into from
Feb 12, 2020

Conversation

zoecarver
Copy link
Contributor

This patch updates isAssignedOnlyOnceInInitializer to return weather a var can be used externally instead of just returning false.

If there are multiple stores to the var, it will be added to GlobalVarSkipProcessing so, it will return false.

@slavapestov slavapestov self-assigned this Jan 13, 2020
@slavapestov
Copy link
Contributor

I'm sorry, I forgot about this. Do you want to fix the conflict and I'll kick off PR testing?

@zoecarver
Copy link
Contributor Author

Don't worry about it. I'll update the conflict tomorrow morning.

@slavapestov
Copy link
Contributor

slavapestov commented Feb 4, 2020

@zoecarver I think once you merge another PR or two, you can apply for commit access. It's somewhat misleadingly named because it allows you to kick off CI testing yourself. (We'd still want a review from someone before merging)

Details here: https://swift.org/contributing/#contributing-code

= Commit Access
Commit access is granted to contributors with a track record of submitting high-quality changes. If you would like commit access, please send an email to the code owners list ([email protected]) with the GitHub user name that you want to use and a list of 5 non-trivial pull requests that were accepted without modifications.

@zoecarver
Copy link
Contributor Author

@slavapestov thank you! I'll look into that. Might be a few more PRs, though, I'm only at two unmodified PRs as of now.

@zoecarver
Copy link
Contributor Author

Don't trigger the bots yet. I just ran the test suit and discovered I need to fix something.

// is only one use, it must be the use that we are trying to optimize, so
// that is OK. If there is more than one use, one of the other uses may
// have a store attached to it which means there may be more than one
// assignment, so return false.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this additional check to prevent an edge case where global uses were improperly optimized away. In the future, GlobalInitCallMap applies could theoretically be traced to a store instruction that could be added to GlobalVarStore which would be beneficial for a few reasons (including that we could get rid of this extra check and optimize more code correctly).

@zoecarver
Copy link
Contributor Author

@slavapestov this should be ready for testing now.

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@zoecarver
Copy link
Contributor Author

@slavapestov can you please merge this for me now that the tests passed?

@slavapestov slavapestov merged commit f664be4 into swiftlang:master Feb 12, 2020
@zoecarver
Copy link
Contributor Author

@slavapestov thank you again :)

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