mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Clean up the TaskGroup ABI:
- stop storing the parent task in the TaskGroup at the .swift level - make sure that swift_taskGroup_isCancelled is implied by the parent task being cancelled - make the TaskGroup structs frozen - make the withTaskGroup functions inlinable - remove swift_taskGroup_create - teach IRGen to allocate memory for the task group - don't deallocate the task group in swift_taskGroup_destroy To achieve the allocation change, introduce paired create/destroy builtins. Furthermore, remove the _swiftRetain and _swiftRelease functions and several calls to them. Replace them with uses of the appropriate builtins. I should probably change the builtins to return retained, since they're working with a managed type, but I'll do that in a separate commit.
This commit is contained in:
@@ -170,3 +170,27 @@ void irgen::emitGetCurrentExecutor(IRGenFunction &IGF, Explosion &out) {
|
||||
|
||||
IGF.emitAllExtractValues(call, IGF.IGM.SwiftExecutorTy, out);
|
||||
}
|
||||
|
||||
llvm::Value *irgen::emitCreateTaskGroup(IRGenFunction &IGF) {
|
||||
auto ty = llvm::ArrayType::get(IGF.IGM.Int8PtrTy, NumWords_TaskGroup);
|
||||
auto address = IGF.createAlloca(ty, Alignment(Alignment_TaskGroup));
|
||||
auto group = IGF.Builder.CreateBitCast(address.getAddress(),
|
||||
IGF.IGM.Int8PtrTy);
|
||||
IGF.Builder.CreateLifetimeStart(group);
|
||||
|
||||
auto *call = IGF.Builder.CreateCall(IGF.IGM.getTaskGroupInitializeFn(),
|
||||
{group});
|
||||
call->setDoesNotThrow();
|
||||
call->setCallingConv(IGF.IGM.SwiftCC);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
void irgen::emitDestroyTaskGroup(IRGenFunction &IGF, llvm::Value *group) {
|
||||
auto *call = IGF.Builder.CreateCall(IGF.IGM.getTaskGroupDestroyFn(),
|
||||
{group});
|
||||
call->setDoesNotThrow();
|
||||
call->setCallingConv(IGF.IGM.SwiftCC);
|
||||
|
||||
IGF.Builder.CreateLifetimeEnd(group);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user