Skip to content

[arc-opts] Teach IsAddressWrittenToDefUseAnalysis how to track "well behaved" writes but don't use it. #30741

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

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Apr 1, 2020

In a future commit, I am going to build on this to promote load [copy] ->
load_borrow from inout arguments where none of the writes overlap the load
[copy]'s result's lifetime. By committing this separately, I am using the
current pass's logic to validate the change.

@gottesmm gottesmm requested a review from atrick April 1, 2020 01:07
@gottesmm
Copy link
Contributor Author

gottesmm commented Apr 1, 2020

@swift-ci test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Fairly enigmatic code

private:
bool isWrittenToHelper(SILValue value);
struct IsAddressWrittenToDefUseAnalysis
: public SmallMultiMapCache<IsAddressWrittenToDefUseAnalysis, SILValue,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please explain how the Analysis is supposed to be viewed as a cache. What does the SmallMultiMapCache interface mean when it's inherited by this analysis. Or just don't publicly inherit a generic ADT and give the analysis its own interface.

@@ -1659,7 +1677,8 @@ class StorageGuaranteesLoadVisitor

// If we have a modify, check if our value is /ever/ written to. If it is
// never actually written to, then we convert to a load_borrow.
return answer(ARCOpt.isAddressWrittenToDefUseAnalysis(access));
auto result = ARCOpt.isAddressWrittenToDefUseAnalysis.get(access);
return answer(!result.hasValue() || result.getValue().size());
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't make sense of this code since it's written in terms of the multi-map interface. What does it mean for the analysis to have or not have a value, and how is that different from it being empty or having multiple elements?

@atrick
Copy link
Contributor

atrick commented Apr 1, 2020

Backing up, my main issue here is "multi-map cache", which was in a different PR. A cache cannot be a multi-map by definition. Either the analysis has a valid result or it does not. If the result is comprised of several values, that is distinct from whether the result is valid or complete.

… of CRTP.

This makes it so one uses a passed in std::function, instead of an impl class to
map a key to a list of values to be cached.
…behaved" writes but don't do use it.

In a future commit, I am going to build on this to promote load [copy] ->
load_borrow from inout arguments where none of the writes overlap the load
[copy]'s result's lifetime. By committing this separately, I am using the
current pass's logic to validate the change.
@gottesmm gottesmm force-pushed the pr-961dc8ea62390b2c78cdfafd88f3d04ebfcb7ade branch from c665b21 to 3eda1ea Compare April 15, 2020 19:23
@gottesmm
Copy link
Contributor Author

@atrick I fixed the cache as per our discussion.

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

Windows failed in a c++ interior test. Not this commit.

@gottesmm gottesmm merged commit 3dd3255 into swiftlang:master Apr 15, 2020
@gottesmm gottesmm deleted the pr-961dc8ea62390b2c78cdfafd88f3d04ebfcb7ade branch April 15, 2020 22:01
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