@@ -535,18 +535,21 @@ Value *coro::Shape::emitAlloc(IRBuilder<> &Builder, Value *Size,
535535  case  coro::ABI::RetconOnce:
536536  case  coro::ABI::RetconOnceDynamic: {
537537    unsigned  sizeParamIndex = 0 ;
538-     SmallVector<Value *, 2 > Args;
539-     if  (ABI == coro::ABI::RetconOnceDynamic) {
540-       sizeParamIndex = 1 ;
541-       Args.push_back (RetconLowering.Allocator );
542-     }
543538    Function *Alloc = nullptr ;
544539    if  (isa_and_nonnull<CoroAllocaAllocFrameInst>(AI)) {
545540      assert (ABI == coro::ABI::RetconOnceDynamic);
546541      Alloc = RetconLowering.AllocFrame ;
547542    } else  {
548543      Alloc = RetconLowering.Alloc ;
549544    }
545+     SmallVector<Value *, 2 > Args;
546+     if  (ABI == coro::ABI::RetconOnceDynamic) {
547+       Args.push_back (RetconLowering.Allocator );
548+       Args.push_back (RetconLowering.Storage );
549+       sizeParamIndex = 2 ;
550+     } else  {
551+       Alloc = RetconLowering.Alloc ;
552+     }
550553    Size = Builder.CreateIntCast (
551554        Size, Alloc->getFunctionType ()->getParamType (sizeParamIndex),
552555        /* is signed*/ false );
@@ -583,11 +586,14 @@ void coro::Shape::emitDealloc(IRBuilder<> &Builder, Value *Ptr,
583586    } else  {
584587      Dealloc = RetconLowering.Dealloc ;
585588    }
586-     SmallVector<Value *, 2 > Args;
587589    unsigned  allocationParamIndex = 0 ;
590+     SmallVector<Value *, 2 > Args;
588591    if  (ABI == coro::ABI::RetconOnceDynamic) {
589-       allocationParamIndex = 1 ;
592+       allocationParamIndex = 2 ;
590593      Args.push_back (RetconLowering.Allocator );
594+       Args.push_back (RetconLowering.Storage );
595+     } else  {
596+       Dealloc = RetconLowering.Dealloc ;
591597    }
592598    Ptr = Builder.CreateBitCast (
593599        Ptr, Dealloc->getFunctionType ()->getParamType (allocationParamIndex));
0 commit comments