Skip to content

Commit 4a9d021

Browse files
committed
Correctly handle normal coroutine results while synthesizing coroutine continuation.
1 parent 74093cd commit 4a9d021

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4830,7 +4830,9 @@ emitRetconCoroutineEntry(IRGenFunction &IGF, CanSILFunctionType fnType,
48304830
llvm::Intrinsic::ID idIntrinsic, Size bufferSize,
48314831
Alignment bufferAlignment) {
48324832
auto prototype =
4833-
IGF.IGM.getOpaquePtr(IGF.IGM.getAddrOfContinuationPrototype(fnType));
4833+
IGF.IGM.getOpaquePtr(
4834+
IGF.IGM.getAddrOfContinuationPrototype(fnType,
4835+
fnType->getInvocationGenericSignature()));
48344836

48354837
// Use malloc and free as our allocator.
48364838
auto allocFn = IGF.IGM.getOpaquePtr(IGF.IGM.getMallocFn());

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6187,13 +6187,14 @@ IRGenModule::getAddrOfDefaultAssociatedConformanceAccessor(
61876187
}
61886188

61896189
llvm::Function *
6190-
IRGenModule::getAddrOfContinuationPrototype(CanSILFunctionType fnType) {
6190+
IRGenModule::getAddrOfContinuationPrototype(CanSILFunctionType fnType,
6191+
CanGenericSignature sig) {
61916192
LinkEntity entity = LinkEntity::forCoroutineContinuationPrototype(fnType);
61926193

61936194
llvm::Function *&entry = GlobalFuncs[entity];
61946195
if (entry) return entry;
61956196

6196-
GenericContextScope scope(*this, fnType->getInvocationGenericSignature());
6197+
GenericContextScope scope(*this, sig);
61976198
auto signature = Signature::forCoroutineContinuation(*this, fnType);
61986199
LinkInfo link = LinkInfo::get(*this, entity, NotForDefinition);
61996200
entry = createFunction(*this, link, signature);

lib/IRGen/GenFunc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,8 @@ class CoroPartialApplicationForwarderEmission
14571457
auto prototype = subIGF.IGM.getOpaquePtr(
14581458
subIGF.IGM.getAddrOfContinuationPrototype(
14591459
cast<SILFunctionType>(
1460-
unsubstType->mapTypeOutOfContext()->getCanonicalType())));
1460+
unsubstType->mapTypeOutOfContext()->getCanonicalType()),
1461+
origType->getInvocationGenericSignature()));
14611462

14621463
// Use malloc and free as our allocator.
14631464
auto allocFn = subIGF.IGM.getOpaquePtr(subIGF.IGM.getMallocFn());

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,7 +1834,8 @@ private: \
18341834

18351835
void emitDynamicReplacementOriginalFunctionThunk(SILFunction *f);
18361836

1837-
llvm::Function *getAddrOfContinuationPrototype(CanSILFunctionType fnType);
1837+
llvm::Function *getAddrOfContinuationPrototype(CanSILFunctionType fnType,
1838+
CanGenericSignature sig);
18381839
Address getAddrOfSILGlobalVariable(SILGlobalVariable *var,
18391840
const TypeInfo &ti,
18401841
ForDefinition_t forDefinition);

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4788,13 +4788,13 @@ void IRGenSILFunction::visitEndApply(BeginApplyInst *i, EndApplyInst *ei) {
47884788

47894789
if (!isAbort) {
47904790
auto resultType = call->getType();
4791+
Explosion e;
47914792
if (!resultType->isVoidTy()) {
4792-
Explosion e;
47934793
// FIXME: Do we need to handle ABI-related conversions here?
47944794
// It seems we cannot have C function convention for coroutines, etc.
47954795
extractScalarResults(*this, resultType, call, e);
4796-
setLoweredExplosion(ei, e);
47974796
}
4797+
setLoweredExplosion(ei, e);
47984798
}
47994799

48004800
coroutine.Temporaries.destroyAll(*this);

0 commit comments

Comments
 (0)