@@ -330,10 +330,6 @@ AsyncContextLayout::AsyncContextLayout(
330
330
#endif
331
331
}
332
332
333
- static Size getAsyncContextSize (AsyncContextLayout layout) {
334
- return layout.getSize ();
335
- }
336
-
337
333
static Alignment getAsyncContextAlignment (IRGenModule &IGM) {
338
334
return IGM.getPointerAlignment ();
339
335
}
@@ -2240,7 +2236,6 @@ class AsyncCallEmission final : public CallEmission {
2240
2236
using super = CallEmission;
2241
2237
2242
2238
Address contextBuffer;
2243
- Size contextSize;
2244
2239
Address context;
2245
2240
llvm::Value *calleeFunction = nullptr ;
2246
2241
llvm::Value *currentResumeFn = nullptr ;
@@ -2285,8 +2280,7 @@ class AsyncCallEmission final : public CallEmission {
2285
2280
CurCallee.getFunctionPointer (), thickContext);
2286
2281
auto *dynamicContextSize =
2287
2282
IGF.Builder .CreateZExt (dynamicContextSize32, IGF.IGM .SizeTy );
2288
- std::tie (contextBuffer, contextSize) = emitAllocAsyncContext (
2289
- IGF, layout, dynamicContextSize, getAsyncContextSize (layout));
2283
+ contextBuffer = emitAllocAsyncContext (IGF, dynamicContextSize);
2290
2284
context = layout.emitCastTo (IGF, contextBuffer.getAddress ());
2291
2285
if (layout.canHaveError ()) {
2292
2286
auto fieldLayout = layout.getErrorLayout ();
@@ -2299,7 +2293,7 @@ class AsyncCallEmission final : public CallEmission {
2299
2293
void end () override {
2300
2294
assert (contextBuffer.isValid ());
2301
2295
assert (context.isValid ());
2302
- emitDeallocAsyncContext (IGF, contextBuffer, contextSize );
2296
+ emitDeallocAsyncContext (IGF, contextBuffer);
2303
2297
super::end ();
2304
2298
}
2305
2299
void setFromCallee () override {
@@ -3523,8 +3517,7 @@ void irgen::emitAsyncFunctionEntry(IRGenFunction &IGF,
3523
3517
auto &IGM = IGF.IGM ;
3524
3518
auto size = getAsyncContextLayout (IGM, asyncFunction).getSize ();
3525
3519
auto asyncFuncPointer = IGF.Builder .CreateBitOrPointerCast (
3526
- IGM.getAddrOfAsyncFunctionPointer (asyncFunction, NotForDefinition),
3527
- IGM.Int8PtrTy );
3520
+ IGM.getAddrOfAsyncFunctionPointer (asyncFunction), IGM.Int8PtrTy );
3528
3521
auto *id = IGF.Builder .CreateIntrinsicCall (
3529
3522
llvm::Intrinsic::coro_id_async,
3530
3523
{llvm::ConstantInt::get (IGM.Int32Ty , size.getValue ()),
@@ -3590,28 +3583,6 @@ void irgen::emitDeallocYieldManyCoroutineBuffer(IRGenFunction &IGF,
3590
3583
IGF.Builder .CreateLifetimeEnd (buffer, bufferSize);
3591
3584
}
3592
3585
3593
- Address irgen::emitTaskAlloc (IRGenFunction &IGF, llvm::Value *size,
3594
- Alignment alignment) {
3595
- auto *call = IGF.Builder .CreateCall (IGF.IGM .getTaskAllocFn (),
3596
- {IGF.getAsyncTask (), size});
3597
- call->setDoesNotThrow ();
3598
- call->setCallingConv (IGF.IGM .SwiftCC );
3599
- call->addAttribute (llvm::AttributeList::FunctionIndex,
3600
- llvm::Attribute::ReadNone);
3601
- auto address = Address (call, alignment);
3602
- return address;
3603
- }
3604
-
3605
- void irgen::emitTaskDealloc (IRGenFunction &IGF, Address address,
3606
- llvm::Value *size) {
3607
- auto *call = IGF.Builder .CreateCall (
3608
- IGF.IGM .getTaskDeallocFn (), {IGF.getAsyncTask (), address.getAddress ()});
3609
- call->setDoesNotThrow ();
3610
- call->setCallingConv (IGF.IGM .SwiftCC );
3611
- call->addAttribute (llvm::AttributeList::FunctionIndex,
3612
- llvm::Attribute::ReadNone);
3613
- }
3614
-
3615
3586
void irgen::emitTaskCancel (IRGenFunction &IGF, llvm::Value *task) {
3616
3587
if (task->getType () != IGF.IGM .SwiftTaskPtrTy ) {
3617
3588
task = IGF.Builder .CreateBitCast (task, IGF.IGM .SwiftTaskPtrTy );
@@ -3663,28 +3634,17 @@ llvm::Value *irgen::emitTaskCreate(
3663
3634
return result;
3664
3635
}
3665
3636
3666
- std::pair<Address, Size> irgen::emitAllocAsyncContext (IRGenFunction &IGF,
3667
- AsyncContextLayout layout,
3668
- llvm::Value *sizeValue,
3669
- Size sizeLowerBound) {
3637
+ Address irgen::emitAllocAsyncContext (IRGenFunction &IGF,
3638
+ llvm::Value *sizeValue) {
3670
3639
auto alignment = getAsyncContextAlignment (IGF.IGM );
3671
- auto address = emitTaskAlloc (IGF, sizeValue, alignment);
3672
- IGF.Builder .CreateLifetimeStart (address, sizeLowerBound);
3673
- return {address, sizeLowerBound};
3674
- }
3675
-
3676
- std::pair<Address, Size>
3677
- irgen::emitAllocAsyncContext (IRGenFunction &IGF, AsyncContextLayout layout) {
3678
- auto size = getAsyncContextSize (layout);
3679
- auto *sizeValue = llvm::ConstantInt::get (IGF.IGM .SizeTy , size.getValue ());
3680
- return emitAllocAsyncContext (IGF, layout, sizeValue, size);
3640
+ auto address = IGF.emitTaskAlloc (sizeValue, alignment);
3641
+ IGF.Builder .CreateLifetimeStart (address, Size (-1 ) /* dynamic size*/ );
3642
+ return address;
3681
3643
}
3682
3644
3683
- void irgen::emitDeallocAsyncContext (IRGenFunction &IGF, Address context,
3684
- Size size) {
3685
- auto *sizeValue = llvm::ConstantInt::get (IGF.IGM .SizeTy , size.getValue ());
3686
- emitTaskDealloc (IGF, context, sizeValue);
3687
- IGF.Builder .CreateLifetimeEnd (context, size);
3645
+ void irgen::emitDeallocAsyncContext (IRGenFunction &IGF, Address context) {
3646
+ IGF.emitTaskDealloc (context);
3647
+ IGF.Builder .CreateLifetimeEnd (context, Size (-1 ) /* dynamic size*/ );
3688
3648
}
3689
3649
3690
3650
llvm::Value *irgen::emitYield (IRGenFunction &IGF,
0 commit comments