Skip to content

[6.4] IRGen/Runtime: emit noncopyable field metadata #89489

Merged
kavon merged 5 commits into
swiftlang:release/6.4.xfrom
kavon:cherry-pick-kavon-noncopyable-field-metadata
May 28, 2026
Merged

[6.4] IRGen/Runtime: emit noncopyable field metadata #89489
kavon merged 5 commits into
swiftlang:release/6.4.xfrom
kavon:cherry-pick-kavon-noncopyable-field-metadata

Conversation

@kavon
Copy link
Copy Markdown
Member

@kavon kavon commented May 28, 2026

  • Explanation: The impact of this change is that types that contain a noncopyable value are no longer invisible to lldb. It does so by updating the Swift runtime so that it is safe for Mirror & RemoteMirror to attempt to inspect noncopyable types. RemoteMirror, used by lldb, will now be able to see the metadata so long as the deployment target of the program is >= Swift 6.4.
  • Scope: IRGen & Runtime reflection
  • Issues: rdar://176282041
  • Risk: We could end up crashing field metadata users like Mirror due to some missed cases, as we're now allowing Mirror to attempt to reflect the fields. The only missing handling I'm aware of is for tuples; there are no noncopyable tuples today, but a future compiler that supports them may need to update the runtime again to support them.
  • Testing: Manual testing and regression tests included
  • Reviewers: @mikeash
  • Original PRs:

kavon and others added 5 commits May 27, 2026 14:45
If our deployment target is a future release version (99.99+) then
we would end up returning the latest known release version, e.g.,
6.3. That seemed counter to the intention of
eac9b3c and the description in
`findSwiftRuntimeVersion`, which says we should return
`std::nullopt` to indicate that we're not bound to any version.

(cherry picked from commit c185332)
The VWT flags for isNonCopyable aren't always being set
correctly by the runtime when it is creating type metadata.

We can't always set them correctly, in the case of fixed-layout
types, as their VWT is static and read-only, yet could still be
conditionally copyable. For example:

```
struct FactoryOf<T: ~Copyable>: ~Copyable {
  var counter: Int = 0
}
extension FactoryOf: Copyable where T: Copyable {}
```

In the common case of an unconditionally Copyable type, we do
effectively two quick bit-tests: one to see if the VWT thinks
it "could be Copyable" and then delegate to
`checkInvertibleRequirements` which has a fast-path for types
that are unconditionally Copyable by checking some bits in the
type's context descriptor.

related to rdar://176282041

(cherry picked from commit 0a73911)
At this point, the ReflectionMirror should be ready to handle Mirror
attempting to reflect fields of noncopyable types.

related to rdar://176282041

(cherry picked from commit 54dd201)
…typeref.swift test (swiftlang#89369)

I'll try enabling again once we switch to the upcoming LTS NDK 30.

(cherry picked from commit fbfe650)
@kavon
Copy link
Copy Markdown
Member Author

kavon commented May 28, 2026

@swift-ci test

@kavon kavon marked this pull request as ready for review May 28, 2026 01:12
@kavon kavon requested a review from a team as a code owner May 28, 2026 01:12
@kavon kavon merged commit e89897c into swiftlang:release/6.4.x May 28, 2026
6 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.

3 participants