File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -242,7 +242,10 @@ private func isCalleeSpecializable(of apply: ApplySite) -> Bool {
242242 // might no longer have 'self' as the last parameter.
243243 //
244244 // TODO: Keep the self argument the last when appending arguments.
245- !callee. mayBindDynamicSelf
245+ !callee. mayBindDynamicSelf,
246+
247+ // Don't support self-recursive functions because that would result in duplicate mapping of values when cloning.
248+ callee != apply. parentFunction
246249 {
247250 return true
248251 }
Original file line number Diff line number Diff line change @@ -947,3 +947,28 @@ bb0(%nc : @owned $NC):
947947 %11 = tuple ()
948948 return %11 : $()
949949}
950+
951+ sil @closure_with_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
952+
953+ // Just make sure the pass is not crashing.
954+ sil [ossa] @test_recursion : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> () {
955+ bb0(%0 : @guaranteed $@callee_guaranteed () -> ()):
956+ %2 = apply %0() : $@callee_guaranteed () -> ()
957+ cond_br undef, bb1, bb2
958+
959+ bb1:
960+ %5 = function_ref @closure_with_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
961+ %6 = copy_value %0
962+ %7 = partial_apply [callee_guaranteed] %5(%6) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
963+ %8 = function_ref @test_recursion : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
964+ %9 = apply %8(%7) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
965+ destroy_value %7
966+ br bb3
967+
968+ bb2:
969+ br bb3
970+
971+ bb3:
972+ %13 = tuple ()
973+ return %13
974+ }
You can’t perform that action at this time.
0 commit comments