Skip to content

Commit 85c5648

Browse files
committed
Revert "Merge pull request #75150 from drexin/wip-130971168"
This reverts commit 8fca31e, reversing changes made to 32af2f6.
1 parent 9bebe11 commit 85c5648

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ void SignatureExpansion::expandResult(
653653
const TypeInfo *directResultTypeInfo;
654654
std::tie(ResultIRType, directResultTypeInfo) = expandDirectResult();
655655

656-
if (!fnConv.hasIndirectSILResults() && !fnConv.hasIndirectSILErrorResults()) {
656+
if (!fnConv.hasIndirectSILErrorResults()) {
657657
llvm::Type *directErrorType;
658658
const TypeInfo *directErrorTypeInfo;
659659
std::tie(directErrorType, directErrorTypeInfo) = expandDirectErrorType();
@@ -2043,8 +2043,7 @@ void SignatureExpansion::expandParameters(
20432043
auto &errorTI = IGM.getTypeInfo(errorType);
20442044
auto &nativeError = errorTI.nativeReturnValueSchema(IGM);
20452045

2046-
if (getSILFuncConventions().hasIndirectSILResults() ||
2047-
getSILFuncConventions().hasIndirectSILErrorResults() ||
2046+
if (getSILFuncConventions().hasIndirectSILErrorResults() ||
20482047
native.requiresIndirect() ||
20492048
nativeError.shouldReturnTypedErrorIndirectly()) {
20502049
ParamIRTypes.push_back(IGM.getStorageType(errorType)->getPointerTo());
@@ -2607,8 +2606,7 @@ class SyncCallEmission final : public CallEmission {
26072606
auto &errorSchema =
26082607
IGF.IGM.getTypeInfo(silErrorTy).nativeReturnValueSchema(IGF.IGM);
26092608

2610-
if (fnConv.hasIndirectSILResults() ||
2611-
nativeSchema.requiresIndirect() ||
2609+
if (nativeSchema.requiresIndirect() ||
26122610
errorSchema.shouldReturnTypedErrorIndirectly()) {
26132611
// Return the error indirectly.
26142612
auto buf = IGF.getCalleeTypedErrorResultSlot(silErrorTy);
@@ -4367,9 +4365,8 @@ bool CallEmission::mayReturnTypedErrorDirectly() const {
43674365
SILFunctionConventions fnConv(getCallee().getOrigFunctionType(),
43684366
IGF.getSILModule());
43694367
bool mayReturnErrorDirectly = false;
4370-
if (!convertDirectToIndirectReturn && !fnConv.hasIndirectSILResults() &&
4371-
!fnConv.hasIndirectSILErrorResults() && fnConv.funcTy->hasErrorResult() &&
4372-
fnConv.isTypedError()) {
4368+
if (!convertDirectToIndirectReturn && !fnConv.hasIndirectSILErrorResults() &&
4369+
fnConv.funcTy->hasErrorResult() && fnConv.isTypedError()) {
43734370
auto errorType =
43744371
fnConv.getSILErrorType(IGF.IGM.getMaximalTypeExpansionContext());
43754372
auto &errorSchema =

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,8 +2183,7 @@ static void emitEntryPointArgumentsNativeCC(IRGenSILFunction &IGF,
21832183
auto &errorTI = cast<FixedTypeInfo>(IGF.getTypeInfo(inContextErrorType));
21842184
auto &native = resultTI.nativeReturnValueSchema(IGF.IGM);
21852185
auto &nativeError = errorTI.nativeReturnValueSchema(IGF.IGM);
2186-
if (funcTy->isAsync() || fnConv.hasIndirectSILResults() ||
2187-
native.requiresIndirect() ||
2186+
if (funcTy->isAsync() || native.requiresIndirect() ||
21882187
nativeError.shouldReturnTypedErrorIndirectly()) {
21892188
IGF.setCallerTypedErrorResultSlot(
21902189
Address(emission->getCallerTypedErrorResultArgument(),
@@ -3926,8 +3925,7 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
39263925
auto &resultSchema = resultTI.nativeReturnValueSchema(IGM);
39273926
auto &errorSchema = errorTI.nativeReturnValueSchema(IGM);
39283927

3929-
if (isAsync() || substConv.hasIndirectSILResults() ||
3930-
substConv.hasIndirectSILErrorResults() ||
3928+
if (isAsync() || substConv.hasIndirectSILErrorResults() ||
39313929
resultSchema.requiresIndirect() ||
39323930
errorSchema.shouldReturnTypedErrorIndirectly()) {
39333931
Explosion errorValue;
@@ -4394,7 +4392,7 @@ static void emitReturnInst(IRGenSILFunction &IGF,
43944392
funcLang == SILFunctionLanguage::C && "Need to handle all cases");
43954393
SILType errorType;
43964394
if (fnType->hasErrorResult() && conv.isTypedError() &&
4397-
!conv.hasIndirectSILResults() && !conv.hasIndirectSILErrorResults()) {
4395+
!conv.hasIndirectSILErrorResults()) {
43984396
errorType =
43994397
conv.getSILErrorType(IGF.IGM.getMaximalTypeExpansionContext());
44004398
}
@@ -4449,8 +4447,7 @@ void IRGenSILFunction::visitThrowInst(swift::ThrowInst *i) {
44494447
auto &errorSchema = errorTI.nativeReturnValueSchema(IGM);
44504448

44514449
Builder.CreateStore(flag, getCallerErrorResultSlot());
4452-
if (conv.hasIndirectSILResults() || conv.hasIndirectSILErrorResults() ||
4453-
resultSchema.requiresIndirect() ||
4450+
if (resultSchema.requiresIndirect() ||
44544451
errorSchema.shouldReturnTypedErrorIndirectly()) {
44554452
errorTI.initialize(*this, errorResult, getCallerTypedErrorResultSlot(),
44564453
false);

test/IRGen/typed_throws.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,3 @@ func directErrorMergePtrAndInt(x: Bool, y: AnyObject) throws(SmallError) -> (Any
144144

145145
return try directErrorMergePtrAndInt(x: !x, y: y)
146146
}
147-
148-
// This used to crash at compile time, because it was trying to use a direct
149-
// error return in combination with an indirect result, which is illegal.
150-
func genericThrows<T>(x: Bool, y: T) throws(SmallError) -> T {
151-
guard x else {
152-
throw SmallError(x: 1)
153-
}
154-
155-
return y
156-
}

0 commit comments

Comments
 (0)