@@ -1634,3 +1634,34 @@ bb0:
16341634 return %5 : $()
16351635}
16361636
1637+ sil [ossa] @callee : $@convention(thin) <Result> (@inout Result, @in_guaranteed Int, Int) -> () {
1638+ bb0(%0 : $*Result, %1 : $*Int, %2 : $Int):
1639+ unreachable
1640+ }
1641+
1642+ sil [reabstraction_thunk] [ossa] @thunk : $@convention(thin) <τ_0_0> (@inout τ_0_0, Int, @guaranteed @noescape @callee_guaranteed (@inout τ_0_0, @in_guaranteed Int) -> ()) -> ()
1643+
1644+ // CHECK-LABEL: sil [ossa] @insert_copy_when_removing_thunk :
1645+ // CHECK: [[P:%.*]] = partial_apply [callee_guaranteed] [on_stack] %2(%0)
1646+ // CHECK: [[C:%.*]] = copy_value [[P]]
1647+ // CHECK: [[V:%.*]] = convert_function [[C]]
1648+ // CHECK: apply [[V]]
1649+ // CHECK: destroy_value [[V]]
1650+ // CHECK: destroy_value [[P]]
1651+ // CHECK: } // end sil function 'insert_copy_when_removing_thunk'
1652+ sil [ossa] @insert_copy_when_removing_thunk : $@convention(method) (Int) -> Int {
1653+ bb0(%0 : $Int):
1654+ %1 = alloc_stack $Int
1655+ %2 = function_ref @callee : $@convention(thin) <τ_0_0> (@inout τ_0_0, @in_guaranteed Int, Int) -> ()
1656+ %3 = partial_apply [callee_guaranteed] [on_stack] %2<Int>(%0) : $@convention(thin) <τ_0_0> (@inout τ_0_0, @in_guaranteed Int, Int) -> ()
1657+ %4 = function_ref @thunk : $@convention(thin) <τ_0_0> (@inout τ_0_0, Int, @guaranteed @noescape @callee_guaranteed (@inout τ_0_0, @in_guaranteed Int) -> ()) -> ()
1658+ %5 = partial_apply [callee_guaranteed] [on_stack] %4<Int>(%3) : $@convention(thin) <τ_0_0> (@inout τ_0_0, Int, @guaranteed @noescape @callee_guaranteed (@inout τ_0_0, @in_guaranteed Int) -> ()) -> ()
1659+ %6 = convert_function %5 to $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0, Int) -> () for <Int>
1660+ store %0 to [trivial] %1
1661+ %8 = apply %6(%1, %0) : $@noescape @callee_guaranteed @substituted <τ_0_0> (@inout τ_0_0, Int) -> () for <Int>
1662+ destroy_value %6
1663+ destroy_value %3
1664+ %11 = load [trivial] %1
1665+ dealloc_stack %1
1666+ return %11
1667+ }
0 commit comments