Skip to content

Small SILValue::getOwnershipValue() fixes #6831

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 3 commits into from
Jan 16, 2017

Conversation

gottesmm
Copy link
Contributor

This PR contains a few fixes for SILValue::getOwnershipValue() that I discovered as I was cleaning up ownership in SILGen.

Specifically:

  1. thin_to_thick_function should return an owned value even though its input is trivial.
  2. unchecked_bitwise_cast does not return trivial semantics. Instead it has the semantics that:
    a. trivial -> trivial => trivial
    b. trivial -> non-trivial => unowned
    c. non-trivial -> trivial => trivial
    d. non-trivial -> non-trivial => forwarding
  3. objc_{existential_,}metatype_to_object is owned. In SIL metatypes are trivial. We only convert them to full objects on request for usage in objective-c. These instructions convert metatypes to objects. Thus they should return the value as owned. The one interesting part here is that one may think that these should return an unowned value (since we are converting from trivial => non-trivial), but since in objective-c land class types are eternal (with a special retain/release that do nothing), we can avoid needing to do that.

rdar://29791263

…getOwnershipKind().

This is used in SILGen in a few different cases:

1. trivial -> non-trivial. This should have unowned semantics since one should
retain before use.
2. non-trivial -> trivial. This should have trivial semantics.
3. trivial -> trivial. This should have trivial semantics.
4. non-trivial -> non-trivial. This should have forwarding semantics.
…ed as owned.

Metatypes in SIL are trivial, until we conver them to objects (mainly for cases
where one converts the metatype to an object for use in objc). Thus these
conversion functions must be treated as returning an @owned value.
@gottesmm
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@gottesmm gottesmm merged commit 554bc78 into swiftlang:master Jan 16, 2017
@gottesmm gottesmm deleted the small_getownershipvalue_fixes branch January 16, 2017 04:22
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.

1 participant