File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -744,6 +744,13 @@ void ClosureSpecializer::gatherCallSites(
744
744
if (!ApplyCallee || ApplyCallee->isExternalDeclaration ())
745
745
continue ;
746
746
747
+ // Don't specialize non-fragile callees if the caller is fragile;
748
+ // the specialized callee will have shared linkage, and thus cannot
749
+ // be referenced from the fragile caller.
750
+ if (Caller->isFragile () &&
751
+ !ApplyCallee->hasValidLinkageForFragileInline ())
752
+ continue ;
753
+
747
754
// Ok, we know that we can perform the optimization but not whether or
748
755
// not the optimization is profitable. Find the index of the argument
749
756
// corresponding to our partial apply.
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests %s -emit-sil -O -o - -verify | %FileCheck %s
2
+
3
+ // Make sure we do not specialize resilientCallee.
4
+
5
+ // CHECK-LABEL: sil [fragile] [always_inline] @_T026closure_specialize_fragile0C6CalleryyF : $@convention(thin) () -> ()
6
+ // CHECK: function_ref @_T026closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
7
+ // CHECK: return
8
+
9
+ @inline ( __always) public func fragileCaller( ) {
10
+ resilientCallee {
11
+ print ( " Hi " )
12
+ }
13
+ }
14
+
15
+ // CHECK-LABEL: sil @_T026closure_specialize_fragile15resilientCalleeyyyc2fn_tF : $@convention(thin) (@owned @callee_owned () -> ()) -> ()
16
+
17
+ public func resilientCallee( fn: ( ) -> ( ) ) {
18
+ fn ( )
19
+ }
You can’t perform that action at this time.
0 commit comments