|
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all -sil-print-debuginfo -copy-forwarding %s | %FileCheck %s |
| 2 | +sil_stage canonical |
| 3 | + |
| 4 | +import Builtin |
| 5 | +import Swift |
| 6 | + |
| 7 | +sil_scope 1 { loc "backward.swift":66:24 parent @backward : $@convention(method) <τ_0_0> (@inout CollectionOfOne<τ_0_0>.Iterator) -> @out Optional<τ_0_0> } |
| 8 | +sil_scope 2 { loc "backward.swift":67:9 parent 1 } |
| 9 | + |
| 10 | +// CHECK-LABEL: sil {{.+}} @backward |
| 11 | +sil [serialized] [ossa] @backward : $@convention(method) <Element> (@inout CollectionOfOne<Element>.Iterator) -> @out Optional<Element> { |
| 12 | +[%0: write v**] |
| 13 | +[%1: read s0.v**, write s0.v**, copy s0.v**, destroy s0.v**] |
| 14 | +[global: read,write,copy,destroy,allocate,deinit_barrier] |
| 15 | +bb0(%0 : $*Optional<Element>, %1 : $*CollectionOfOne<Element>.Iterator): |
| 16 | + debug_value %1 : $*CollectionOfOne<Element>.Iterator, var, name "self", argno 1, expr op_deref, loc "backward.swift":66:24, scope 1 |
| 17 | + %3 = alloc_stack [lexical] [var_decl] $Optional<Element>, let, name "result", loc "backward.swift":67:9, scope 2 |
| 18 | + %4 = struct_element_addr %1 : $*CollectionOfOne<Element>.Iterator, #CollectionOfOne.Iterator._elements, loc "backward.swift":67:18, scope 1 |
| 19 | + |
| 20 | + // CHECK: debug_value %{{[0-9]+}} : $*Optional<Element>, let, (name "result", loc "backward.swift":67:9, scope 2), expr op_deref, loc "backward.swift":67:18, scope 2 |
| 21 | + |
| 22 | + copy_addr %4 to [init] %3 : $*Optional<Element>, loc "backward.swift":67:18, scope 1 |
| 23 | + %6 = alloc_stack $Optional<Element>, loc "backward.swift":68:17, scope 2 |
| 24 | + inject_enum_addr %6 : $*Optional<Element>, #Optional.none!enumelt, loc "backward.swift":68:17, scope 2 |
| 25 | + %8 = struct_element_addr %1 : $*CollectionOfOne<Element>.Iterator, #CollectionOfOne.Iterator._elements, loc "backward.swift":68:15, scope 2 |
| 26 | + copy_addr [take] %6 to %8 : $*Optional<Element>, loc "backward.swift":68:15, scope 2 |
| 27 | + dealloc_stack %6 : $*Optional<Element>, loc "backward.swift":68:17, scope 2 |
| 28 | + copy_addr [take] %3 to [init] %0 : $*Optional<Element>, loc "backward.swift":69:12, scope 2 |
| 29 | + dealloc_stack %3 : $*Optional<Element>, loc "backward.swift":70:3, scope 2 |
| 30 | + %13 = tuple (), loc "backward.swift":70:3, scope 2 |
| 31 | + return %13 : $(), loc "backward.swift":69:5, scope 2 |
| 32 | +} // end sil function 'backward' |
| 33 | + |
| 34 | +sil_scope 10 { loc "tempcopy.swift":714:27 parent @tempcopy : $@convention(method) <τ_0_0 where τ_0_0 : Strideable, τ_0_0.Stride : SignedInteger> (@in PartialRangeFrom<τ_0_0>) -> @out PartialRangeFrom<τ_0_0>.Iterator } |
| 35 | +sil_scope 12 { loc "tempcopy.swift":715:12 parent 10 } |
| 36 | + |
| 37 | +// CHECK-LABEL: sil {{.+}} @tempcopy |
| 38 | +sil [serialized] [ossa] @tempcopy : $@convention(method) <Bound where Bound : Strideable, Bound.Stride : SignedInteger> (@in PartialRangeFrom<Bound>) -> @out PartialRangeFrom<Bound>.Iterator { |
| 39 | +[%0: write v**] |
| 40 | +[%1: read v**, write v**, copy s0.v**, destroy v**] |
| 41 | +[global: read,write,copy,destroy,allocate,deinit_barrier] |
| 42 | +bb0(%0 : $*PartialRangeFrom<Bound>.Iterator, %1 : $*PartialRangeFrom<Bound>): |
| 43 | + debug_value %1 : $*PartialRangeFrom<Bound>, let, name "self", argno 1, expr op_deref, loc "tempcopy.swift":714:27, scope 10 // id: %2 |
| 44 | + %3 = struct_element_addr %1 : $*PartialRangeFrom<Bound>, #PartialRangeFrom.lowerBound, loc "tempcopy.swift":715:31, scope 10 // user: %5 |
| 45 | + %4 = alloc_stack $Bound, loc "tempcopy.swift":715:31, scope 10 // users: %8, %6, %10, %5 |
| 46 | + copy_addr [take] %3 to [init] %4 : $*Bound, loc "tempcopy.swift":715:31, scope 10 // id: %5 |
| 47 | + // CHECK: debug_value %{{[0-9]+}} : $*Bound, let, (name "_current", loc "tempcopy.swift":696:17 |
| 48 | + // CHECK-SAME: expr op_deref, loc "tempcopy.swift":715:31 |
| 49 | + debug_value %4 : $*Bound, let, name "_current", expr op_deref, loc "tempcopy.swift":696:17, scope 12 // id: %6 |
| 50 | + %7 = struct_element_addr %0 : $*PartialRangeFrom<Bound>.Iterator, #PartialRangeFrom.Iterator._current, loc "tempcopy.swift":696:50, scope 12 // user: %8 |
| 51 | + copy_addr [take] %4 to [init] %7 : $*Bound, loc "tempcopy.swift":696:50, scope 12 // id: %8 |
| 52 | + %9 = tuple (), loc * "tempcopy.swift":696:61, scope 12 |
| 53 | + dealloc_stack %4 : $*Bound, loc "tempcopy.swift":715:41, scope 10 // id: %10 |
| 54 | + %11 = tuple (), loc "tempcopy.swift":716:3, scope 10 // user: %12 |
| 55 | + return %11 : $(), loc "tempcopy.swift":715:5, scope 10 // id: %12 |
| 56 | +} // end sil function 'tempcopy' |
| 57 | + |
| 58 | +sil @f_in : $@convention(thin) <T> (@in T) -> () |
| 59 | + |
| 60 | +// CHECK-LABEL: sil hidden [ossa] @forward_takeinit : |
| 61 | +sil hidden [ossa] @forward_takeinit : $@convention(thin) <T> (@in T) -> () { |
| 62 | +bb0(%0 : $*T): |
| 63 | + // CHECK: debug_value %0 : $*T, let, (name "hello",{{.+}} expr op_deref |
| 64 | + %l1 = alloc_stack $T, let, name "hello" |
| 65 | + copy_addr [take] %0 to [init] %l1 : $*T |
| 66 | + %f1 = function_ref @f_in : $@convention(thin) <τ_0_0> (@in τ_0_0) -> () |
| 67 | + %c1 = apply %f1<T>(%l1) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> () |
| 68 | + dealloc_stack %l1 : $*T |
| 69 | + %r1 = tuple () |
| 70 | + return %r1 : $() |
| 71 | +} |
0 commit comments