Skip to content

Fix existential specializer for unowned ownership #77933

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
Dec 4, 2024

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Dec 3, 2024

init_existential_ref cannot forward operands of unowned ownership. Create an owned value when we have such args.

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta meg-gupta marked this pull request as ready for review December 3, 2024 23:17
@meg-gupta meg-gupta requested a review from eeckstein as a code owner December 3, 2024 23:17
@meg-gupta
Copy link
Contributor Author

meg-gupta commented Dec 3, 2024

I don't know why exactly it is illegal for init_existential_ref to have operands with unowned ownership. We allow certain casts like unchecked_ref_cast to have operand with unowned ownership. This PR fixes the verification error by creating owned values.

Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm

@meg-gupta meg-gupta merged commit db89c6a into swiftlang:main Dec 4, 2024
5 checks passed
@atrick
Copy link
Contributor

atrick commented Dec 4, 2024

I don't know why exactly it is illegal for init_existential_ref to have operands with unowned ownership. We allow certain casts like unchecked_ref_cast to have operand with unowned ownership. This PR fixes the verification error by creating owned values.

unowned values need to be shielded from all the normal OSSA transformations. They can't be transformed safely. The general rule should be that you can never get an owned value from unowned without a copy. We might have some very special casts that unsafely convert ownership; we need to make sure not to optimize those.

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