Skip to content

Commit b7943bb

Browse files
authored
Merge pull request #80287 from drexin/wip-147872231
[IRGen] Map result to native representation in emitAsyncReturn
2 parents 98fc0a9 + 287e779 commit b7943bb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6683,10 +6683,12 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
66836683
if (combinedTy->isVoidTy()) {
66846684
assert(result.empty() && "Unexpected result values");
66856685
} else {
6686+
Explosion native = nativeSchema.mapIntoNative(
6687+
IGM, IGF, result, funcResultTypeInContext, /*isOutlined*/ false);
66866688
if (auto *structTy = dyn_cast<llvm::StructType>(combinedTy)) {
66876689
llvm::Value *nativeAgg = llvm::UndefValue::get(structTy);
6688-
for (unsigned i = 0, e = result.size(); i < e; ++i) {
6689-
llvm::Value *elt = result.claimNext();
6690+
for (unsigned i = 0, e = native.size(); i < e; ++i) {
6691+
llvm::Value *elt = native.claimNext();
66906692
auto *nativeTy = structTy->getElementType(i);
66916693
elt = convertForDirectError(IGF, elt, nativeTy,
66926694
/*forExtraction*/ false);
@@ -6697,9 +6699,9 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
66976699
while (!out.empty()) {
66986700
nativeResultsStorage.push_back(out.claimNext());
66996701
}
6700-
} else if (!result.empty()) {
6702+
} else if (!native.empty()) {
67016703
auto *converted = convertForDirectError(
6702-
IGF, result.claimNext(), combinedTy, /*forExtraction*/ false);
6704+
IGF, native.claimNext(), combinedTy, /*forExtraction*/ false);
67036705
nativeResultsStorage.push_back(converted);
67046706
} else {
67056707
nativeResultsStorage.push_back(llvm::UndefValue::get(combinedTy));

test/IRGen/typed_throws.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,13 @@ func callSmallErrorLargerResult() {
349349
}
350350
}
351351
}
352+
353+
struct SomeStruct {
354+
let x: Int
355+
let y: UInt32
356+
let z: UInt32
357+
}
358+
359+
func someFunc() async throws(SmallError) -> SomeStruct {
360+
SomeStruct(x: 42, y: 23, z: 25)
361+
}

0 commit comments

Comments
 (0)