Merge pull request #84528 from rjmccall/async-let-runtime-realism

Model async let begin/finish as builtins in SIL
This commit is contained in:
John McCall
2025-11-05 10:24:46 -08:00
committed by GitHub
48 changed files with 464 additions and 636 deletions

View File

@@ -262,6 +262,9 @@ bb0(%out : $*Pair<T>):
// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[T0]], 0
// CHECK-NEXT: call swiftcc void @swift_asyncLet_begin({{.*}}, ptr [[METADATA]], {{.*}})
%asyncLet = builtin "startAsyncLetWithLocalBuffer"<Pair<T>>(%scratch, %fn, %outPtr) : $Builtin.RawPointer
// CHECK: musttail call swifttailcc void @swift_asyncLet_finish
%t0 = builtin "finishAsyncLet"(%asyncLet, %outPtr) : $()
%t1 = builtin "endAsyncLetLifetime"(%asyncLet, %fn) : $()
%result = tuple ()
return %result

View File

@@ -170,7 +170,6 @@ entry:
// =============================================================================
sil @closure_for_with_async_let : $@convention(thin) @Sendable @async @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <Int>
sil @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
// Verify that a function with an async let builtin doesn't contain any marker
// instructions and that it is annotated no_onstack_pack_metadata. This is
@@ -194,8 +193,7 @@ entry:
%addr : $Optional<Builtin.RawPointer>,
%thick_closure : $@noescape @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <Int>,
%output_ptr : $Builtin.RawPointer) : $Builtin.RawPointer
%finish = function_ref @swift_asyncLet_finish : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
apply %finish(%alet, %output_ptr) : $@convention(thin) @async (Builtin.RawPointer, Builtin.RawPointer) -> ()
builtin "finishAsyncLet"(%alet, %output_ptr) : $()
builtin "endAsyncLetLifetime"(%alet : $Builtin.RawPointer) : $()
dealloc_stack %output : $*Int
%retval = tuple ()