Avatar
2っぽい動き。 public struct S<T> { var x: T public __consuming func foo() {} } public func testing<T>(c: S<T>) { c.foo() }__consuming 有り無しで
8:46 AM
あり // S.foo() sil @$s4test1SV3fooyyF : $@convention(method) <T> (@in S<T>) -> () { // %0 // users: %2, %1 bb0(%0 : $*S<T>): debug_value_addr %0 : $*S<T>, let, name "self", argno 1 // id: %1 destroy_addr %0 : $*S<T> // id: %2 %3 = tuple () // user: %4 return %3 : $() // id: %4 } // end sil function '$s4test1SV3fooyyF' // testing<A>(c:) sil @$s4test7testing1cyAA1SVyxG_tlF : $@convention(thin) <T> (@in_guaranteed S<T>) -> () { // %0 // users: %3, %1 bb0(%0 : $*S<T>): debug_value_addr %0 : $*S<T>, let, name "c", argno 1 // id: %1 %2 = alloc_stack $S<T> // users: %6, %5, %3 copy_addr %0 to [initialization] %2 : $*S<T> // id: %3 // function_ref S.foo() %4 = function_ref @$s4test1SV3fooyyF : $@convention(method) <τ_0_0> (@in S<τ_0_0>) -> () // user: %5 %5 = apply %4<T>(%2) : $@convention(method) <τ_0_0> (@in S<τ_0_0>) -> () dealloc_stack %2 : $*S<T> // id: %6 %7 = tuple () // user: %8 return %7 : $() // id: %8 } // end sil function '$s4test7testing1cyAA1SVyxG_tlF'
8:47 AM
呼び出し側でコピーして、callee 側で破棄している。
8:47 AM
なし // S.foo() sil @$s4test1SV3fooyyF : $@convention(method) <T> (@in_guaranteed S<T>) -> () { // %0 // user: %1 bb0(%0 : $*S<T>): debug_value_addr %0 : $*S<T>, let, name "self", argno 1 // id: %1 %2 = tuple () // user: %3 return %2 : $() // id: %3 } // end sil function '$s4test1SV3fooyyF' // testing<A>(c:) sil @$s4test7testing1cyAA1SVyxG_tlF : $@convention(thin) <T> (@in_guaranteed S<T>) -> () { // %0 // users: %3, %1 bb0(%0 : $*S<T>): debug_value_addr %0 : $*S<T>, let, name "c", argno 1 // id: %1 // function_ref S.foo() %2 = function_ref @$s4test1SV3fooyyF : $@convention(method) <τ_0_0> (@in_guaranteed S<τ_0_0>) -> () // user: %3 %3 = apply %2<T>(%0) : $@convention(method) <τ_0_0> (@in_guaranteed S<τ_0_0>) -> () %4 = tuple () // user: %5 return %4 : $() // id: %5 } // end sil function '$s4test7testing1cyAA1SVyxG_tlF' オーナーシップ系の動きは一切ない。