@@ -405,6 +405,44 @@ void IRGenThunk::emit() {
405
405
}
406
406
errorArgValues.add (errorValue);
407
407
emitAsyncReturn (IGF, *asyncLayout, origTy, errorArgValues.claimAll ());
408
+
409
+ IGF.Builder .emitBlock (successBB);
410
+
411
+ Explosion resultArgValues;
412
+ if (result.empty ()) {
413
+ if (!combined.combinedTy ->isVoidTy ()) {
414
+ if (auto *structTy =
415
+ dyn_cast<llvm::StructType>(combined.combinedTy )) {
416
+ IGF.emitAllExtractValues (llvm::UndefValue::get (structTy), structTy,
417
+ resultArgValues);
418
+ } else {
419
+ resultArgValues = llvm::UndefValue::get (combined.combinedTy );
420
+ }
421
+ }
422
+ } else {
423
+ if (auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy )) {
424
+ llvm::Value *expandedResult =
425
+ llvm::UndefValue::get (combined.combinedTy );
426
+ for (size_t i = 0 , count = result.size (); i < count; i++) {
427
+ llvm::Value *elt = result.claimNext ();
428
+ auto *nativeTy = structTy->getElementType (i);
429
+ elt = convertForDirectError (IGF, elt, nativeTy,
430
+ /* forExtraction*/ false );
431
+ expandedResult =
432
+ IGF.Builder .CreateInsertValue (expandedResult, elt, i);
433
+ }
434
+ IGF.emitAllExtractValues (expandedResult, structTy, resultArgValues);
435
+ } else {
436
+ resultArgValues = convertForDirectError (IGF, result.claimNext (),
437
+ combined.combinedTy ,
438
+ /* forExtraction*/ false );
439
+ }
440
+ }
441
+
442
+ resultArgValues.add (errorValue);
443
+ emitAsyncReturn (IGF, *asyncLayout, origTy, resultArgValues.claimAll ());
444
+
445
+ return ;
408
446
} else {
409
447
if (!error->empty ()) {
410
448
// Map the direct error explosion from the call back to the native
@@ -426,8 +464,8 @@ void IRGenThunk::emit() {
426
464
llvm::UndefValue::get (IGF.CurFn ->getReturnType ()));
427
465
}
428
466
}
467
+ IGF.Builder .emitBlock (successBB);
429
468
}
430
- IGF.Builder .emitBlock (successBB);
431
469
} else {
432
470
if (isAsync) {
433
471
Explosion error;
0 commit comments