Skip to content

Conversation

jckarter
Copy link
Contributor

This is a new case that comes up with InlineArray, since an InlineArray with unknown count but known trivial element type is trivial but still address-only due to its unknown size. We are inconsistent about whether we emit formal copies or not of these values; they should generally be unnecessary as long as the memory location of a value is sufficiently long-lived, but the SIL verifier still reasonably considers a [take] as an invalidation of the memory, even though at runtime a take is a no-op. Since the take is unnecessary, we can just not take when we copy out of a trivial address location. Fixes #84141 | rdar://160007939.

This is a new case that comes up with `InlineArray`, since an `InlineArray`
with unknown count but known trivial element type is trivial but still
address-only due to its unknown size. We are inconsistent about whether
we emit formal copies or not of these values; they should generally
be unnecessary as long as the memory location of a value is sufficiently
long-lived, but the SIL verifier still reasonably considers a `[take]` as
an invalidation of the memory, even though at runtime a take is a no-op.
Since the take is unnecessary, we can just not take when we copy out of
a trivial address location. Fixes swiftlang#84141 | rdar://160007939.
@jckarter jckarter requested a review from kavon as a code owner September 12, 2025 18:47
@jckarter
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

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

lgtm

@jckarter jckarter merged commit 798621e into swiftlang:main Sep 15, 2025
5 checks passed
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.

SIL compile crash when switching over an enum with cases that have an InlineArray parameter

3 participants