Skip to content

Commit 76959b1

Browse files
committed
Remove CreateAsyncTaskGroupFuture and swift_task_create_group_future.
We've moved everything over to `CreateAsyncTask` now.
1 parent 8388a92 commit 76959b1

File tree

14 files changed

+8
-179
lines changed

14 files changed

+8
-179
lines changed

Diff for: include/swift/AST/Builtins.def

-12
Original file line numberDiff line numberDiff line change
@@ -816,18 +816,6 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(EndAsyncLet, "endAsyncLet", "", Special)
816816
BUILTIN_MISC_OPERATION_WITH_SILGEN(CreateAsyncTask,
817817
"createAsyncTask", "", Special)
818818

819-
/// createAsyncTaskGroupFuture(): (
820-
/// Int, // flags
821-
/// Builtin.RawPointer?, // group
822-
/// Builtin.RawPointer?, // options (TaskOptionRecord*)
823-
/// @escaping () async throws -> T // function
824-
/// ) -> Builtin.NativeObject
825-
///
826-
/// Create a new asynchronous task future, given flags, a parent task,
827-
/// task group and a function to execute.
828-
BUILTIN_MISC_OPERATION_WITH_SILGEN(CreateAsyncTaskGroupFuture,
829-
"createAsyncTaskGroupFuture", "", Special)
830-
831819
/// globalStringTablePointer has type String -> Builtin.RawPointer.
832820
/// It returns an immortal, global string table pointer for strings constructed
833821
/// from string literals. We consider it effects as readnone meaning that it

Diff for: include/swift/Runtime/Concurrency.h

-10
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@ AsyncTaskAndContext swift_task_create_common(
6767
FutureAsyncSignature::FunctionType *function, void *closureContext,
6868
size_t initialContextSize);
6969

70-
/// Create a task object with a future which will run the given
71-
/// closure, and offer its result to the task group
72-
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
73-
AsyncTaskAndContext swift_task_create_group_future(
74-
size_t flags,
75-
TaskGroup *group,
76-
TaskOptionRecord *options,
77-
const Metadata *futureResultType,
78-
void *closureEntryPoint, HeapObject * /* +1 */ closureContext);
79-
8070
/// Allocate memory in a task.
8171
///
8272
/// This must be called synchronously with the task.

Diff for: include/swift/Runtime/RuntimeFunctions.def

-18
Original file line numberDiff line numberDiff line change
@@ -1547,24 +1547,6 @@ FUNCTION(TaskCancel,
15471547
ARGS(SwiftTaskPtrTy),
15481548
ATTRS(NoUnwind, ArgMemOnly))
15491549

1550-
// AsyncTaskAndContext swift_task_create_group_future(
1551-
// size_t flags,
1552-
// TaskGroup *group,
1553-
// TaskOptionRecord *options
1554-
// const Metadata *futureResultType,
1555-
// void *closureEntry, HeapObject *closureContext);
1556-
FUNCTION(TaskCreateGroupFuture,
1557-
swift_task_create_group_future, SwiftCC,
1558-
ConcurrencyAvailability,
1559-
RETURNS(AsyncTaskAndContextTy),
1560-
ARGS(SizeTy,
1561-
SwiftTaskGroupPtrTy,
1562-
SwiftTaskOptionRecordPtrTy,
1563-
TypeMetadataPtrTy,
1564-
Int8PtrTy,
1565-
RefCountedPtrTy),
1566-
ATTRS(NoUnwind, ArgMemOnly))
1567-
15681550
// AsyncTaskAndContext swift_task_create(
15691551
// size_t taskCreateFlags,
15701552
// TaskOptionRecord *options,

Diff for: lib/AST/Builtins.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -1437,22 +1437,6 @@ static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id) {
14371437
return builder.build(id);
14381438
}
14391439

