Skip to content

[owned-phiweb-elimination] Add an "ApplySite" like wrapper for OwnershipIntroducingValues and add utilities for finding them. #30265

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

@gottesmm gottesmm commented Mar 6, 2020

An OwnershipIntroducingValue is a value with owned ownership that is not a result of forwarding ownership from some other value. It is similar to the notion of "rc identity" that we talk about in the low level ARC optimizer.

I am adding this support so given a specific value, we can walk up the def-use graph and find all of the ownership introducing values (what one would call in the low level ARC optimizer an "rc identity set"). As an example, consider the following SIL:

%0 = @owned $(Klass, Int)
%1 = @owned $Klass
(%2, _) = destructure_tuple %0
%3 = tuple(%1, %2)

In this case, the set of ownership introducing values for %3 would be (%0, %1).

In order to implement phi elimination, I need to be able to ascertain all of the owned value introducers for a specific incoming value so I can see if I can convert all of the LiveRanges associated with the incoming value could be converted to guaranteed if we could flip the phi argument.

gottesmm added 2 commits March 6, 2020 12:01
…h non-forwarding owned values at a higher level.

This is a similar concept to "rc-identity" that we talk about in the low level
ARC optimizer. The main idea is that all owned values in a program can be
partitioned into two different kinds of values:

1. Introducer values that exist independently of any other local values in the
function. It is a point of truth from which the owned objects lifetime extends
from and is in a certain sense an initialization (in a category theoretic sense)
in the lifetime of the underlying object that we are manipulating.

2. Forwarding values do not represent an object lifetime that is "truly"
independent of any other value locally: its liveness comes from passing on
liveness from some introducer or some other forwarding value.

The reason why I am adding this new construct is that I am beginning to
implement a new form of ARC optimization that enables us to convert @owned SIL
phi arguments to @guaranteed phi arguments. As part of that, I need to have a
way to in a systematic way finding the underlying incoming values (using the
logic used to determine forwarding in the ownership verifier).

This is the first part of that effort, defining the ontology we are going to
work with. Keep in mind this is just a seed ontology, if I missed any "owned
introducers" (I am sure I did), feel free to add them.
…lueIntroducers().

These enable robust walking up the def-use ossa graph to find the value that
introduces an independent underlying owned value, looking through forwarding
insts.
@gottesmm gottesmm requested a review from atrick March 6, 2020 20:08
@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 6, 2020

This isn't used anywhere now. But I am going to use it in a forthcoming commit that implements the actual mechanism here.

@gottesmm
Copy link
Contributor Author

gottesmm commented Mar 6, 2020

@swift-ci smoke test and merge

@swift-ci swift-ci merged commit 0fe0917 into swiftlang:master Mar 6, 2020
@gottesmm gottesmm deleted the pr-8d01937acb91692d7483e6a5895296634037a326 branch March 6, 2020 23:18
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