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)
111111
112112EXPERIMENTAL_FEATURE(OneWayClosureParameters, false )
113113EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false )
114- EXPERIMENTAL_FEATURE(LayoutPrespecialization, false )
114+ EXPERIMENTAL_FEATURE(LayoutPrespecialization, true )
115115EXPERIMENTAL_FEATURE(ModuleInterfaceExportAs, true )
116116
117117// / Whether to enable experimental differentiable programming features:
Original file line number Diff line number Diff line change @@ -2884,8 +2884,9 @@ bool usePrespecialized(
28842884
28852885 if (!erased || !layout || !layout->isClass ()) {
28862886 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
28892890 break ;
28902891 } else if (!specializedSig->getRequiredProtocols (genericParam)
28912892 .empty ()) {
Original file line number Diff line number Diff line change 1616// 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
1717// 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
1818
19- // REQUIRES: asserts
20-
2119import pre_specialized_module_layouts
2220
2321// Helper to prevent return values from getting optimized away
@@ -187,6 +185,17 @@ public func usePartialApply(y: SomeClass) -> (SomeClass) -> SomeClass {
187185 return usePartialApplyInner
188186}
189187
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+
190199// OPT-macosx: sil [available 10.50] @$s22pre_specialize_layouts40usePrespecializedEntryPointsAvailabilityyyF : $@convention(thin) () -> () {
191200// OPT-macosx: [[F1:%.*]] = function_ref @$s30pre_specialized_module_layouts20publicPrespecializedyyxlFAA8SomeDataV_Ts5 : $@convention(thin) (SomeData) -> ()
192201// OPT-macosx: apply [[F1]](
You can’t perform that action at this time.
0 commit comments