@@ -4511,12 +4511,12 @@ void CallEmission::emitToUnmappedExplosionWithDirectTypedError(
4511
4511
for (unsigned i = 0 , e = structTy->getNumElements (); i < e; ++i) {
4512
4512
llvm::Value *elt = values[combined.errorValueMapping [i]];
4513
4513
auto *nativeTy = structTy->getElementType (i);
4514
- elt = convertForDirectError (IGF, elt, nativeTy, /* forExtraction*/ true );
4514
+ elt = convertForAsyncDirect (IGF, elt, nativeTy, /* forExtraction*/ true );
4515
4515
errorExplosion.add (elt);
4516
4516
}
4517
4517
} else {
4518
4518
auto *converted =
4519
- convertForDirectError (IGF, values[combined.errorValueMapping [0 ]],
4519
+ convertForAsyncDirect (IGF, values[combined.errorValueMapping [0 ]],
4520
4520
combined.combinedTy , /* forExtraction*/ true );
4521
4521
errorExplosion.add (converted);
4522
4522
}
@@ -4534,12 +4534,12 @@ void CallEmission::emitToUnmappedExplosionWithDirectTypedError(
4534
4534
dyn_cast<llvm::StructType>(nativeSchema.getExpandedType (IGF.IGM ))) {
4535
4535
for (unsigned i = 0 , e = structTy->getNumElements (); i < e; ++i) {
4536
4536
auto *nativeTy = structTy->getElementType (i);
4537
- auto *converted = convertForDirectError (IGF, values[i], nativeTy,
4537
+ auto *converted = convertForAsyncDirect (IGF, values[i], nativeTy,
4538
4538
/* forExtraction*/ true );
4539
4539
resultExplosion.add (converted);
4540
4540
}
4541
4541
} else {
4542
- auto *converted = convertForDirectError (
4542
+ auto *converted = convertForAsyncDirect (
4543
4543
IGF, values[0 ], combined.combinedTy , /* forExtraction*/ true );
4544
4544
resultExplosion.add (converted);
4545
4545
}
@@ -5407,7 +5407,7 @@ llvm::Value* IRGenFunction::coerceValue(llvm::Value *value, llvm::Type *toTy,
5407
5407
return loaded;
5408
5408
}
5409
5409
5410
- llvm::Value *irgen::convertForDirectError (IRGenFunction &IGF,
5410
+ llvm::Value *irgen::convertForAsyncDirect (IRGenFunction &IGF,
5411
5411
llvm::Value *value, llvm::Type *toTy,
5412
5412
bool forExtraction) {
5413
5413
auto &Builder = IGF.Builder ;
@@ -5417,9 +5417,12 @@ llvm::Value *irgen::convertForDirectError(IRGenFunction &IGF,
5417
5417
if (toTy->isPointerTy ()) {
5418
5418
if (fromTy->isPointerTy ())
5419
5419
return Builder.CreateBitCast (value, toTy);
5420
- return Builder.CreateIntToPtr (value, toTy);
5420
+ if (fromTy == IGF.IGM .IntPtrTy )
5421
+ return Builder.CreateIntToPtr (value, toTy);
5421
5422
} else if (fromTy->isPointerTy ()) {
5422
- return Builder.CreatePtrToInt (value, toTy);
5423
+ if (toTy == IGF.IGM .IntPtrTy ) {
5424
+ return Builder.CreatePtrToInt (value, toTy);
5425
+ }
5423
5426
}
5424
5427
5425
5428
if (forExtraction) {
@@ -5877,12 +5880,12 @@ void IRGenFunction::emitScalarReturn(SILType returnResultType,
5877
5880
for (unsigned i = 0 , e = native.size (); i != e; ++i) {
5878
5881
llvm::Value *elt = native.claimNext ();
5879
5882
auto *nativeTy = structTy->getElementType (i);
5880
- elt = convertForDirectError (*this , elt, nativeTy,
5883
+ elt = convertForAsyncDirect (*this , elt, nativeTy,
5881
5884
/* forExtraction*/ false );
5882
5885
nativeAgg = Builder.CreateInsertValue (nativeAgg, elt, i);
5883
5886
}
5884
5887
} else {
5885
- nativeAgg = convertForDirectError (*this , native.claimNext (), combinedTy,
5888
+ nativeAgg = convertForAsyncDirect (*this , native.claimNext (), combinedTy,
5886
5889
/* forExtraction*/ false );
5887
5890
}
5888
5891
}
@@ -6214,7 +6217,7 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
6214
6217
for (unsigned i = 0 , e = result.size (); i != e; ++i) {
6215
6218
llvm::Value *elt = result.claimNext ();
6216
6219
auto *nativeTy = structTy->getElementType (i);
6217
- elt = convertForDirectError (IGF, elt, nativeTy,
6220
+ elt = convertForAsyncDirect (IGF, elt, nativeTy,
6218
6221
/* forExtraction*/ false );
6219
6222
nativeAgg = IGF.Builder .CreateInsertValue (nativeAgg, elt, i);
6220
6223
}
@@ -6224,7 +6227,7 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
6224
6227
nativeResultsStorage.push_back (out.claimNext ());
6225
6228
}
6226
6229
} else {
6227
- auto *converted = convertForDirectError (
6230
+ auto *converted = convertForAsyncDirect (
6228
6231
IGF, result.claimNext (), combinedTy, /* forExtraction*/ false );
6229
6232
nativeResultsStorage.push_back (converted);
6230
6233
}
0 commit comments