Skip to content

Commit aa9421a

Browse files
committed
SIL: Correctly handle @_alwaysEmitIntoClient properties and subscripts
Fixes <rdar://problem/50058883>.
1 parent 2e85997 commit aa9421a

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/SIL/SILDeclRef.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
301301
// serialized bodies, but no public symbol in the generated binary.
302302
if (d->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>())
303303
limit = Limit::AlwaysEmitIntoClient;
304+
if (auto accessor = dyn_cast<AccessorDecl>(d)) {
305+
auto *storage = accessor->getStorage();
306+
if (storage->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>())
307+
limit = Limit::AlwaysEmitIntoClient;
308+
}
304309

305310
// ivar initializers and destroyers are completely contained within the class
306311
// from which they come, and never get seen externally.

test/SILGen/always_emit_into_client_attribute.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,22 @@
1010
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute26implicitlyUsableFromInlineyyF : $@convention(thin) () -> ()
1111
@_alwaysEmitIntoClient func implicitlyUsableFromInline() {
1212
alwaysEmitIntoClientOtherFunction()
13-
}
13+
}
14+
15+
public struct S {
16+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SV8propertySivg : $@convention(method) (S) -> Int
17+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SV8propertySivs : $@convention(method) (Int, @inout S) -> ()
18+
// CHECK-LABEL: sil non_abi [transparent] [serialized] [ossa] @$s33always_emit_into_client_attribute1SV8propertySivM : $@yield_once @convention(method) (@inout S) -> @yields @inout Int
19+
@_alwaysEmitIntoClient public var property: Int {
20+
get { return 0 }
21+
set { }
22+
}
23+
24+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SVyS2icig : $@convention(method) (Int, S) -> Int
25+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SVyS2icis : $@convention(method) (Int, Int, @inout S) -> ()
26+
// CHECK-LABEL: sil non_abi [transparent] [serialized] [ossa] @$s33always_emit_into_client_attribute1SVyS2iciM : $@yield_once @convention(method) (Int, @inout S) -> @yields @inout Int
27+
@_alwaysEmitIntoClient public subscript(x: Int) -> Int {
28+
get { return 0 }
29+
set { }
30+
}
31+
}

0 commit comments

Comments
 (0)