1440-
static ValueDecl *getCreateAsyncTaskGroupFuture(ASTContext &ctx, Identifier id) {
1441-
BuiltinFunctionBuilder builder(ctx);
1442-
auto genericParam = makeGenericParam().build(builder); // <T>
1443-
builder.addParameter(makeConcrete(ctx.getIntType())); // 0 flags
1444-
builder.addParameter(
1445-
makeConcrete(OptionalType::get(ctx.TheRawPointerType))); // 1 group
1446-
builder.addParameter(
1447-
makeConcrete(OptionalType::get(ctx.TheRawPointerType))); // 2 options
1448-
auto extInfo = ASTExtInfoBuilder().withAsync().withThrows().build();
1449-
builder.addParameter(
1450-
makeConcrete(FunctionType::get({ }, genericParam, extInfo))); // 3 operation
1451-
builder.setResult(makeConcrete(getAsyncTaskAndContextType(ctx)));
1452-
1453-
return builder.build(id);
1454-
}
1455-
14561440
static ValueDecl *getConvertTaskToJob(ASTContext &ctx, Identifier id) {
14571441
return getBuiltinFunction(ctx, id,
14581442
_thin,
@@ -2764,9 +2748,6 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
27642748
case BuiltinValueKind::CreateAsyncTask:
27652749
return getCreateAsyncTask(Context, Id);
27662750

2767-
case BuiltinValueKind::CreateAsyncTaskGroupFuture:
2768-
return getCreateAsyncTaskGroupFuture(Context, Id);
2769-
27702751
case BuiltinValueKind::ConvertTaskToJob:
27712752
return getConvertTaskToJob(Context, Id);
27722753

Diff for: lib/IRGen/GenBuiltin.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,8 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
270270
return;
271271
}
272272

273-
if (Builtin.ID == BuiltinValueKind::CreateAsyncTask ||
274-
Builtin.ID == BuiltinValueKind::CreateAsyncTaskGroupFuture) {
275-
273+
if (Builtin.ID == BuiltinValueKind::CreateAsyncTask) {
276274
auto flags = args.claimNext();
277-
auto taskGroup =
278-
(Builtin.ID == BuiltinValueKind::CreateAsyncTaskGroupFuture)
279-
? args.claimNext()
280-
: nullptr;
281275
auto taskOptions = args.claimNext();
282276
auto futureResultType = args.claimNext();
283277
auto taskFunction = args.claimNext();
@@ -286,7 +280,6 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
286280
auto newTaskAndContext = emitTaskCreate(
287281
IGF,
288282
flags,
289-
taskGroup,
290283
taskOptions,
291284
futureResultType,
292285
taskFunction, taskContext,

Diff for: lib/IRGen/GenCall.cpp

+7-21
Original file line numberDiff line numberDiff line change
@@ -3860,7 +3860,6 @@ void irgen::emitTaskCancel(IRGenFunction &IGF, llvm::Value *task) {
38603860
llvm::Value *irgen::emitTaskCreate(
38613861
IRGenFunction &IGF,
38623862
llvm::Value *flags,
3863-
llvm::Value *taskGroup,
38643863
llvm::Value *taskOptions,
38653864
llvm::Value *futureResultType,
38663865
llvm::Value *taskFunction,
@@ -3869,26 +3868,13 @@ llvm::Value *irgen::emitTaskCreate(
38693868
llvm::CallInst *result;
38703869
taskOptions = IGF.Builder.CreateBitOrPointerCast(
38713870
taskOptions, IGF.IGM.SwiftTaskOptionRecordPtrTy);
3872-
if (taskGroup && futureResultType) {
3873-
taskGroup = IGF.Builder.CreateBitOrPointerCast(
3874-
taskGroup, IGF.IGM.SwiftTaskGroupPtrTy);
3875-
result = IGF.Builder.CreateCall(
3876-
IGF.IGM.getTaskCreateGroupFutureFn(),
3877-
{flags,
3878-
taskGroup,
3879-
taskOptions,
3880-
futureResultType,
3881-
taskFunction, localContextInfo});
3882-
} else if (futureResultType) {
3883-
result = IGF.Builder.CreateCall(
3884-
IGF.IGM.getTaskCreateFn(),
3885-
{flags,
3886-
taskOptions,
3887-
futureResultType,
3888-
taskFunction, localContextInfo});
3889-
} else {
3890-
llvm_unreachable("no future?!");
3891-
}
3871+
assert(futureResultType && "No future?!");
3872+
result = IGF.Builder.CreateCall(
3873+
IGF.IGM.getTaskCreateFn(),
3874+
{flags,
3875+
taskOptions,
3876+
futureResultType,
3877+
taskFunction, localContextInfo});
38923878
result->setDoesNotThrow();
38933879
result->setCallingConv(IGF.IGM.SwiftCC);
38943880

Diff for: lib/IRGen/GenCall.h

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ namespace irgen {
229229
llvm::Value *emitTaskCreate(
230230
IRGenFunction &IGF,
231231
llvm::Value *flags,
232-
llvm::Value *taskGroup,
233232
llvm::Value *taskOptions,
234233
llvm::Value *futureResultType,
235234
llvm::Value *taskFunction,

Diff for: lib/SIL/IR/OperandOwnership.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,6 @@ BUILTIN_OPERAND_OWNERSHIP(ForwardingConsume, COWBufferForReading)
766766
BUILTIN_OPERAND_OWNERSHIP(ForwardingConsume, UnsafeGuaranteed)
767767

768768
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_FUTURE_FUNCTION = 3;
769-
const int PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION = 4;
770769

771770
OperandOwnership
772771
OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(BuiltinInst *bi,
@@ -782,20 +781,6 @@ OperandOwnershipBuiltinClassifier::visitCreateAsyncTask(BuiltinInst *bi,
782781
return OperandOwnership::InteriorPointer;
783782
}
784783

785-
OperandOwnership
786-
OperandOwnershipBuiltinClassifier::visitCreateAsyncTaskGroupFuture(BuiltinInst *bi,
787-
StringRef attr) {
788-
// The function operand is consumed by the new task.
789-
if (&op == &bi->getOperandRef(PARAMETER_INDEX_CREATE_ASYNC_TASK_GROUP_FUTURE_FUNCTION))
790-
return OperandOwnership::DestroyingConsume;
791-
792-
// FIXME: These are considered InteriorPointer because they may propagate a
793-
// pointer into a borrowed values. If they do not propagate an interior pointer,
794-
// then they should be InstantaneousUse instead and should not require a
795-
// guaranteed value.
796-
return OperandOwnership::InteriorPointer;
797-
}
798-
799784
OperandOwnership OperandOwnershipBuiltinClassifier::
800785
visitResumeNonThrowingContinuationReturning(BuiltinInst *bi, StringRef attr) {
801786
// The value operand is consumed.

Diff for: lib/SIL/IR/ValueOwnership.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ CONSTANT_OWNERSHIP_BUILTIN(None, GlobalStringTablePointer)
533533
CONSTANT_OWNERSHIP_BUILTIN(None, GetCurrentAsyncTask)
534534
CONSTANT_OWNERSHIP_BUILTIN(None, CancelAsyncTask)
535535
CONSTANT_OWNERSHIP_BUILTIN(Owned, CreateAsyncTask)
536-
CONSTANT_OWNERSHIP_BUILTIN(Owned, CreateAsyncTaskGroupFuture)
537536
CONSTANT_OWNERSHIP_BUILTIN(None, ConvertTaskToJob)
538537
CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDefaultActor)
539538
CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDefaultActor)

Diff for: lib/SIL/Utils/MemAccessUtils.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,6 @@ static void visitBuiltinAddress(BuiltinInst *builtin,
18551855
case BuiltinValueKind::TSanInoutAccess:
18561856
case BuiltinValueKind::CancelAsyncTask:
18571857
case BuiltinValueKind::CreateAsyncTask:
1858-
case BuiltinValueKind::CreateAsyncTaskGroupFuture:
18591858
case BuiltinValueKind::AutoDiffCreateLinearMapContext:
18601859
case BuiltinValueKind::AutoDiffAllocateSubcontext:
18611860
case BuiltinValueKind::InitializeDefaultActor:

Diff for: lib/SILGen/SILGenBuiltin.cpp

-36
Original file line numberDiff line numberDiff line change
@@ -1458,42 +1458,6 @@ static ManagedValue emitBuiltinCreateAsyncTask(
14581458
return SGF.emitManagedRValueWithCleanup(apply);
14591459
}
14601460

1461-
// Emit SIL for the named builtin: createAsyncTaskGroupFuture.
1462-
static ManagedValue emitBuiltinCreateAsyncTaskGroupFuture(
1463-
SILGenFunction &SGF, SILLocation loc, SubstitutionMap subs,
1464-
ArrayRef<ManagedValue> args, SGFContext C) {
1465-
ASTContext &ctx = SGF.getASTContext();
1466-
auto flags = args[0].forward(SGF);
1467-
auto group = args[1].borrow(SGF, loc).forward(SGF);
1468-
auto taskOptions = args[2].borrow(SGF, loc).forward(SGF);
1469-
1470-
// Form the metatype of the result type.
1471-
CanType futureResultType =
1472-
Type(
1473-
MetatypeType::get(GenericTypeParamType::get(0, 0, SGF.getASTContext()), MetatypeRepresentation::Thick))
1474-
.subst(subs)->getCanonicalType();
1475-
CanType anyTypeType = ExistentialMetatypeType::get(
1476-
ProtocolCompositionType::get(ctx, { }, false))->getCanonicalType();
1477-
auto &anyTypeTL = SGF.getTypeLowering(anyTypeType);
1478-
auto &futureResultTL = SGF.getTypeLowering(futureResultType);
1479-
auto futureResultMetadata = SGF.emitExistentialErasure(
1480-
loc, futureResultType, futureResultTL, anyTypeTL, { }, C,
1481-
[&](SGFContext C) -> ManagedValue {
1482-
return ManagedValue::forTrivialObjectRValue(
1483-
SGF.B.createMetatype(loc, SGF.getLoweredType(futureResultType)));
1484-
}).borrow(SGF, loc).forward(SGF);
1485-
1486-
auto function = emitFunctionArgumentForAsyncTaskEntryPoint(SGF, loc, args[3],
1487-
futureResultType);
1488-
auto apply = SGF.B.createBuiltin(
1489-
loc,
1490-
ctx.getIdentifier(
1491-
getBuiltinName(BuiltinValueKind::CreateAsyncTaskGroupFuture)),
1492-
SGF.getLoweredType(getAsyncTaskAndContextType(ctx)), subs,
1493-
{ flags, group, taskOptions, futureResultMetadata, function.forward(SGF) });
1494-
return SGF.emitManagedRValueWithCleanup(apply);
1495-
}
1496-
14971461
// Shared implementation of withUnsafeContinuation and
14981462
// withUnsafe[Throwing]Continuation.
14991463
static ManagedValue emitBuiltinWithUnsafeContinuation(

Diff for: lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static bool isBarrier(SILInstruction *inst) {
174174
case BuiltinValueKind::CancelAsyncTask:
175175
case BuiltinValueKind::StartAsyncLet:
176176
case BuiltinValueKind::CreateAsyncTask:
177-
case BuiltinValueKind::CreateAsyncTaskGroupFuture:
178177
case BuiltinValueKind::ConvertTaskToJob:
179178
case BuiltinValueKind::InitializeDefaultActor:
180179
case BuiltinValueKind::DestroyDefaultActor:

Diff for: stdlib/public/Concurrency/Task.cpp

-28
Original file line numberDiff line numberDiff line change
@@ -716,34 +716,6 @@ AsyncTaskAndContext swift::swift_task_create_async_let_future(
716716
futureResultType, taskEntry, closureContext, initialContextSize);
717717
}
718718

719-
AsyncTaskAndContext
720-
swift::swift_task_create_group_future(
721-
size_t flags,
722-
TaskGroup *group,
723-
TaskOptionRecord *options,
724-
const Metadata *futureResultType,
725-
void *closureEntry,
726-
HeapObject * /*+1*/closureContext) {
727-
FutureAsyncSignature::FunctionType *taskEntry;
728-
size_t initialContextSize;
729-
std::tie(taskEntry, initialContextSize)
730-
= getAsyncClosureEntryPointAndContextSize<
731-
FutureAsyncSignature,
732-
SpecialPointerAuthDiscriminators::AsyncFutureFunction
733-
>(closureEntry, closureContext);
734-
735-
// Wire the group into the options.
736-
TaskGroupTaskOptionRecord groupRecord(group);
737-
if (group) {
738-
groupRecord.Parent = options;
739-
options = &groupRecord;
740-
}
741-
742-
return swift_task_create_common(
743-
convertJobFlagsToTaskCreateFlags(flags), options, futureResultType,
744-
taskEntry, closureContext, initialContextSize);
745-
}
746-
747719
SWIFT_CC(swiftasync)
748720
static void swift_task_future_waitImpl(
749721
OpaqueValue *result,

Diff for: test/SILGen/async_builtins.swift

-8
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ public struct X {
2424
}
2525
}
2626

27-
// CHECK-LABEL: sil hidden [ossa] @$s4test1XV16launchGroupChildyyxlF : $@convention(method) <T> (@in_guaranteed T, X) -> () {
28-
func launchGroupChild<T>(_ value: T) {
29-
// CHECK: builtin "createAsyncTaskGroupFuture"<T>([[ZERO:%.*]] : $Int, [[NIL:%.*]] : $Optional<Builtin.RawPointer>, [[FN:%.*]] : $@async @callee_guaranteed @substituted <τ_0_0> () -> (@out τ_0_0, @error Error) for <T>) : $(Builtin.NativeObject, Builtin.RawPointer)
30-
_ = Builtin.createAsyncTaskGroupFuture(0, nil, nil) { () async throws -> T in
31-
return value
32-
}
33-
}
34-
3527
public func launchRocker<T>(closure: @escaping () async throws -> T) {
3628
_ = Builtin.createAsyncTask(0, nil, closure)
3729
}

0 commit comments

Comments
 (0)