Skip to content

Update canTriviallyDeleteOSSAEndScopeInst and a related assertion #72019

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
Mar 1, 2024

Conversation

meg-gupta
Copy link
Contributor

A destroy_value of Optional.none can be deleted.

A move-only struct with deinit has a non trivial SILType but OwnershipKind::None, such values cannot be deleted.

@meg-gupta meg-gupta requested a review from atrick March 1, 2024 20:07
@meg-gupta meg-gupta force-pushed the instdeleterassertfix branch from aedb40b to a505c25 Compare March 1, 2024 20:09
@meg-gupta meg-gupta requested a review from nate-chandler March 1, 2024 20:12
A destroy_value of Optional.none can be deleted.

A move-only struct with deinit has a non trivial SILType but OwnershipKind::None,
such values cannot be deleted.
@meg-gupta
Copy link
Contributor Author

@swift-ci smoke 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.

I'm not opposed to this fix. I just want to make sure everyone understands that Ownership.none can never apply to a struct-with-deinit. Ownership.none literally means that the type is trivial on this path. Meaning we know there is no deinit on this path

@meg-gupta
Copy link
Contributor Author

@atrick You are right. My observation was from the earlier @_moveOnly type attribute which used Ownership::None even in the presence of deinit.

@meg-gupta
Copy link
Contributor Author

But we can't assume Ownership::None implies anymore because a ~Copyable struct without deinit has OwnershipKind::None and non-trivial SILType ?

@meg-gupta meg-gupta merged commit 59153a0 into swiftlang:main Mar 1, 2024
@atrick
Copy link
Contributor

atrick commented Mar 2, 2024

But we can't assume Ownership::None implies anymore because a ~Copyable struct without deinit has OwnershipKind::None and non-trivial SILType ?

I'm not really sure what assumptions are currently being made in move-only passes. I think Ownership::None always implies that the value is trivial. Even though its type might conservatively report non-trivial. That's the assumption in all the code I've written.

In my mind, we would like BitwiseCopyable implies SILType.isTrivial implies Ownership::None. Right @nate-chandler?

The statement above

~Copyable struct without deinit has OwnershipKind::None and non-trivial SILType ?

is consistent with that model of increasing information as the trivial representation is lowered. I just have no idea what is accomplished by making "~Copyable struct without deinit" nontrivial at the type level but trivial at the ownership level. Ownership::None is just a way of saying that this particular value is known to be trivial.

@nate-chandler
Copy link
Contributor

nate-chandler commented Mar 2, 2024

we would like BitwiseCopyable implies SILType.isTrivial

That's a goal, yes. See rdar://123661042 .

@meg-gupta
Copy link
Contributor Author

I'm not opposed to this fix. I just want to make sure everyone understands that Ownership.none can never apply to a struct-with-deinit. Ownership.none literally means that the type is trivial on this path. Meaning we know there is no deinit on this path

@atrick I created #72160 to show we can have Ownership.none for a non-copyable struct.

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