|
1 | 1 | // RUN: %target-sil-opt -enable-sil-verify-all -generic-specializer %s | %FileCheck %s
|
2 | 2 |
|
| 3 | +// REQUIRES: swift_in_compiler |
3 | 4 |
|
4 | 5 | sil_stage canonical
|
5 | 6 |
|
@@ -35,6 +36,8 @@ public struct Val<T> : ValProto {
|
35 | 36 | init()
|
36 | 37 | }
|
37 | 38 |
|
| 39 | +class X {} |
| 40 | + |
38 | 41 | sil @coerce : $@convention(thin) <T, U, V> (@owned @callee_owned (@owned Ref<T>) -> @owned @callee_owned (@owned Ref<U>) -> @owned Ref<V>) -> @owned @callee_owned (Val<U>) -> Val<V>
|
39 | 42 |
|
40 | 43 | sil @merge : $@convention(method) <Self where Self : RefProto><U> (@owned Ref<U>, @in_guaranteed Self) -> @owned Ref<(Self.T, U)> {
|
@@ -131,3 +134,35 @@ bb0(%0 : $Bool):
|
131 | 134 | %rv = tuple ()
|
132 | 135 | return %rv : $()
|
133 | 136 | }
|
| 137 | + |
| 138 | +// CHECK-LABEL: sil shared [escapes %0 => %r] @$s21arg_escapes_to_return4main1XC_Tg5 |
| 139 | +sil [escapes %1 => %0] @arg_escapes_to_return : $@convention(thin) <T> (@in_guaranteed T) -> @out T { |
| 140 | +bb0(%0 : $*T, %1 : $*T): |
| 141 | + copy_addr %1 to [initialization] %0 : $*T |
| 142 | + %4 = tuple () |
| 143 | + return %4 : $() |
| 144 | +} |
| 145 | + |
| 146 | +// CHECK-LABEL: sil shared [escapes %1 => %0] @$s015arg_escapes_to_A04main1XC_Tg5 |
| 147 | +sil [escapes %1 => %0] @arg_escapes_to_arg : $@convention(thin) <T> (@inout T, @in_guaranteed T) -> () { |
| 148 | +bb0(%0 : $*T, %1 : $*T): |
| 149 | + copy_addr %1 to %0 : $*T |
| 150 | + %4 = tuple () |
| 151 | + return %4 : $() |
| 152 | +} |
| 153 | + |
| 154 | +sil @test_escape_effects : $@convention(thin) (@guaranteed X) -> @owned X { |
| 155 | +bb0(%0 : $X): |
| 156 | + %2 = alloc_stack $X |
| 157 | + %3 = alloc_stack $X |
| 158 | + store %0 to %3 : $*X |
| 159 | + %5 = function_ref @arg_escapes_to_return : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0 |
| 160 | + %6 = apply %5<X>(%2, %3) : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> @out τ_0_0 |
| 161 | + %7 = function_ref @arg_escapes_to_arg : $@convention(thin) <τ_0_0> (@inout τ_0_0, @in_guaranteed τ_0_0) -> () |
| 162 | + %8 = apply %7<X>(%2, %3) : $@convention(thin) <τ_0_0> (@inout τ_0_0, @in_guaranteed τ_0_0) -> () |
| 163 | + dealloc_stack %3 : $*X |
| 164 | + %10 = load %2 : $*X |
| 165 | + dealloc_stack %2 : $*X |
| 166 | + return %10 : $X |
| 167 | +} |
| 168 | + |
0 commit comments