@@ -2223,14 +2223,44 @@ bb0(%thick : $@callee_guaranteed @yield_once @convention(thick) (Int64, Int32) -
2223
2223
return %pa_f : $@yield_once @callee_guaranteed (Int64) -> Int64
2224
2224
}
2225
2225
2226
- // FIXME: Assertion `LastArgWritten >= adjusted.size()' failed.
2227
- // sil @external_closure : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2228
- // sil @dont_crash : $@convention(thin) (Int) -> @owned @yield_once @callee_guaranteed (Int) -> (Int, @error Error) {
2229
- // bb0(%0 : $Int):
2230
- // %2 = function_ref @external_closure : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2231
- // %3 = partial_apply [callee_guaranteed] %2(%0) : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2232
- // return %3 : $@yield_once @callee_guaranteed (Int) -> (Int, @error Error)
2233
- // }
2226
+ // CHECK: define {{.*}} { ptr, ptr } @dont_crash
2227
+ // CHECK-SAME: (i64 %[[ARG:.*]])
2228
+ // CHECK: entry:
2229
+ // CHECK: %[[BOX:.*]] = call noalias ptr @swift_allocObject(ptr getelementptr inbounds (%swift.full_boxmetadata
2230
+ // CHECK: %[[BOXPTR:.*]] = getelementptr inbounds <{ %swift.refcounted, %TSi }>, ptr %1, i32 0, i32 1
2231
+ // CHECK: %[[ARGPTR:.*]] = getelementptr inbounds %TSi, ptr %2, i32 0, i32 0
2232
+ // CHECK: store i64 %[[ARG]], ptr %[[ARGPTR]]
2233
+ // CHECK: %[[RET:.*]] = insertvalue { ptr, ptr } { ptr @"$s16external_closureTA", ptr undef }, ptr %[[BOX]], 1
2234
+ // CHECK: ret { ptr, ptr } %[[RET]]
2235
+ // CHECK: }
2236
+ //
2237
+ // CHECK: define {{.*}} ptr @"$s16external_closureTA"
2238
+ // CHECK-SAME: (ptr noalias {{.*}} %[[CTX:.*]], i64 %[[ARG1:.*]], ptr swiftself %[[PA_CTX_BOX:.*]], ptr noalias nocapture swifterror {{.*}} %[[ERROR:.*]])
2239
+ // CHECK: entry:
2240
+ // CHECK: %[[SPILL:.*]] = call ptr @malloc(i64 40)
2241
+ // CHECK: store ptr %[[SPILL]], ptr %[[CTX]]
2242
+ // CHECK: %[[FRAME:.*]] = getelementptr inbounds %"$s16external_closureTA.Frame", ptr %[[SPILL]], i32 0, i32 0
2243
+ // CHECK: %[[PA_CTX:.*]] = getelementptr inbounds <{ %swift.refcounted, %TSi }>, ptr %[[PA_CTX_BOX]], i32 0, i32 1
2244
+ // CHECK: %[[PA_ARG:.*]] = getelementptr inbounds %TSi, ptr %[[PA_CTX]], i32 0, i32 0
2245
+ // CHECK: %[[ARG2:.*]] = load i64, ptr %[[PA_ARG]]
2246
+ // CHECK: %[[FRAMEPTR:.*]] = getelementptr inbounds [32 x i8], ptr %[[FRAME]], i32 0, i32 0
2247
+ // CHECK: call void @llvm.lifetime.start.p0(i64 32, ptr %[[FRAMEPTR]])
2248
+ // CHECK: store ptr null, ptr %[[ERROR]]
2249
+ // CHECK: %[[YIELD_PAIR:.*]] = call swiftcc ptr @external_closure(ptr noalias {{.*}} %[[FRAMEPTR]], i64 %[[ARG1]], i64 %[[ARG2]], ptr swiftself undef, ptr noalias nocapture swifterror {{.*}} %[[ERROR]])
2250
+ // CHECK: %[[SPILL1:.*]] = getelementptr inbounds %"$s16external_closureTA.Frame", ptr %[[SPILL]], i32 0, i32 1
2251
+ // CHECK: store ptr %[[YIELD_PAIR]], ptr %[[SPILL1]]
2252
+ // CHECK: %[[ERRORVAL:.*]] = load ptr, ptr %[[ERROR]]
2253
+ // CHECK: store ptr %[[ERRORVAL]], ptr %[[ERROR]]
2254
+ // CHECK: ret ptr @"$s16external_closureTA.resume.0"
2255
+ // CHECK: }
2256
+ //
2257
+ sil @external_closure : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2258
+ sil @dont_crash : $@convention(thin) (Int) -> @owned @yield_once @callee_guaranteed (Int) -> (Int, @error Error) {
2259
+ bb0(%0 : $Int):
2260
+ %2 = function_ref @external_closure : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2261
+ %3 = partial_apply [callee_guaranteed] %2(%0) : $@convention(thin) @yield_once (Int, Int) -> (Int, @error Error)
2262
+ return %3 : $@yield_once @callee_guaranteed (Int) -> (Int, @error Error)
2263
+ }
2234
2264
2235
2265
// CHECK: define {{.*}} { ptr, ptr } @partially_apply_method_with_out_return
2236
2266
// CHECK-SAME: (ptr %[[ARG:.*]])
@@ -2246,3 +2276,22 @@ bb(%class : $SwiftClass):
2246
2276
%result = partial_apply [callee_guaranteed] %method_with_out_param(%class) : $@convention(method) @yield_once (SwiftClass) -> @out Int
2247
2277
return %result : $@callee_guaranteed @yield_once () -> @out Int
2248
2278
}
2279
+
2280
+ // CHECK: define {{.*}} { ptr, ptr } @convert_thin_test(i64 %[[ARG:.*]])
2281
+ // CHECK: entry:
2282
+ // CHECK: %[[PA_CTX_BOX:.*]] = call noalias ptr @swift_allocObject(ptr getelementptr inbounds (%swift.full_boxmetadata
2283
+ // CHECK: %[[PA_ARG:.*]] = getelementptr inbounds <{ %swift.refcounted, %TSi }>, ptr %[[PA_CTX_BOX]], i32 0, i32 1
2284
+ // CHECK: %[[ARG_PTR:.*]] = getelementptr inbounds %TSi, ptr %[[PA_ARG]], i32 0, i32 0
2285
+ // CHECK: store i64 %[[ARG]], ptr %[[ARG_PTR]]
2286
+ // CHECK: %[[RET:.*]] = insertvalue { ptr, ptr } { ptr @"$s4afunTA", ptr undef }, ptr %[[PA_CTX_BOX]], 1
2287
+ // CHECK: ret { ptr, ptr } %[[RET]]
2288
+ // CHECK: }
2289
+
2290
+ sil @afun : $@yield_once @convention(thin) (Int) -> (@error Error, @yields Int)
2291
+ sil @convert_thin_test : $@convention(thin) (Int) -> @yield_once @callee_guaranteed () -> (@error Error, @yields Int) {
2292
+ bb(%0 : $Int):
2293
+ %f = function_ref @afun : $@yield_once @convention(thin) (Int) -> (@error Error, @yields Int)
2294
+ %c = convert_function %f : $@yield_once @convention(thin) (Int) -> (@error Error, @yields Int) to $@yield_once @convention(thin) @noescape (Int) -> (@error Error, @yields Int)
2295
+ %pa = partial_apply [callee_guaranteed] %c(%0) : $@yield_once @convention(thin) @noescape (Int) -> (@error Error, @yields Int)
2296
+ return %pa : $@yield_once @callee_guaranteed () -> (@error Error, @yields Int)
2297
+ }
0 commit comments