Skip to content

Commit e48ceef

Browse files
committed
Correctly handle normal coroutine results while synthesizing coroutine continuation.
1 parent 7b2fecc commit e48ceef

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4989,7 +4989,9 @@ static void emitRetconCoroutineEntry(
49894989
ArrayRef<llvm::Value *> extraArguments, llvm::Constant *allocFn,
49904990
llvm::Constant *deallocFn, ArrayRef<llvm::Value *> finalArguments) {
49914991
auto prototype =
4992-
IGF.IGM.getOpaquePtr(IGF.IGM.getAddrOfContinuationPrototype(fnType));
4992+
IGF.IGM.getOpaquePtr(
4993+
IGF.IGM.getAddrOfContinuationPrototype(fnType,
4994+
fnType->getInvocationGenericSignature()));
49934995
// Call the right 'llvm.coro.id.retcon' variant.
49944996
SmallVector<llvm::Value *, 8> arguments;
49954997
arguments.push_back(

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6269,13 +6269,14 @@ IRGenModule::getAddrOfDefaultAssociatedConformanceAccessor(
62696269
}
62706270

62716271
llvm::Function *
6272-
IRGenModule::getAddrOfContinuationPrototype(CanSILFunctionType fnType) {
6272+
IRGenModule::getAddrOfContinuationPrototype(CanSILFunctionType fnType,
6273+
CanGenericSignature sig) {
62736274
LinkEntity entity = LinkEntity::forCoroutineContinuationPrototype(fnType);
62746275

62756276
llvm::Function *&entry = GlobalFuncs[entity];
62766277
if (entry) return entry;
62776278

6278-
GenericContextScope scope(*this, fnType->getInvocationGenericSignature());
6279+
GenericContextScope scope(*this, sig);
62796280
auto signature = Signature::forCoroutineContinuation(*this, fnType);
62806281
LinkInfo link = LinkInfo::get(*this, entity, NotForDefinition);
62816282
entry = createFunction(*this, link, signature);

lib/IRGen/GenFunc.cpp

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

14611462

14621463
// Use free as our allocator.

lib/IRGen/IRGenModule.h

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

18661866
void emitDynamicReplacementOriginalFunctionThunk(SILFunction *f);
18671867

1868-
llvm::Function *getAddrOfContinuationPrototype(CanSILFunctionType fnType);
1868+
llvm::Function *getAddrOfContinuationPrototype(CanSILFunctionType fnType,
1869+
CanGenericSignature sig);
18691870
Address getAddrOfSILGlobalVariable(SILGlobalVariable *var,
18701871
const TypeInfo &ti,
18711872
ForDefinition_t forDefinition);

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,16 +4827,15 @@ void IRGenSILFunction::visitEndApply(BeginApplyInst *i, EndApplyInst *ei) {
48274827

48284828
if (!isAbort) {
48294829
auto resultType = call->getType();
4830+
Explosion e;
48304831
if (!resultType->isVoidTy()) {
4831-
Explosion e;
48324832
// FIXME: Do we need to handle ABI-related conversions here?
48334833
// It seems we cannot have C function convention for coroutines, etc.
48344834
extractScalarResults(*this, resultType, call, e);
4835-
4836-
// NOTE: This inserts a new entry into the LoweredValues DenseMap,
4837-
// invalidating the reference held by `coroutine`.
4838-
setLoweredExplosion(ei, e);
48394835
}
4836+
// NOTE: This inserts a new entry into the LoweredValues DenseMap,
4837+
// invalidating the reference held by `coroutine`.
4838+
setLoweredExplosion(ei, e);
48404839
}
48414840
}
48424841

0 commit comments

Comments
 (0)