@@ -4419,48 +4419,6 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
4419
4419
getSILModule ());
4420
4420
assert (!conv.hasIndirectSILErrorResults ());
4421
4421
4422
- auto buildDirectError = [=](const CombinedResultAndErrorType &combined,
4423
- const NativeConventionSchema &errorSchema,
4424
- SILType silErrorTy, Explosion &errorResult,
4425
- bool forAsync, Explosion &out) {
4426
- if (combined.combinedTy ->isVoidTy ()) {
4427
- return ;
4428
- }
4429
-
4430
- llvm::Value *expandedResult = llvm::UndefValue::get (combined.combinedTy );
4431
- auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy );
4432
-
4433
- if (!errorSchema.getExpandedType (IGM)->isVoidTy ()) {
4434
- auto nativeError =
4435
- errorSchema.mapIntoNative (IGM, *this , errorResult, silErrorTy, false );
4436
-
4437
- if (structTy) {
4438
- for (unsigned i : combined.errorValueMapping ) {
4439
- llvm::Value *elt = nativeError.claimNext ();
4440
- auto *nativeTy = structTy->getElementType (i);
4441
- elt = convertForDirectError (*this , elt, nativeTy,
4442
- /* forExtraction*/ false );
4443
- expandedResult = Builder.CreateInsertValue (expandedResult, elt, i);
4444
- }
4445
- if (forAsync) {
4446
- emitAllExtractValues (expandedResult, structTy, out);
4447
- } else {
4448
- out = expandedResult;
4449
- }
4450
- } else if (!errorSchema.getExpandedType (IGM)->isVoidTy ()) {
4451
- out =
4452
- convertForDirectError (*this , nativeError.claimNext (),
4453
- combined.combinedTy , /* forExtraction*/ false );
4454
- }
4455
- } else {
4456
- if (forAsync && structTy) {
4457
- emitAllExtractValues (expandedResult, structTy, out);
4458
- } else {
4459
- out = expandedResult;
4460
- }
4461
- }
4462
- };
4463
-
4464
4422
if (!isAsync ()) {
4465
4423
auto fnTy = CurFn->getFunctionType ();
4466
4424
auto retTy = fnTy->getReturnType ();
@@ -4493,7 +4451,8 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
4493
4451
auto combined =
4494
4452
combineResultAndTypedErrorType (IGM, resultSchema, errorSchema);
4495
4453
Explosion nativeAgg;
4496
- buildDirectError (combined, errorSchema, silErrorTy, errorResult,
4454
+ buildDirectError (*this , combined, errorSchema, silErrorTy,
4455
+ errorResult,
4497
4456
/* forAsync*/ false , nativeAgg);
4498
4457
4499
4458
emitScalarReturn (combined.combinedTy , nativeAgg);
@@ -4543,7 +4502,7 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
4543
4502
Explosion nativeAgg;
4544
4503
auto combined =
4545
4504
combineResultAndTypedErrorType (IGM, resultSchema, errorSchema);
4546
- buildDirectError (combined, errorSchema, silErrorTy, exn,
4505
+ buildDirectError (* this , combined, errorSchema, silErrorTy, exn,
4547
4506
/* forAsync*/ true , nativeAgg);
4548
4507
assert (exn.empty () && " Unclaimed typed error results" );
4549
4508
0 commit comments