Skip to content

Commit 017bede

Browse files
committed
[Async CC] Never map returns to native explosions.
Previously, when lowering the entry point of an async function, the returned values were lowered to explosions that matched those of sync functions, namely native explosions. That is incorrect for async functions where the structured values are within the async context. Here, that error is fixed, by loading the values returned from the call out of the async context passed in. rdar://problem/71641793
1 parent 110dff5 commit 017bede

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,28 +2390,12 @@ class AsyncCallEmission final : public CallEmission {
23902390
}
23912391
}
23922392
void emitCallToUnmappedExplosion(llvm::CallInst *call, Explosion &out) override {
2393-
SILFunctionConventions fnConv(getCallee().getSubstFunctionType(),
2394-
IGF.getSILModule());
2395-
auto resultType =
2396-
fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext());
2397-
auto &nativeSchema =
2398-
IGF.IGM.getTypeInfo(resultType).nativeReturnValueSchema(IGF.IGM);
2399-
auto expectedNativeResultType = nativeSchema.getExpandedType(IGF.IGM);
2400-
if (expectedNativeResultType->isVoidTy()) {
2401-
// If the async return is void, there is no return to move out of the
2402-
// argument buffer.
2403-
return;
2404-
}
2405-
// Gather the values.
2406-
Explosion nativeExplosion;
24072393
auto layout = getAsyncContextLayout();
24082394
for (unsigned index = 0, count = layout.getDirectReturnCount();
24092395
index < count; ++index) {
24102396
auto fieldLayout = layout.getDirectReturnLayout(index);
2411-
loadValue(fieldLayout, nativeExplosion);
2397+
loadValue(fieldLayout, out);
24122398
}
2413-
2414-
out = nativeSchema.mapFromNative(IGF.IGM, IGF, nativeExplosion, resultType);
24152399
}
24162400
Address getCalleeErrorSlot(SILType errorType) override {
24172401
auto layout = getAsyncContextLayout();

0 commit comments

Comments
 (0)