Skip to content

Commit 7b2fecc

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,15 +4786,19 @@ void IRGenSILFunction::visitEndApply(BeginApplyInst *i, EndApplyInst *ei) {
47864786
const auto &coroutine = getLoweredCoroutine(i->getTokenResult());
47874787
bool isAbort = ei == nullptr;
47884788

4789-
auto sig = Signature::forCoroutineContinuation(IGM, i->getOrigCalleeType());
4789+
// Lower the return value in the callee's generic context.
4790+
auto origCalleeType = i->getOrigCalleeType();
4791+
GenericContextScope scope(IGM, origCalleeType->getInvocationGenericSignature());
4792+
4793+
auto sig = Signature::forCoroutineContinuation(IGM, origCalleeType);
47904794

47914795
// Cast the continuation pointer to the right function pointer type.
47924796
auto continuation = coroutine.Continuation;
47934797
continuation = Builder.CreateBitCast(continuation,
47944798
sig.getType()->getPointerTo());
47954799

47964800
auto schemaAndEntity =
4797-
getCoroutineResumeFunctionPointerAuth(IGM, i->getOrigCalleeType());
4801+
getCoroutineResumeFunctionPointerAuth(IGM, origCalleeType);
47984802
auto pointerAuth = PointerAuthInfo::emit(*this, schemaAndEntity.first,
47994803
coroutine.getBuffer().getAddress(),
48004804
schemaAndEntity.second);

0 commit comments

Comments
 (0)