Skip to content

Unify several l-value access emission paths in SILGen #18071

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 1 commit into from
Jul 20, 2018

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Jul 19, 2018

There were several bits of code which were unnecessarily repeating the core logic of breaking down an access strategy and either setting up an LValue or directly emitting it. These places have now been unified to just create and then load or othrwise use an LValue.

Introduce a visitor which handles the common parts of breaking down an access strategy and computing information like the LValueTypeData. In addition to its direct benefits (which are somewhat lost in the boilerplate of capturing local state into the visitor subclass), this eliminates some of the ad hoc-ness of how the various emission paths use AccessStrategy.

Finally, implement the MaterializeToTemporary strategy in its full generality by using the actual read and write sub-strategies instead of always falling back on calling the getter and setter. This part is not NFC because it causes us to perform the read part of a read/write to a stored-with-observers property by directly accessing the storage instead of calling the getter. It will be even less NFC as we generalize ways in which accesses can be performed.

@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 03da0b48dc6e08cf8e14ccff186491ce17322fea

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 03da0b48dc6e08cf8e14ccff186491ce17322fea

@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 03da0b48dc6e08cf8e14ccff186491ce17322fea

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 03da0b48dc6e08cf8e14ccff186491ce17322fea

There were several bits of code which were unnecessarily
repeating the core logic of breaking down an access strategy
and either setting up an LValue or directly emitting it.
These places have now been unified to just create and then
load or othrwise use an LValue.

Introduce a visitor which handles the common parts of breaking
down an access strategy and computing information like the
LValueTypeData.  In addition to its direct benefits (which are
somewhat lost in the boilerplate of capturing local state into
the visitor subclass), this eliminates some of the ad-hocness
of how the various emission paths use AccessStrategy.

Finally, implement the MaterializeToTemporary strategy in its
full generality by using the actual read and write sub-strategies
instead of always falling back on calling the getter and setter.
This part is not NFC because it causes us to perform the read
part of a read/write to a stored-with-observers property by
directly accessing the storage instead of calling the getter.
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b44459bae99b8ac35941e4e7c95837fcda75b8d3

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b44459bae99b8ac35941e4e7c95837fcda75b8d3

@rjmccall rjmccall merged commit 1380590 into swiftlang:master Jul 20, 2018
@rjmccall rjmccall deleted the access-cleanup branch July 20, 2018 05:42
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