Skip to content

Commit 74093cd

Browse files
committed
Ensure we are lowering coroutine normal result using proper (callee) context.
1 parent 87e4d99 commit 74093cd

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
@@ -4762,19 +4762,23 @@ void IRGenSILFunction::visitEndApply(BeginApplyInst *i, EndApplyInst *ei) {
47624762
const auto &coroutine = getLoweredCoroutine(i->getTokenResult());
47634763
bool isAbort = ei == nullptr;
47644764

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

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

47724776
auto schemaAndEntity =
4773-
getCoroutineResumeFunctionPointerAuth(IGM, i->getOrigCalleeType());
4777+
getCoroutineResumeFunctionPointerAuth(IGM, origCalleeType);
47744778
auto pointerAuth = PointerAuthInfo::emit(*this, schemaAndEntity.first,
47754779
coroutine.Buffer.getAddress(),
47764780
schemaAndEntity.second);
4777-
auto callee = FunctionPointer::createSigned(i->getOrigCalleeType(),
4781+
auto callee = FunctionPointer::createSigned(origCalleeType,
47784782
continuation, pointerAuth, sig);
47794783

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

0 commit comments

Comments
 (0)