File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -3119,6 +3119,12 @@ void swift::trySpecializeApplyOfGeneric(
3119
3119
<< SpecializedF->getLoweredFunctionType () << " \n " );
3120
3120
NewFunctions.push_back (SpecializedF.getFunction ());
3121
3121
}
3122
+ if (replacePartialApplyWithoutReabstraction &&
3123
+ SpecializedF.getFunction ()->isExternalDeclaration ()) {
3124
+ // Cannot create a tunk without having the body of the function.
3125
+ return ;
3126
+ }
3127
+
3122
3128
if (F->isSerialized () && !SpecializedF->hasValidLinkageForFragileInline ()) {
3123
3129
// If the specialized function already exists as a "IsNotSerialized" function,
3124
3130
// but now it's called from a "IsSerialized" function, we need to mark it as
Original file line number Diff line number Diff line change @@ -726,3 +726,34 @@ bb0:
726
726
return %t : $()
727
727
728
728
}
729
+
730
+ sil shared @closure : $@convention(thin) <T> (@in_guaranteed T) -> () {
731
+ bb0(%0 : $*T):
732
+ %5 = tuple ()
733
+ return %5 : $()
734
+ }
735
+
736
+ sil @getExistingExternalSpecialization : $@convention(thin) <T> (@in_guaranteed T) -> @owned @callee_owned () -> () {
737
+ bb0(%0 : $*T):
738
+ %2 = function_ref @closure : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
739
+ %5 = partial_apply %2<T>(%0) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
740
+ return %5 : $@callee_owned () -> ()
741
+ }
742
+
743
+ // Make sure we don't crash here
744
+ // CHECK-LABEL: sil @testExistingExternalSpecialization :
745
+ // CHECK: function_ref @$s33getExistingExternalSpecializations5UInt8V_Tg5
746
+ // CHECK: } // end sil function 'testExistingExternalSpecialization'
747
+ sil @testExistingExternalSpecialization : $@convention(thin) () -> () {
748
+ bb0:
749
+ %0 = alloc_stack $UInt8
750
+ %1 = integer_literal $Builtin.Int8, 5
751
+ %2 = struct $UInt8 (%1 : $Builtin.Int8)
752
+ store %2 to %0 : $*UInt8
753
+ %5 = function_ref @getExistingExternalSpecialization : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @owned @callee_owned () -> ()
754
+ %8 = apply %5<UInt8>(%0) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @owned @callee_owned () -> ()
755
+ dealloc_stack %0 : $*UInt8
756
+ %r = tuple ()
757
+ return %r : $()
758
+ }
759
+
You can’t perform that action at this time.
0 commit comments