Skip to content

Commit b9d8f0e

Browse files
committed
Ensure we are lowering coroutine normal result using proper (callee) context.
1 parent 7cef5be commit b9d8f0e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,19 +4765,23 @@ void IRGenSILFunction::visitEndApply(BeginApplyInst *i, EndApplyInst *ei) {
47654765
const auto &coroutine = getLoweredCoroutine(i->getTokenResult());
47664766
bool isAbort = ei == nullptr;
47674767

4768-
auto sig = Signature::forCoroutineContinuation(IGM, i->getOrigCalleeType());
4768+
// Lower the return value in the callee's generic context.
4769+
auto origCalleeType = i->getOrigCalleeType();
4770+
GenericContextScope scope(IGM, origCalleeType->getInvocationGenericSignature());
4771+
4772+
auto sig = Signature::forCoroutineContinuation(IGM, origCalleeType);
47694773

47704774
// Cast the continuation pointer to the right function pointer type.
47714775
auto continuation = coroutine.Continuation;
47724776
continuation = Builder.CreateBitCast(continuation,
47734777
sig.getType()->getPointerTo());
47744778

47754779
auto schemaAndEntity =
4776-
getCoroutineResumeFunctionPointerAuth(IGM, i->getOrigCalleeType());
4780+
getCoroutineResumeFunctionPointerAuth(IGM, origCalleeType);
47774781
auto pointerAuth = PointerAuthInfo::emit(*this, schemaAndEntity.first,
47784782
coroutine.Buffer.getAddress(),
47794783
schemaAndEntity.second);
4780-
auto callee = FunctionPointer::createSigned(i->getOrigCalleeType(),
4784+
auto callee = FunctionPointer::createSigned(origCalleeType,
47814785
continuation, pointerAuth, sig);
47824786

47834787
auto *call = Builder.CreateCall(callee, {

0 commit comments

Comments
 (0)