@@ -348,3 +348,36 @@ bb0(%0 : @noImplicitCopy @_eagerMove $Int):
348
348
dealloc_stack %1 : $*@moveOnly Int
349
349
return %14 : $Int
350
350
}
351
+
352
+ struct _UnsafeContinuation<T, R> {}
353
+
354
+ sil @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
355
+ sil @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
356
+
357
+ // insertDestroyOfCapturedArguments should not crash on 'undef'
358
+ //
359
+ // CHECK-LABEL: sil hidden [ossa] @testCapturedUndef : $@convention(thin) (Int) -> (Int, @error any Error) {
360
+ // CHECK: partial_apply [callee_guaranteed] [on_stack] %{{.*}}(undef)
361
+ // CHECK-LABEL: } // end sil function 'testCapturedUndef'
362
+ sil hidden [ossa] @testCapturedUndef : $@convention(thin) (Int) -> (Int, @error any Error) {
363
+ bb0(%0 : $Int):
364
+ %5 = alloc_stack $Int
365
+ %6 = function_ref @testCapturedUndefClosure : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
366
+ %7 = partial_apply [callee_guaranteed] %6(undef) : $@convention(thin) @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>, Int) -> () for <Int>
367
+ %8 = convert_escape_to_noescape [not_guaranteed] %7 : $@callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int> to $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
368
+ destroy_value %7 : $@callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
369
+
370
+ %10 = function_ref @testCapturedUndefTakeClosure : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error)
371
+ try_apply %10<Int>(%5, %8) : $@convention(thin) <τ_0_0> (@guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <τ_0_0>) -> (@out τ_0_0, @error any Error), normal bb1, error bb2
372
+
373
+ bb1(%12 : $()):
374
+ destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
375
+ %15 = load [trivial] %5 : $*Int
376
+ dealloc_stack %5 : $*Int
377
+ return %15 : $Int
378
+
379
+ bb2(%19 : @owned $any Error):
380
+ destroy_value %8 : $@noescape @callee_guaranteed @substituted <τ_0_0> (_UnsafeContinuation<τ_0_0, any Error>) -> () for <Int>
381
+ dealloc_stack %5 : $*Int
382
+ throw %19 : $any Error
383
+ }
0 commit comments