Skip to content

Commit 904876e

Browse files
committed
[Async CC] Pass the function's task to task_[de]alloc.
Previously, a null task was always passed to swift_task_alloc/swift_task_dealloc. Now that the current task is available as one of the arguments to every async function, pass that value along to the runtime de/allocation functions.
1 parent 1e0d6f3 commit 904876e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,6 @@ static Alignment getAsyncContextAlignment(IRGenModule &IGM) {
293293
return IGM.getPointerAlignment();
294294
}
295295

296-
static llvm::Value *getAsyncTask(IRGenFunction &IGF) {
297-
// TODO: Return the appropriate task.
298-
return llvm::Constant::getNullValue(IGF.IGM.SwiftTaskPtrTy);
299-
}
300-
301296
llvm::Value *IRGenFunction::getAsyncTask() {
302297
assert(isAsync());
303298
auto *value = CurFn->getArg((unsigned)AsyncFunctionArgumentIndex::Task);
@@ -3379,7 +3374,7 @@ void irgen::emitDeallocYieldManyCoroutineBuffer(IRGenFunction &IGF,
33793374
Address irgen::emitTaskAlloc(IRGenFunction &IGF, llvm::Value *size,
33803375
Alignment alignment) {
33813376
auto *call = IGF.Builder.CreateCall(IGF.IGM.getTaskAllocFn(),
3382-
{getAsyncTask(IGF), size});
3377+
{IGF.getAsyncTask(), size});
33833378
call->setDoesNotThrow();
33843379
call->setCallingConv(IGF.IGM.SwiftCC);
33853380
call->addAttribute(llvm::AttributeList::FunctionIndex,
@@ -3391,7 +3386,7 @@ Address irgen::emitTaskAlloc(IRGenFunction &IGF, llvm::Value *size,
33913386
void irgen::emitTaskDealloc(IRGenFunction &IGF, Address address,
33923387
llvm::Value *size) {
33933388
auto *call = IGF.Builder.CreateCall(
3394-
IGF.IGM.getTaskDeallocFn(), {getAsyncTask(IGF), address.getAddress()});
3389+
IGF.IGM.getTaskDeallocFn(), {IGF.getAsyncTask(), address.getAddress()});
33953390
call->setDoesNotThrow();
33963391
call->setCallingConv(IGF.IGM.SwiftCC);
33973392
call->addAttribute(llvm::AttributeList::FunctionIndex,

0 commit comments

Comments
 (0)