1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only | %FileCheck %s
sil_stage raw
protocol P {}
sil [ossa] @callWithAutoclosure_3 : $@convention(thin) <T where T : P> (@in T) -> () {
bb0(%0 : $*T):
debug_value %0 : $*T, expr op_deref
%2 = function_ref @mightApply : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> ()
%3 = function_ref @closure_to_specialize : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
%4 = alloc_box $<τ_0_0> { var τ_0_0 } <T>
%4c = mark_uninitialized [var] %4 : $<τ_0_0> { var τ_0_0 } <T>
%4a = project_box %4c : $<τ_0_0> { var τ_0_0 } <T>, 0
%4copy = copy_value %4c : $<τ_0_0> { var τ_0_0 } <T>
copy_addr %0 to [init] %4a : $*T
%6 = partial_apply %3<T>(%4copy) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0
%7 = apply %2<T>(%6) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@owned @callee_owned () -> @out τ_0_0) -> ()
destroy_addr %0 : $*T
destroy_value %4c : $<τ_0_0> { var τ_0_0 } <T>
%9 = tuple ()
return %9 : $()
}
// CHECK-LABEL: sil {{.*}}@$s21closure_to_specializeTf0ns_n : {{.*}}{
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : @_eagerMove $*T, {{%[^,]+}} : @_eagerMove $
// CHECK-LABEL: } // end sil function '$s21closure_to_specializeTf0ns_n'
sil shared [ossa] @closure_to_specialize : $@convention(thin) <T where T : P> (@owned <τ_0_0> { var τ_0_0 } <T>) -> @out T {
bb0(%0 : @_eagerMove $*T, %1 : @_eagerMove @owned $<τ_0_0> { var τ_0_0 } <T>):
%2 = project_box %1 : $<τ_0_0> { var τ_0_0 } <T>, 0
copy_addr %2 to [init] %0 : $*T
destroy_value %1 : $<τ_0_0> { var τ_0_0 } <T>
%5 = tuple ()
return %5 : $()
}
sil [transparent] [serialized] [ossa] @mightApply : $@convention(thin) <U where U : P> (@owned @callee_owned () -> @out U) -> () {
bb0(%0 : @owned $@callee_owned () -> @out U):
debug_value %0 : $@callee_owned () -> @out U
%1 = copy_value %0 : $@callee_owned () -> @out U
%3 = alloc_stack $U
%4 = apply %1(%3) : $@callee_owned () -> @out U
destroy_addr %3 : $*U
dealloc_stack %3 : $*U
destroy_value %0 : $@callee_owned () -> @out U
%8 = tuple ()
return %8 : $()
}
|