@@ -4419,48 +4419,6 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
44194419 getSILModule ());
44204420 assert (!conv.hasIndirectSILErrorResults ());
44214421
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-
44644422 if (!isAsync ()) {
44654423 auto fnTy = CurFn->getFunctionType ();
44664424 auto retTy = fnTy->getReturnType ();
@@ -4493,7 +4451,8 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
44934451 auto combined =
44944452 combineResultAndTypedErrorType (IGM, resultSchema, errorSchema);
44954453 Explosion nativeAgg;
4496- buildDirectError (combined, errorSchema, silErrorTy, errorResult,
4454+ buildDirectError (*this , combined, errorSchema, silErrorTy,
4455+ errorResult,
44974456 /* forAsync*/ false , nativeAgg);
44984457
44994458 emitScalarReturn (combined.combinedTy , nativeAgg);
@@ -4543,7 +4502,7 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
45434502 Explosion nativeAgg;
45444503 auto combined =
45454504 combineResultAndTypedErrorType (IGM, resultSchema, errorSchema);
4546- buildDirectError (combined, errorSchema, silErrorTy, exn,
4505+ buildDirectError (* this , combined, errorSchema, silErrorTy, exn,
45474506 /* forAsync*/ true , nativeAgg);
45484507 assert (exn.empty () && " Unclaimed typed error results" );
45494508
0 commit comments