diff --git a/include/swift/AST/Builtins.def b/include/swift/AST/Builtins.def index 993b492a380a3..f1f7c0bbf37ee 100644 --- a/include/swift/AST/Builtins.def +++ b/include/swift/AST/Builtins.def @@ -953,9 +953,9 @@ BUILTIN_MISC_OPERATION(AddressOfBorrowOpaque, "addressOfBorrowOpaque", "", Speci BUILTIN_MISC_OPERATION(UnprotectedAddressOfBorrowOpaque, "unprotectedAddressOfBorrowOpaque", "", Special) /// createTask(flags: Int, +/// initialSerialExecutor: (Builtin.Executor)? = nil, /// taskGroup: Builtin.RawPointer? = nil, /// initialTaskExecutor: (Builtin.Executor)? = nil, -/// initialExecutor: (Builtin.Executor)? = nil, /// operation: @escaping () async throws -> T) /// -> Builtin.NativeObject, Builtin.RawPointer) /// @@ -963,9 +963,9 @@ BUILTIN_MISC_OPERATION(UnprotectedAddressOfBorrowOpaque, "unprotectedAddressOfBo BUILTIN_SIL_OPERATION(CreateTask, "createTask", Special) /// createDiscardingTask(flags: Int, +/// initialSerialExecutor: (Builtin.Executor)? = nil, /// taskGroup: Builtin.RawPointer? = nil, /// initialTaskExecutor: (Builtin.Executor)? = nil, -/// initialExecutor: (Builtin.Executor)? = nil, /// operation: @escaping () async throws -> ()) /// -> (Builtin.NativeObject, Builtin.RawPointer) /// diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 635888724327b..19860a72a457e 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -1531,8 +1531,8 @@ static ValueDecl *getCreateTask(ASTContext &ctx, Identifier id) { ctx, id, _thin, _generics(_unrestricted, _conformsToDefaults(0)), _parameters( _label("flags", _swiftInt), + _label("initialSerialExecutor", _defaulted(_optional(_executor), _nil)), _label("taskGroup", _defaulted(_optional(_rawPointer), _nil)), - //_label("initialExecutor", _defaulted(_optional(_executor), _nil)), _label("initialTaskExecutor", _defaulted(_optional(_executor), _nil)), _label("operation", _function(_async(_throws(_sendable(_thick))), _typeparam(0), _parameters()))), @@ -1544,8 +1544,8 @@ static ValueDecl *getCreateDiscardingTask(ASTContext &ctx, Identifier id) { ctx, id, _thin, _parameters( _label("flags", _swiftInt), + _label("initialSerialExecutor", _defaulted(_optional(_executor), _nil)), _label("taskGroup", _defaulted(_optional(_rawPointer), _nil)), - //_label("initialExecutor", _defaulted(_optional(_executor), _nil)), _label("initialTaskExecutor", _defaulted(_optional(_executor), _nil)), _label("operation", _function(_async(_throws(_sendable(_thick))), _void, _parameters()))), diff --git a/lib/IRGen/GenConcurrency.cpp b/lib/IRGen/GenConcurrency.cpp index edf2463280171..8bb4d5fd05ff0 100644 --- a/lib/IRGen/GenConcurrency.cpp +++ b/lib/IRGen/GenConcurrency.cpp @@ -598,6 +598,31 @@ llvm::Value *irgen::maybeAddEmbeddedSwiftResultTypeInfo(IRGenFunction &IGF, namespace { +struct InitialSerialExecutorRecordTraits { + static StringRef getLabel() { + return "initial_serial_executor"; + } + static llvm::StructType *getRecordType(IRGenModule &IGM) { + return IGM.SwiftInitialSerialExecutorTaskOptionRecordTy; + } + static TaskOptionRecordFlags getRecordFlags() { + return TaskOptionRecordFlags(TaskOptionRecordKind::InitialSerialExecutor); + } + static CanType getValueType(ASTContext &ctx) { + return ctx.TheExecutorType; + } + + void initialize(IRGenFunction &IGF, Address recordAddr, + Explosion &serialExecutor) const { + auto executorRecord = + IGF.Builder.CreateStructGEP(recordAddr, 1, 2 * IGF.IGM.getPointerSize()); + IGF.Builder.CreateStore(serialExecutor.claimNext(), + IGF.Builder.CreateStructGEP(executorRecord, 0, Size())); + IGF.Builder.CreateStore(serialExecutor.claimNext(), + IGF.Builder.CreateStructGEP(executorRecord, 1, Size())); + } +}; + struct TaskGroupRecordTraits { static StringRef getLabel() { return "task_group"; @@ -647,6 +672,15 @@ struct InitialTaskExecutorRecordTraits { } // end anonymous namespace +static llvm::Value * +maybeAddInitialSerialExecutorOptionRecord(IRGenFunction &IGF, + llvm::Value *prevOptions, + OptionalExplosion &serialExecutor) { + return maybeAddOptionRecord(IGF, prevOptions, + InitialSerialExecutorRecordTraits(), + serialExecutor); +} + static llvm::Value * maybeAddTaskGroupOptionRecord(IRGenFunction &IGF, llvm::Value *prevOptions, OptionalExplosion &taskGroup) { @@ -665,6 +699,7 @@ maybeAddInitialTaskExecutorOptionRecord(IRGenFunction &IGF, std::pair irgen::emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags, + OptionalExplosion &serialExecutor, OptionalExplosion &taskGroup, OptionalExplosion &taskExecutor, Explosion &taskFunction, @@ -686,6 +721,10 @@ irgen::emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags, resultTypeMetadata = IGF.emitTypeMetadataRef(resultType); } + // Add an option record for the initial serial executor, if present. + taskOptions = + maybeAddInitialSerialExecutorOptionRecord(IGF, taskOptions, serialExecutor); + // Add an option record for the task group, if present. taskOptions = maybeAddTaskGroupOptionRecord(IGF, taskOptions, taskGroup); diff --git a/lib/IRGen/GenConcurrency.h b/lib/IRGen/GenConcurrency.h index dacaf63c43cef..0fbb5169445fc 100644 --- a/lib/IRGen/GenConcurrency.h +++ b/lib/IRGen/GenConcurrency.h @@ -102,6 +102,7 @@ llvm::Value *maybeAddEmbeddedSwiftResultTypeInfo(IRGenFunction &IGF, /// task function. std::pair emitTaskCreate(IRGenFunction &IGF, llvm::Value *flags, + OptionalExplosion &initialExecutor, OptionalExplosion &taskGroup, OptionalExplosion &taskExecutor, Explosion &taskFunction, diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index bbad48af76bfe..d542f1aac0fbf 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -702,6 +702,11 @@ IRGenModule::IRGenModule(IRGenerator &irgen, ExecutorFirstTy, // identity ExecutorSecondTy, // implementation }); + SwiftInitialSerialExecutorTaskOptionRecordTy = + createStructType(*this, "swift.serial_executor_task_option", { + SwiftTaskOptionRecordTy, // Base option record + SwiftExecutorTy, // Executor + }); SwiftInitialTaskExecutorPreferenceTaskOptionRecordTy = createStructType(*this, "swift.task_executor_task_option", { SwiftTaskOptionRecordTy, // Base option record diff --git a/lib/IRGen/IRGenModule.h b/lib/IRGen/IRGenModule.h index 19ff63561d848..68056f421558b 100644 --- a/lib/IRGen/IRGenModule.h +++ b/lib/IRGen/IRGenModule.h @@ -819,6 +819,7 @@ class IRGenModule { llvm::IntegerType *SwiftTaskOptionRecordPtrTy; llvm::PointerType *SwiftTaskGroupPtrTy; llvm::StructType *SwiftTaskOptionRecordTy; + llvm::StructType *SwiftInitialSerialExecutorTaskOptionRecordTy; llvm::StructType *SwiftTaskGroupTaskOptionRecordTy; llvm::StructType *SwiftInitialTaskExecutorPreferenceTaskOptionRecordTy; llvm::StructType *SwiftResultTypeInfoTaskOptionRecordTy; diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index c835e1e3efeef..4f08e0472f5d8 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -3568,13 +3568,14 @@ static void emitBuiltinStackDealloc(IRGenSILFunction &IGF, static void emitBuiltinCreateAsyncTask(IRGenSILFunction &IGF, swift::BuiltinInst *i) { auto flags = IGF.getLoweredSingletonExplosion(i->getOperand(0)); - auto taskGroup = IGF.getLoweredOptionalExplosion(i->getOperand(1)); - auto taskExecutor = IGF.getLoweredOptionalExplosion(i->getOperand(2)); - Explosion taskFunction = IGF.getLoweredExplosion(i->getOperand(3)); + auto serialExecutor = IGF.getLoweredOptionalExplosion(i->getOperand(1)); + auto taskGroup = IGF.getLoweredOptionalExplosion(i->getOperand(2)); + auto taskExecutor = IGF.getLoweredOptionalExplosion(i->getOperand(3)); + Explosion taskFunction = IGF.getLoweredExplosion(i->getOperand(4)); auto taskAndContext = - emitTaskCreate(IGF, flags, taskGroup, taskExecutor, taskFunction, - i->getSubstitutions()); + emitTaskCreate(IGF, flags, serialExecutor, taskGroup, taskExecutor, + taskFunction, i->getSubstitutions()); Explosion out; out.add(taskAndContext.first); out.add(taskAndContext.second); diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index 65f5e065a6f5c..b30c397c95182 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -2292,15 +2292,17 @@ class SILVerifier : public SILVerifierBase { if (builtinKind == BuiltinValueKind::CreateAsyncTask) { requireType(BI->getType(), _object(_tuple(_nativeObject, _rawPointer)), "result of createAsyncTask"); - require(arguments.size() == 4, - "createAsyncTask expects four arguments"); + require(arguments.size() == 5, + "createAsyncTask expects five arguments"); requireType(arguments[0]->getType(), _object(_swiftInt), "first argument of createAsyncTask"); - requireType(arguments[1]->getType(), _object(_optional(_rawPointer)), + requireType(arguments[1]->getType(), _object(_optional(_executor)), "second argument of createAsyncTask"); - requireType(arguments[2]->getType(), _object(_optional(_executor)), + requireType(arguments[2]->getType(), _object(_optional(_rawPointer)), "third argument of createAsyncTask"); - auto fnType = requireObjectType(SILFunctionType, arguments[3], + requireType(arguments[3]->getType(), _object(_optional(_executor)), + "fourth argument of createAsyncTask"); + auto fnType = requireObjectType(SILFunctionType, arguments[4], "result of createAsyncTask"); auto expectedExtInfo = SILExtInfoBuilder().withAsync(true).withConcurrent(true).build(); diff --git a/lib/SILGen/SILGenBuiltin.cpp b/lib/SILGen/SILGenBuiltin.cpp index a16c6241d71aa..0475620edab9e 100644 --- a/lib/SILGen/SILGenBuiltin.cpp +++ b/lib/SILGen/SILGenBuiltin.cpp @@ -1576,6 +1576,14 @@ static ManagedValue emitCreateAsyncTask(SILGenFunction &SGF, SILLocation loc, ManagedValue flags = nextArg().getAsSingleValue(SGF); + ManagedValue initialExecutor = [&] { + if (options & CreateTaskOptions::OptionalEverything) { + return nextArg().getAsSingleValue(SGF); + } else { + return emitOptionalNone(ctx.TheExecutorType); + } + }(); + ManagedValue taskGroup = [&] { if (options & CreateTaskOptions::OptionalEverything) { return nextArg().getAsSingleValue(SGF); @@ -1638,6 +1646,7 @@ static ManagedValue emitCreateAsyncTask(SILGenFunction &SGF, SILLocation loc, SILValue builtinArgs[] = { flags.getUnmanagedValue(), + initialExecutor.getUnmanagedValue(), taskGroup.getUnmanagedValue(), taskExecutor.getUnmanagedValue(), functionValue.forward(SGF) diff --git a/test/Concurrency/async_main.swift b/test/Concurrency/async_main.swift index fdc52c3f8a620..08aee73185859 100644 --- a/test/Concurrency/async_main.swift +++ b/test/Concurrency/async_main.swift @@ -67,13 +67,14 @@ func asyncFunc() async { // CHECK-SIL-NEXT: [[ASYNC_MAIN_FN:%.*]] = function_ref @async_Main : $@convention(thin) @async () -> () // CHECK-SIL-NEXT: [[T0:%.*]] = integer_literal $Builtin.Int64, 2048 // CHECK-SIL-NEXT: [[FLAGS:%.*]] = struct $Int ([[T0]] : $Builtin.Int64) +// CHECK-SIL-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-SIL-NEXT: [[GROUP:%.*]] = enum $Optional, #Optional.none // CHECK-SIL-NEXT: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-SIL-NEXT: // function_ref thunk for @escaping @convention(thin) @async () -> () // CHECK-SIL-NEXT: [[THUNK_FN:%.*]] = function_ref @$sIetH_yts5Error_pIeghHrzo_TR : $@convention(thin) @Sendable @async (@convention(thin) @async () -> ()) -> (@out (), @error any Error) // CHECK-SIL-NEXT: [[THUNK:%.*]] = partial_apply [callee_guaranteed] [[THUNK_FN]]([[ASYNC_MAIN_FN]]) : $@convention(thin) @Sendable @async (@convention(thin) @async () -> ()) -> (@out (), @error any Error) // CHECK-SIL-NEXT: [[CONVERTED_THUNK:%.*]] = convert_function [[THUNK]] : $@Sendable @async @callee_guaranteed () -> (@out (), @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()> -// CHECK-SIL-NEXT: [[TASK_RESULT:%.*]] = builtin "createAsyncTask"<()>([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_THUNK]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()>) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-SIL-NEXT: [[TASK_RESULT:%.*]] = builtin "createAsyncTask"<()>([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_THUNK]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for <()>) : $(Builtin.NativeObject, Builtin.RawPointer) // CHECK-SIL-NEXT: [[TASK:%.*]] = tuple_extract [[TASK_RESULT]] : $(Builtin.NativeObject, Builtin.RawPointer), 0 // CHECK-SIL-NEXT: // function_ref swift_job_run // CHECK-SIL-NEXT: [[RUN_FN:%.*]] = function_ref @swift_job_run : $@convention(thin) (UnownedJob, UnownedSerialExecutor) -> () diff --git a/test/IRGen/async/builtins.sil b/test/IRGen/async/builtins.sil index c82d046211c06..d5deab00e5e98 100644 --- a/test/IRGen/async/builtins.sil +++ b/test/IRGen/async/builtins.sil @@ -33,10 +33,37 @@ bb0(%0 : @guaranteed $Builtin.NativeObject): sil hidden [ossa] @launch_future : $@convention(method) (Int, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) -> () { bb0(%flags : $Int, %taskFunction: @owned $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ): // CHECK-NOT: br i1 - // CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create( + // CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create([[INT]] %0, [[INT]] 0, ptr %T, ptr %1, ptr %2) + %optSerialExecutor = enum $Optional, #Optional.none + %optTaskGroup = enum $Optional, #Optional.none + %optTaskExecutor = enum $Optional, #Optional.none + %20 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer) + %21 = tuple () + return %21 : $() +} + +// CHECK-LABEL: define hidden swift{{(tail)?}}cc void @launch_future_on( +sil hidden [ossa] @launch_future_on : $@convention(method) (Int, Builtin.Executor, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) -> () { +bb0(%flags : $Int, %serialExecutor : $Builtin.Executor, %taskFunction: @owned $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ): + // CHECK: [[EXECUTOR_RECORD:%.*]] = alloca %swift.serial_executor_task_option + // CHECK-NOT: br i1 + // CHECK: [[BASE_GEP:%.*]] = getelementptr inbounds %swift.serial_executor_task_option, ptr [[EXECUTOR_RECORD]], i32 0, i32 0 + // CHECK: [[FLAGS_GEP:%.*]] = getelementptr inbounds %swift.task_option, ptr [[BASE_GEP]], i32 0, i32 0 + // CHECK: store [[INT]] 0, ptr [[FLAGS_GEP]], align + // CHECK: [[PARENT_GEP:%.*]] = getelementptr inbounds %swift.task_option, ptr [[BASE_GEP]], i32 0, i32 1 + // CHECK: store [[INT]] 0, ptr [[PARENT_GEP]], align + // CHECK: [[EXECUTOR_GEP:%.*]] = getelementptr inbounds %swift.serial_executor_task_option, ptr [[EXECUTOR_RECORD]], i32 0, i32 1 + // CHECK: [[EXECUTOR_IDENT_GEP:%.*]] = getelementptr inbounds %swift.executor, ptr [[EXECUTOR_GEP]], i32 0, i32 0 + // CHECK: store [[INT]] %1, ptr [[EXECUTOR_IDENT_GEP]], align + // CHECK: [[EXECUTOR_IMPL_GEP:%.*]] = getelementptr inbounds %swift.executor, ptr [[EXECUTOR_GEP]], i32 0, i32 1 + // CHECK: store [[INT]] %2, ptr [[EXECUTOR_IMPL_GEP]], align + // CHECK: [[OPTIONS_PTR:%.*]] = ptrtoint ptr [[EXECUTOR_RECORD]] to [[INT]] + // CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create([[INT]] %0, [[INT]] [[OPTIONS_PTR]], ptr %T, ptr %3, ptr %4) + %optSerialExecutor = enum $Optional, #Optional.some, %serialExecutor : $Builtin.Executor %optTaskGroup = enum $Optional, #Optional.none %optTaskExecutor = enum $Optional, #Optional.none - %20 = builtin "createAsyncTask"(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + %20 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer) %21 = tuple () return %21 : $() @@ -56,9 +83,10 @@ bb0(%flags : $Int, %taskFunction: @owned $@Sendable @async @callee_guaranteed @s // CHECK: call swiftcc %swift.async_task_and_context @swift_task_create([[INT]] %3, [[INT]] [[OPTIONS_PTR]], sil hidden @launch_future_in_group : $@convention(thin) (Builtin.RawPointer, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for , Int) -> () { bb0(%taskGroup : $Builtin.RawPointer, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for , %flags: $Int): + %optSerialExecutor = enum $Optional, #Optional.none %optTaskGroup = enum $Optional, #Optional.some!enumelt, %taskGroup : $Builtin.RawPointer %optTaskExecutor = enum $Optional, #Optional.none - %9 = builtin "createAsyncTask"(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + %9 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) %10 = tuple_extract %9 : $(Builtin.NativeObject, Builtin.RawPointer), 0 strong_release %10 : $Builtin.NativeObject %12 = tuple () @@ -86,8 +114,9 @@ bb0(%flags : $Int, %optTaskGroup : $Optional, %taskFunction: // CHECK: phi i64 [ 0, %entry ], [ [[OPTIONS_PTR]], %task_group.some ] // CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create( + %optSerialExecutor = enum $Optional, #Optional.none %optTaskExecutor = enum $Optional, #Optional.none - %20 = builtin "createAsyncTask"(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + %20 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer) %result = tuple () return %result : $() @@ -96,11 +125,12 @@ bb0(%flags : $Int, %optTaskGroup : $Optional, %taskFunction: // CHECK-LABEL: define hidden swift{{(tail)?}}cc void @launch_discarding_future_in_group sil hidden @launch_discarding_future_in_group : $@convention(thin) (Builtin.RawPointer, @owned @Sendable @async @callee_guaranteed () -> @error Error, Int) -> () { bb0(%taskGroup : $Builtin.RawPointer, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error, %flags: $Int): + %optSerialExecutor = enum $Optional, #Optional.none %optTaskGroup = enum $Optional, #Optional.some!enumelt, %taskGroup : $Builtin.RawPointer %optTaskExecutor = enum $Optional, #Optional.none // CHECK-NOT: br i1 // CHECK: call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create( - %9 = builtin "createAsyncTask"(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error) : $(Builtin.NativeObject, Builtin.RawPointer) + %9 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error) : $(Builtin.NativeObject, Builtin.RawPointer) %10 = tuple_extract %9 : $(Builtin.NativeObject, Builtin.RawPointer), 0 strong_release %10 : $Builtin.NativeObject %12 = tuple () @@ -110,6 +140,7 @@ bb0(%taskGroup : $Builtin.RawPointer, %taskFunction : $@Sendable @async @callee_ // CHECK-LABEL: define hidden swift{{(tail)?}}cc void @launch_discarding_future_in_group_with_executor sil hidden @launch_discarding_future_in_group_with_executor : $@convention(thin) (Builtin.RawPointer, Builtin.Executor, @owned @Sendable @async @callee_guaranteed () -> @error Error, Int) -> () { bb0(%taskGroup : $Builtin.RawPointer, %taskExecutor : $Builtin.Executor, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error, %flags: $Int): + %optSerialExecutor = enum $Optional, #Optional.none %optTaskGroup = enum $Optional, #Optional.some!enumelt, %taskGroup : $Builtin.RawPointer %optTaskExecutor = enum $Optional, #Optional.some!enumelt, %taskExecutor : $Builtin.Executor // CHECK: [[GROUP_RECORD:%.*]] = alloca %swift.task_group_task_option @@ -138,7 +169,7 @@ bb0(%taskGroup : $Builtin.RawPointer, %taskExecutor : $Builtin.Executor, %taskFu // CHECK: [[OPTIONS_PTR:%.*]] = ptrtoint ptr [[EXECUTOR_RECORD]] to [[INT]] // CHECK: call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create([[INT]] %5, [[INT]] [[OPTIONS_PTR]] - %9 = builtin "createAsyncTask"(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor: $Optional, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error) : $(Builtin.NativeObject, Builtin.RawPointer) + %9 = builtin "createAsyncTask"(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor: $Optional, %taskFunction : $@Sendable @async @callee_guaranteed () -> @error Error) : $(Builtin.NativeObject, Builtin.RawPointer) %10 = tuple_extract %9 : $(Builtin.NativeObject, Builtin.RawPointer), 0 strong_release %10 : $Builtin.NativeObject %12 = tuple () @@ -148,10 +179,11 @@ bb0(%taskGroup : $Builtin.RawPointer, %taskExecutor : $Builtin.Executor, %taskFu // CHECK-LABEL: define hidden swift{{(tail)?}}cc void @launch_void_future sil hidden [ossa] @launch_void_future : $@convention(method) (Int, Builtin.RawPointer, @owned @Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>) -> () { bb0(%flags : $Int, %taskGroup : $Builtin.RawPointer, %taskFunction: @owned $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>): + %optSerialExecutor = enum $Optional, #Optional.none %optTaskGroup = enum $Optional, #Optional.some!enumelt, %taskGroup : $Builtin.RawPointer %optTaskExecutor = enum $Optional, #Optional.none // CHECK: [[NEW_TASK_AND_CONTEXT:%.*]] = call swift{{(tail)?}}cc %swift.async_task_and_context @swift_task_create( - %20 = builtin "createAsyncTask"<()>(%flags : $Int, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>) : $(Builtin.NativeObject, Builtin.RawPointer) + %20 = builtin "createAsyncTask"<()>(%flags : $Int, %optSerialExecutor : $Optional, %optTaskGroup : $Optional, %optTaskExecutor : $Optional, %taskFunction : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <()>) : $(Builtin.NativeObject, Builtin.RawPointer) destroy_value %20 : $(Builtin.NativeObject, Builtin.RawPointer) %21 = tuple () return %21 : $() diff --git a/test/SILGen/async_builtins.swift b/test/SILGen/async_builtins.swift index d41d3b8641a4b..bc8ab85d6a621 100644 --- a/test/SILGen/async_builtins.swift +++ b/test/SILGen/async_builtins.swift @@ -18,12 +18,13 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV12launchFutureyyxlF : $@convention(method) (@in_guaranteed T, X) -> () // CHECK: [[FLAGS:%.*]] = apply + // CHECK: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[GROUP:%.*]] = enum $Optional, #Optional.none // CHECK: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE_FN:%.*]] = function_ref @$s4test1XV12launchFutureyyxlFxyYaYbKcfU_ : // CHECK: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[CLOSURE_FN]]({{.*}}) : $@convention(thin) @Sendable @async <τ_0_0> (@in_guaranteed τ_0_0) -> (@out τ_0_0, @error any Error) // CHECK: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for - // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func launchFuture(_ value: T) { _ = Builtin.createAsyncTask(0) { () async throws -> T in return value @@ -32,12 +33,13 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV16launchGroupChild_5groupyx_BptlF : $@convention(method) (@in_guaranteed T, Builtin.RawPointer, X) -> () { // CHECK: [[FLAGS:%.*]] = apply + // CHECK: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %1 : $Builtin.RawPointer // CHECK: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE_FN:%.*]] = function_ref @$s4test1XV16launchGroupChild_5groupyx_BptlFxyYaYbKcfU_ : // CHECK: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[CLOSURE_FN]]({{.*}}) : $@convention(thin) @Sendable @async <τ_0_0> (@in_guaranteed τ_0_0) -> (@out τ_0_0, @error any Error) // CHECK: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for - // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func launchGroupChild(_ value: T, group: Builtin.RawPointer) { _ = Builtin.createAsyncTaskInGroup(0, group) { () async throws -> T in return value @@ -46,11 +48,12 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV26launchDiscardingGroupChild5groupyBp_tF : $@convention(method) (Builtin.RawPointer, X) -> () { // CHECK: [[FLAGS:%.*]] = apply + // CHECK: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.RawPointer // CHECK: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE_FN:%.*]] = function_ref @$s4test1XV26launchDiscardingGroupChild5groupyBp_tFyyYaYbKcfU_ : // CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[CLOSURE_FN]] - // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) + // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) func launchDiscardingGroupChild(group: Builtin.RawPointer) { _ = Builtin.createAsyncDiscardingTaskInGroup(0, group) { () async throws in return @@ -63,12 +66,13 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV24launchFutureWithExecutor_8executoryx_BetlF : $@convention(method) (@in_guaranteed T, Builtin.Executor, X) -> () { // CHECK: [[FLAGS:%.*]] = apply + // CHECK: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[GROUP:%.*]] = enum $Optional, #Optional.none // CHECK: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %1 : $Builtin.Executor // CHECK: [[CLOSURE_FN:%.*]] = function_ref @$s4test1XV24launchFutureWithExecutor_8executoryx_BetlFxyYaYbKcfU_ : // CHECK: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [[CLOSURE_FN]]({{.*}}) : $@convention(thin) @Sendable @async <τ_0_0> (@in_guaranteed τ_0_0) -> (@out τ_0_0, @error any Error) // CHECK: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for - // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) + // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func launchFutureWithExecutor(_ value: T, executor: Builtin.Executor) { _ = Builtin.createAsyncTaskWithExecutor(0, executor) { () async throws -> T in return value @@ -77,11 +81,12 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test1XV34launchDiscardingFutureWithExecutor5group8executoryBp_BetF : $@convention(method) (Builtin.RawPointer, Builtin.Executor, X) -> () { // CHECK: [[FLAGS:%.*]] = apply + // CHECK: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.RawPointer // CHECK: [[TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %1 : $Builtin.Executor // CHECK: [[CLOSURE_FN:%.*]] = function_ref @$s4test1XV34launchDiscardingFutureWithExecutor5group8executoryBp_BetFyyYaYbKcfU_ : // CHECK: [[CLOSURE:%.*]] = thin_to_thick_function [[CLOSURE_FN]] - // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) + // CHECK: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[GROUP]] : $Optional, [[TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) func launchDiscardingFutureWithExecutor(group: Builtin.RawPointer, executor: Builtin.Executor) { _ = Builtin.createAsyncDiscardingTaskInGroupWithExecutor(0, group, executor) { () async throws in return @@ -91,11 +96,12 @@ public struct X { // CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask5valueyx_tlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE:%.*]] = partial_apply // CHECK-NEXT: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func testCreateTask(value: T) { _ = Builtin.createTask(flags: 0) { value @@ -104,37 +110,53 @@ func testCreateTask(value: T) { // CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask5group5valueyBp_xtlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.RawPointer // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE:%.*]] = partial_apply // CHECK-NEXT: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func testCreateTask(group: Builtin.RawPointer, value: T) { _ = Builtin.createTask(flags: 0, taskGroup: group) { value } } -// CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask8executor5valueyBe_xtlF +// CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask12taskExecutor5valueyBe_xtlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.Executor // CHECK: [[CLOSURE:%.*]] = partial_apply // CHECK-NEXT: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) -func testCreateTask(executor: Builtin.Executor, value: T) { - _ = Builtin.createTask(flags: 0, initialTaskExecutor: executor) { +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) +func testCreateTask(taskExecutor: Builtin.Executor, value: T) { + _ = Builtin.createTask(flags: 0, initialTaskExecutor: taskExecutor) { value } } +// CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask14serialExecutor5valueyBe_xtlF +// CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.Executor +// CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.none +// CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none +// CHECK: [[CLOSURE:%.*]] = partial_apply +// CHECK-NEXT: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) +func testCreateTask(serialExecutor: Builtin.Executor, value: T) { + _ = Builtin.createTask(flags: 0, initialSerialExecutor: serialExecutor) { + value + } +} // CHECK-LABEL: sil hidden [ossa] @$s4test0A10CreateTask5group8executor5valueyBp_BextlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.RawPointer // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %1 : $Builtin.Executor // CHECK: [[CLOSURE:%.*]] = partial_apply // CHECK-NEXT: [[CONVERTED_CLOSURE:%.*]] = convert_function [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> (@out T, @error any Error) to $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CONVERTED_CLOSURE]] : $@Sendable @async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error any Error) for ) : $(Builtin.NativeObject, Builtin.RawPointer) func testCreateTask(group: Builtin.RawPointer, executor: Builtin.Executor, value: T) { _ = Builtin.createTask(flags: 0, taskGroup: group, initialTaskExecutor: executor) { value @@ -146,10 +168,11 @@ func testCreateTask(group: Builtin.RawPointer, executor: Builtin.Executor, va // as needed. // CHECK-LABEL: sil hidden [ossa] @$s4test0A20CreateDiscardingTask5valueyx_tlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.none // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.none // CHECK: [[CLOSURE:%.*]] = partial_apply -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) func testCreateDiscardingTask(value: T) { _ = Builtin.createDiscardingTask(flags: 0) { _ = value @@ -161,10 +184,11 @@ func testCreateDiscardingTask(value: T) { // as needed. // CHECK-LABEL: sil hidden [ossa] @$s4test0A20CreateDiscardingTask5group8executor5valueyBp_BextlF // CHECK: [[FLAGS:%.*]] = apply +// CHECK-NEXT: [[OPT_SERIAL_EXECUTOR:%.*]] = enum $Optional, #Optional.none!enumelt // CHECK-NEXT: [[OPT_GROUP:%.*]] = enum $Optional, #Optional.some!enumelt, %0 : $Builtin.RawPointer // CHECK-NEXT: [[OPT_TASK_EXECUTOR:%.*]] = enum $Optional, #Optional.some!enumelt, %1 : $Builtin.Executor // CHECK: [[CLOSURE:%.*]] = partial_apply -// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) +// CHECK-NEXT: builtin "createAsyncTask"([[FLAGS]] : $Int, [[OPT_SERIAL_EXECUTOR]] : $Optional, [[OPT_GROUP]] : $Optional, [[OPT_TASK_EXECUTOR]] : $Optional, [[CLOSURE]] : $@Sendable @async @callee_guaranteed () -> @error any Error) : $(Builtin.NativeObject, Builtin.RawPointer) func testCreateDiscardingTask(group: Builtin.RawPointer, executor: Builtin.Executor, value: T) { _ = Builtin.createDiscardingTask(flags: 0, taskGroup: group, initialTaskExecutor: executor) { _ = value