Skip to content

[ownership] Centralize all info about SILInstruction forwarding in the SILInstruction class hierarchy itself. #34915

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 4 commits into from
Dec 2, 2020

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Dec 2, 2020

No description provided.

…ead of FieldIndexCacheBase.

This is NFCI.

THis is in preparation for making FieldIndexCacheBase a templated subclass.
Previously FieldIndexCacheBase only had a parent class of
SingleValueInstruction. I need to be able to in certain cases shim in a
SingleValueInstruction subclass as a parent class instead. In my case it is to
imbue ownership forwarding on StructExtractInst.

This commit itself doesn't make that change and instead just always templatizes
using SingleValueInstruction.
@gottesmm gottesmm requested a review from atrick December 2, 2020 00:10
@gottesmm
Copy link
Contributor Author

gottesmm commented Dec 2, 2020

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Dec 2, 2020

Build failed
Swift Test OS X Platform
Git Sha - fca2238b8786d239dfb72396399a3d2e4d8cd07f

@gottesmm gottesmm force-pushed the forwarding-silinstruction branch from fca2238 to 7aa4d9f Compare December 2, 2020 00:48
@swift-ci
Copy link
Contributor

swift-ci commented Dec 2, 2020

Build failed
Swift Test Linux Platform
Git Sha - fca2238b8786d239dfb72396399a3d2e4d8cd07f

…t in OSSA.

Operationally it just means that in SILGlobalVariable blocks, all operands have
ownership constraint:

  {OwnershipKind::Any, UseLifetimeConstraint::NonLifetimeEnding}

and all values yield an ownership kind of: OwnershipKind::None.
…e SILInstruction class hierarchy itself.

This commit is doing a few things:

1. It is centralizing all decisions about whether an operand's owner instruction
or a value's parent instruction is forwarding in each SILInstruction
itself. This will prevent this information from getting out of sync.

2. This allowed me to hide the low level queries in OwnershipUtils.h that
determined if a SILNodeKind was "forwarding". I tried to minimize the amount of
churn in this PR and thus didn't remove the
is{Owned,Ownership,Guaranteed}Forwarding{Use,Value} checks. Instead I left them
alone but added in asserts to make sure that if the old impl ever returns true,
the neew impl does as well. In a subsequent commit, I am going to remove the old
impl in favor of isa queries.

3. I also in the process discovered that there were some instructions that were
being inconsistently marked as forwarding. All of the asserts in the PR caught
these and I fixed these inconsistencies.
@gottesmm gottesmm force-pushed the forwarding-silinstruction branch from 7aa4d9f to 09ae2ef Compare December 2, 2020 01:36
@gottesmm
Copy link
Contributor Author

gottesmm commented Dec 2, 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.

lgtm except the names are attempting to describe all the invariants rather than just being unique and easily recognizable, like OwnershipForwardingInst and AggregateOwnershipForwardingInst

@gottesmm gottesmm merged commit b13a8e9 into swiftlang:main Dec 2, 2020
@gottesmm gottesmm deleted the forwarding-silinstruction branch December 2, 2020 05:33
@gottesmm
Copy link
Contributor Author

gottesmm commented Dec 2, 2020

@swift-ci test source compatibility

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.

3 participants