File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ EXPERIMENTAL_FEATURE(MoveOnlyClasses, true)
111
111
112
112
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false )
113
113
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false )
114
- EXPERIMENTAL_FEATURE(LayoutPrespecialization, false )
114
+ EXPERIMENTAL_FEATURE(LayoutPrespecialization, true )
115
115
EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true )
116
116
117
117
// / Whether to enable experimental differentiable programming features:
Original file line number Diff line number Diff line change @@ -2884,8 +2884,9 @@ bool usePrespecialized(
2884
2884
2885
2885
if (!erased || !layout || !layout->isClass ()) {
2886
2886
newSubs.push_back (entry.value ());
2887
- } else if (!entry.value ()->isAnyClassReferenceType ()) {
2888
- // non-reference type can't be applied
2887
+ } else if (!entry.value ()->isAnyClassReferenceType () ||
2888
+ entry.value ()->isAnyExistentialType ()) {
2889
+ // non-reference or existential type can't be applied
2889
2890
break ;
2890
2891
} else if (!specializedSig->getRequiredProtocols (genericParam)
2891
2892
.empty ()) {
Original file line number Diff line number Diff line change 16
16
// RUN: %target-swift-frontend -enable-experimental-feature LayoutPrespecialization -O -swift-version 5 -enable-library-evolution -emit-module -o /dev/null -emit-module-interface-path %t/pre_specialized_module_layouts.swiftinterface %S/Inputs/pre_specialized_module_layouts.swift -module-name pre_specialized_module_layouts
17
17
// RUN: %target-swift-frontend -enable-experimental-feature LayoutPrespecialization -I %t -O -Xllvm -sil-disable-pass=function-signature-opts -emit-sil %s | %FileCheck %s --check-prefix=OPT
18
18
19
- // REQUIRES: asserts
20
-
21
19
import pre_specialized_module_layouts
22
20
23
21
// Helper to prevent return values from getting optimized away
@@ -187,6 +185,17 @@ public func usePartialApply(y: SomeClass) -> (SomeClass) -> SomeClass {
187
185
return usePartialApplyInner
188
186
}
189
187
188
+ // NOTE: AnyObject specializations MUST not be applied to existential references.
189
+
190
+ // OPT: sil @$s22pre_specialize_layouts48useLayoutPrespecializedEntryPointWithExistentialyyAA21SomeReferenceProtocol_pF : $@convention(thin) (@guaranteed any SomeReferenceProtocol) -> () {
191
+ // OPT: {{bb.*}}([[A1:%.*]] : $any SomeReferenceProtocol):
192
+ // OPT-NOT: {{%.*}} = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFyXl_Ts5 : $@convention(thin) (@guaranteed AnyObject) -> ()
193
+ // OPT: } // end sil function '$s22pre_specialize_layouts48useLayoutPrespecializedEntryPointWithExistentialyyAA21SomeReferenceProtocol_pF'
194
+ public protocol SomeReferenceProtocol : AnyObject { }
195
+ public func useLayoutPrespecializedEntryPointWithExistential( _ p: any SomeReferenceProtocol ) {
196
+ publicPrespecialized ( p)
197
+ }
198
+
190
199
// OPT-macosx: sil [available 10.50] @$s22pre_specialize_layouts40usePrespecializedEntryPointsAvailabilityyyF : $@convention(thin) () -> () {
191
200
// OPT-macosx: [[F1:%.*]] = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFAA8SomeDataV_Ts5 : $@convention(thin) (SomeData) -> ()
192
201
// OPT-macosx: apply [[F1]](
You can’t perform that action at this time.
0 commit comments