Skip to content

Commit 291abb6

Browse files
committed
Revert "Merge pull request swiftlang#75677 from drexin/wip-133006541"
This reverts commit 739c719, reversing changes made to 7d1c505.
1 parent 66586a6 commit 291abb6

File tree

5 files changed

+20
-44
lines changed

5 files changed

+20
-44
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4511,12 +4511,12 @@ void CallEmission::emitToUnmappedExplosionWithDirectTypedError(
45114511
for (unsigned i = 0, e = structTy->getNumElements(); i < e; ++i) {
45124512
llvm::Value *elt = values[combined.errorValueMapping[i]];
45134513
auto *nativeTy = structTy->getElementType(i);
4514-
elt = convertForDirectError(IGF, elt, nativeTy, /*forExtraction*/ true);
4514+
elt = convertForAsyncDirect(IGF, elt, nativeTy, /*forExtraction*/ true);
45154515
errorExplosion.add(elt);
45164516
}
45174517
} else {
45184518
auto *converted =
4519-
convertForDirectError(IGF, values[combined.errorValueMapping[0]],
4519+
convertForAsyncDirect(IGF, values[combined.errorValueMapping[0]],
45204520
combined.combinedTy, /*forExtraction*/ true);
45214521
errorExplosion.add(converted);
45224522
}
@@ -4534,12 +4534,12 @@ void CallEmission::emitToUnmappedExplosionWithDirectTypedError(
45344534
dyn_cast<llvm::StructType>(nativeSchema.getExpandedType(IGF.IGM))) {
45354535
for (unsigned i = 0, e = structTy->getNumElements(); i < e; ++i) {
45364536
auto *nativeTy = structTy->getElementType(i);
4537-
auto *converted = convertForDirectError(IGF, values[i], nativeTy,
4537+
auto *converted = convertForAsyncDirect(IGF, values[i], nativeTy,
45384538
/*forExtraction*/ true);
45394539
resultExplosion.add(converted);
45404540
}
45414541
} else {
4542-
auto *converted = convertForDirectError(
4542+
auto *converted = convertForAsyncDirect(
45434543
IGF, values[0], combined.combinedTy, /*forExtraction*/ true);
45444544
resultExplosion.add(converted);
45454545
}
@@ -5407,7 +5407,7 @@ llvm::Value* IRGenFunction::coerceValue(llvm::Value *value, llvm::Type *toTy,
54075407
return loaded;
54085408
}
54095409

5410-
llvm::Value *irgen::convertForDirectError(IRGenFunction &IGF,
5410+
llvm::Value *irgen::convertForAsyncDirect(IRGenFunction &IGF,
54115411
llvm::Value *value, llvm::Type *toTy,
54125412
bool forExtraction) {
54135413
auto &Builder = IGF.Builder;
@@ -5417,9 +5417,12 @@ llvm::Value *irgen::convertForDirectError(IRGenFunction &IGF,
54175417
if (toTy->isPointerTy()) {
54185418
if (fromTy->isPointerTy())
54195419
return Builder.CreateBitCast(value, toTy);
5420-
return Builder.CreateIntToPtr(value, toTy);
5420+
if (fromTy == IGF.IGM.IntPtrTy)
5421+
return Builder.CreateIntToPtr(value, toTy);
54215422
} else if (fromTy->isPointerTy()) {
5422-
return Builder.CreatePtrToInt(value, toTy);
5423+
if (toTy == IGF.IGM.IntPtrTy) {
5424+
return Builder.CreatePtrToInt(value, toTy);
5425+
}
54235426
}
54245427

54255428
if (forExtraction) {
@@ -5877,12 +5880,12 @@ void IRGenFunction::emitScalarReturn(SILType returnResultType,
58775880
for (unsigned i = 0, e = native.size(); i != e; ++i) {
58785881
llvm::Value *elt = native.claimNext();
58795882
auto *nativeTy = structTy->getElementType(i);
5880-
elt = convertForDirectError(*this, elt, nativeTy,
5883+
elt = convertForAsyncDirect(*this, elt, nativeTy,
58815884
/*forExtraction*/ false);
58825885
nativeAgg = Builder.CreateInsertValue(nativeAgg, elt, i);
58835886
}
58845887
} else {
5885-
nativeAgg = convertForDirectError(*this, native.claimNext(), combinedTy,
5888+
nativeAgg = convertForAsyncDirect(*this, native.claimNext(), combinedTy,
58865889
/*forExtraction*/ false);
58875890
}
58885891
}
@@ -6214,7 +6217,7 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
62146217
for (unsigned i = 0, e = result.size(); i != e; ++i) {
62156218
llvm::Value *elt = result.claimNext();
62166219
auto *nativeTy = structTy->getElementType(i);
6217-
elt = convertForDirectError(IGF, elt, nativeTy,
6220+
elt = convertForAsyncDirect(IGF, elt, nativeTy,
62186221
/*forExtraction*/ false);
62196222
nativeAgg = IGF.Builder.CreateInsertValue(nativeAgg, elt, i);
62206223
}
@@ -6224,7 +6227,7 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
62246227
nativeResultsStorage.push_back(out.claimNext());
62256228
}
62266229
} else {
6227-
auto *converted = convertForDirectError(
6230+
auto *converted = convertForAsyncDirect(
62286231
IGF, result.claimNext(), combinedTy, /*forExtraction*/ false);
62296232
nativeResultsStorage.push_back(converted);
62306233
}

lib/IRGen/GenCall.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ namespace irgen {
274274
void forwardAsyncCallResult(IRGenFunction &IGF, CanSILFunctionType fnType,
275275
AsyncContextLayout &layout, llvm::CallInst *call);
276276

277-
/// Converts a value for direct error return.
278-
llvm::Value *convertForDirectError(IRGenFunction &IGF, llvm::Value *value,
277+
/// Converts a value for async direct errors.
278+
llvm::Value *convertForAsyncDirect(IRGenFunction &IGF, llvm::Value *value,
279279
llvm::Type *toTy, bool forExtraction);
280280

281281
} // end namespace irgen

lib/IRGen/GenThunk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,14 @@ void IRGenThunk::emit() {
384384
for (unsigned i : combined.errorValueMapping) {
385385
llvm::Value *elt = nativeError.claimNext();
386386
auto *nativeTy = structTy->getElementType(i);
387-
elt = convertForDirectError(IGF, elt, nativeTy,
387+
elt = convertForAsyncDirect(IGF, elt, nativeTy,
388388
/*forExtraction*/ false);
389389
expandedResult =
390390
IGF.Builder.CreateInsertValue(expandedResult, elt, i);
391391
}
392392
IGF.emitAllExtractValues(expandedResult, structTy, errorArgValues);
393393
} else if (!errorSchema.getExpandedType(IGM)->isVoidTy()) {
394-
errorArgValues = convertForDirectError(IGF, nativeError.claimNext(),
394+
errorArgValues = convertForAsyncDirect(IGF, nativeError.claimNext(),
395395
combined.combinedTy,
396396
/*forExtraction*/ false);
397397
}

lib/IRGen/IRGenSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,7 +4445,7 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
44454445
for (unsigned i : combined.errorValueMapping) {
44464446
llvm::Value *elt = nativeError.claimNext();
44474447
auto *nativeTy = structTy->getElementType(i);
4448-
elt = convertForDirectError(*this, elt, nativeTy,
4448+
elt = convertForAsyncDirect(*this, elt, nativeTy,
44494449
/*forExtraction*/ false);
44504450
expandedResult = Builder.CreateInsertValue(expandedResult, elt, i);
44514451
}
@@ -4456,7 +4456,7 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
44564456
}
44574457
} else if (!errorSchema.getExpandedType(IGM)->isVoidTy()) {
44584458
out =
4459-
convertForDirectError(*this, nativeError.claimNext(),
4459+
convertForAsyncDirect(*this, nativeError.claimNext(),
44604460
combined.combinedTy, /*forExtraction*/ false);
44614461
}
44624462
} else {

test/IRGen/typed_throws_32_bit.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)