Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ private func isCalleeSpecializable(of apply: ApplySite) -> Bool {
// might no longer have 'self' as the last parameter.
//
// TODO: Keep the self argument the last when appending arguments.
!callee.mayBindDynamicSelf
!callee.mayBindDynamicSelf,

// Don't support self-recursive functions because that would result in duplicate mapping of values when cloning.
callee != apply.parentFunction
{
return true
}
Expand Down
25 changes: 25 additions & 0 deletions test/SILOptimizer/closure_specialization.sil
Original file line number Diff line number Diff line change
Expand Up @@ -947,3 +947,28 @@ bb0(%nc : @owned $NC):
%11 = tuple ()
return %11 : $()
}

sil @closure_with_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()

// Just make sure the pass is not crashing.
sil [ossa] @test_recursion : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> () {
bb0(%0 : @guaranteed $@callee_guaranteed () -> ()):
%2 = apply %0() : $@callee_guaranteed () -> ()
cond_br undef, bb1, bb2

bb1:
%5 = function_ref @closure_with_closure : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
%6 = copy_value %0
%7 = partial_apply [callee_guaranteed] %5(%6) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
%8 = function_ref @test_recursion : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
%9 = apply %8(%7) : $@convention(thin) (@guaranteed @callee_guaranteed () -> ()) -> ()
destroy_value %7
br bb3

bb2:
br bb3

bb3:
%13 = tuple ()
return %13
}