|
82 | 82 | strong_release %11 : $@box Int
|
83 | 83 | strong_release %6 : $@box Baz
|
84 | 84 | strong_release %1 : $@box Foo
|
| 85 | + |
85 | 86 | return %21 : $@callee_owned () -> Int
|
86 | 87 | }
|
87 | 88 |
|
| 89 | +// CHECK-LABEL: sil @test_capture_promotion_indirect |
| 90 | +sil @test_capture_promotion_indirect : $@convention(thin) () -> @owned @callee_owned () -> @out Int { |
| 91 | +bb0: |
| 92 | + %0 = tuple () |
| 93 | + %1 = alloc_box $Foo |
| 94 | + %1a = project_box %1 : $@box Foo |
| 95 | + %2 = function_ref @foo_allocating_init : $@convention(thin) (@thick Foo.Type) -> @owned Foo |
| 96 | + %3 = metatype $@thick Foo.Type |
| 97 | + %4 = apply %2(%3) : $@convention(thin) (@thick Foo.Type) -> @owned Foo |
| 98 | + store %4 to %1a : $*Foo |
| 99 | + %6 = alloc_box $Baz |
| 100 | + %6a = project_box %6 : $@box Baz |
| 101 | + %7 = function_ref @baz_init : $@convention(thin) (@thin Baz.Type) -> @owned Baz |
| 102 | + %8 = metatype $@thin Baz.Type |
| 103 | + %9 = apply %7(%8) : $@convention(thin) (@thin Baz.Type) -> @owned Baz |
| 104 | + store %9 to %6a : $*Baz |
| 105 | + %11 = alloc_box $Int |
| 106 | + %11a = project_box %11 : $@box Int |
| 107 | + %12 = function_ref @convert_from_integer_literal : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int |
| 108 | + %13 = metatype $@thin Int.Type |
| 109 | + %14 = integer_literal $Builtin.Word, 3 |
| 110 | + %15 = apply %12(%14, %13) : $@convention(thin) (Builtin.Word, @thin Int.Type) -> Int |
| 111 | + store %15 to %11a : $*Int |
| 112 | + |
| 113 | + %17 = function_ref @closure_indirect_result : $@convention(thin) (@owned @box Foo, @owned @box Baz, @owned @box Int) -> @out Int |
| 114 | + strong_retain %1 : $@box Foo |
| 115 | + strong_retain %6 : $@box Baz |
| 116 | + strong_retain %11 : $@box Int |
| 117 | + %21 = partial_apply %17(%1, %6, %11) : $@convention(thin) (@owned @box Foo, @owned @box Baz, @owned @box Int) -> @out Int |
| 118 | + |
| 119 | + strong_release %11 : $@box Int |
| 120 | + strong_release %6 : $@box Baz |
| 121 | + strong_release %1 : $@box Foo |
| 122 | + |
| 123 | + return %21 : $@callee_owned () -> @out Int |
| 124 | +} |
| 125 | + |
88 | 126 | // CHECK-LABEL: sil private @_TTSf2i_i_i__closure0 : $@convention(thin) (@owned Foo, @owned Baz, Int) -> Int
|
89 | 127 | // CHECK: [[DUMMY_FUNC:%.*]] = function_ref @dummy_func : $@convention(thin) (Int, Int, Int) -> Int
|
90 | 128 |
|
@@ -215,3 +253,30 @@ bb0(%0 : $@box Int, %2 : $@box Int):
|
215 | 253 | }
|
216 | 254 |
|
217 | 255 | sil [transparent] [fragile] @_TFsoi1pFTSiSi_Si : $@convention(thin) (Int, Int) -> Int
|
| 256 | + |
| 257 | + |
| 258 | +sil private @closure_indirect_result : $@convention(thin) (@owned @box Foo, @owned @box Baz, @owned @box Int) -> @out Int { |
| 259 | +bb0(%0: $*Int, %1 : $@box Foo, %2 : $@box Baz, %4 : $@box Int): |
| 260 | + %17 = project_box %1 : $@box Foo |
| 261 | + %3 = project_box %2 : $@box Baz |
| 262 | + %5 = project_box %4 : $@box Int |
| 263 | + %6 = tuple () |
| 264 | + // function_ref test14.plus (a : Swift.Int, b : Swift.Int, c : Swift.Int) -> Swift.Int |
| 265 | + %7 = function_ref @dummy_func : $@convention(thin) (Int, Int, Int) -> Int |
| 266 | + %8 = load %17 : $*Foo |
| 267 | + strong_retain %8 : $Foo |
| 268 | + %10 = class_method %8 : $Foo, #Foo.foo!1 : (Foo) -> () -> Int, $@convention(method) (@guaranteed Foo) -> Int |
| 269 | + %11 = apply %10(%8) : $@convention(method) (@guaranteed Foo) -> Int |
| 270 | + %12 = struct_element_addr %3 : $*Baz, #Baz.x |
| 271 | + %13 = load %12 : $*Int |
| 272 | + %14 = load %5 : $*Int |
| 273 | + %15 = apply %7(%11, %13, %14) : $@convention(thin) (Int, Int, Int) -> Int |
| 274 | + strong_release %4 : $@box Int |
| 275 | + strong_release %2 : $@box Baz |
| 276 | + strong_release %1 : $@box Foo |
| 277 | + store %15 to %0 : $*Int |
| 278 | + %16 = tuple() |
| 279 | + return %16 : $() |
| 280 | +} |
| 281 | + |
| 282 | + |
0 commit comments