Skip to content

Commit 2318b47

Browse files
Merge pull request #73708 from aschwaighofer/ignore_aeic_in_package_context_without_ufi
SIL: Ignore AEIC on package declaration inside declarations without effective public access
2 parents 9b69c18 + 09a9ba4 commit 2318b47

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,11 @@ SILLinkage SILDeclRef::getDefinitionLinkage() const {
625625
case Limit::None:
626626
return SILLinkage::Package;
627627
case Limit::AlwaysEmitIntoClient:
628-
return SILLinkage::PackageNonABI;
628+
// Drop the AEIC if the enclosing decl is not effectively public.
629+
// This matches what we do in the `internal` case.
630+
if (isSerialized())
631+
return SILLinkage::PackageNonABI;
632+
else return SILLinkage::Package;
629633
case Limit::OnDemand:
630634
return SILLinkage::Shared;
631635
case Limit::NeverPublic:

test/SILGen/always_emit_into_client_attribute.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,21 @@ public final class C {
5858
@_alwaysEmitIntoClient
5959
deinit {}
6060
}
61+
62+
63+
// We drop AEIC if the containing context does not have effective public
64+
// visibility.
65+
internal struct InternalContext {
66+
// CHECK-LABEL: sil hidden [ossa] @$s33always_emit_into_client_attribute15InternalContextV1vSivgZ
67+
@_alwaysEmitIntoClient
68+
internal static var v : Int { 1 }
69+
}
70+
71+
// We drop AEIC if the containing context does not have effective public
72+
// visibility.
73+
package struct PackageContext {
74+
// CHECK-LABEL: sil package [ossa] @$s33always_emit_into_client_attribute14PackageContextV1vSivgZ
75+
76+
@_alwaysEmitIntoClient
77+
package static var v : Int { 1 }
78+
}

0 commit comments

Comments
 (0)