Skip to content

Commit e6605bc

Browse files
committed
Revert "[SILGen] Add support thunk support for () -> T to () -> Void conversions"
This reverts commit 87b109f.
1 parent 38aeaf4 commit e6605bc

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,6 @@ class ResultPlanner {
15651565
///
15661566
/// Valid: reabstraction info, InnerResult, OuterResult.
15671567
ReabstractDirectToDirect,
1568-
1569-
/// Ignore the next direct inner result, since the outer is 'Void'.
1570-
IgnoreDirectResult,
15711568
};
15721569

15731570
Operation(Kind kind) : TheKind(kind) {}
@@ -1712,24 +1709,6 @@ class ResultPlanner {
17121709
SILResultInfo outerResult,
17131710
SILValue optOuterResultAddr);
17141711

1715-
void planIgnoredResult(AbstractionPattern innerOrigType,
1716-
CanType innerSubstType, PlanData &planData) {
1717-
if (innerOrigType.isTuple()) {
1718-
auto innerSubstTuple = cast<TupleType>(innerSubstType);
1719-
for (unsigned i = 0, n = innerSubstTuple->getNumElements(); i != n; ++i)
1720-
planIgnoredResult(innerOrigType.getTupleElementType(i),
1721-
innerSubstTuple.getElementType(i), planData);
1722-
return;
1723-
}
1724-
1725-
auto innerResult = claimNextInnerResult(planData);
1726-
if (innerResult.isFormalIndirect() &&
1727-
SGF.silConv.isSILIndirect(innerResult))
1728-
(void)addInnerIndirectResultTemporary(planData, innerResult);
1729-
else
1730-
addIgnoreDirectResult();
1731-
}
1732-
17331712
/// Claim the next inner result from the plan data.
17341713
SILResultInfo claimNextInnerResult(PlanData &data) {
17351714
return claimNext(data.InnerResults);
@@ -1879,10 +1858,6 @@ class ResultPlanner {
18791858
op.OuterOrigType = outerOrigType;
18801859
op.OuterSubstType = outerSubstType;
18811860
}
1882-
1883-
void addIgnoreDirectResult() {
1884-
(void)addOperation(Operation::IgnoreDirectResult);
1885-
}
18861861
};
18871862

18881863
} // end anonymous namespace
@@ -1893,13 +1868,6 @@ void ResultPlanner::plan(AbstractionPattern innerOrigType,
18931868
AbstractionPattern outerOrigType,
18941869
CanType outerSubstType,
18951870
PlanData &planData) {
1896-
// Conversion from `() -> T` to `() -> Void` is allowed when
1897-
// the argument is a closure.
1898-
if (!innerSubstType->isVoid() && outerSubstType->isVoid()) {
1899-
planIgnoredResult(innerOrigType, innerSubstType, planData);
1900-
return;
1901-
}
1902-
19031871
// The substituted types must match up in tuple-ness and arity.
19041872
assert(isa<TupleType>(innerSubstType) == isa<TupleType>(outerSubstType) ||
19051873
(isa<TupleType>(innerSubstType) &&
@@ -2612,10 +2580,6 @@ void ResultPlanner::execute(ArrayRef<SILValue> innerDirectResults,
26122580
case Operation::InjectOptionalIndirect:
26132581
SGF.B.createInjectEnumAddr(Loc, op.OuterResultAddr, op.SomeDecl);
26142582
continue;
2615-
2616-
case Operation::IgnoreDirectResult:
2617-
(void)claimNext(innerDirectResults);
2618-
continue;
26192583
}
26202584
llvm_unreachable("bad operation kind");
26212585
}

test/IRGen/objc_retainAutoreleasedReturnValue.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ public func test(_ dict: NSDictionary) {
2424
// popq %rbp ;<== Blocks the handshake from objc_autoreleaseReturnValue
2525
// jmp 0x01ec20 ; symbol stub for: objc_retainAutoreleasedReturnValue
2626

27-
// CHECK-LABEL: define {{.*}}swiftcc %TSo12NSEnumeratorC* @"$S34objc_retainAutoreleasedReturnValue4testyySo12NSDictionaryCFSo12NSEnumeratorCADcfU_"(%TSo12NSDictionaryC*)
27+
// CHECK-LABEL: define {{.*}}swiftcc void @"$S34objc_retainAutoreleasedReturnValue4testyySo12NSDictionaryCFyADcfU_"(%TSo12NSDictionaryC*)
2828
// CHECK: entry:
2929
// CHECK: call {{.*}}@objc_msgSend
3030
// CHECK: notail call i8* @objc_retainAutoreleasedReturnValue
31-
// CHECK: ret %TSo12NSEnumeratorC*
31+
// CHECK: ret void
3232

33-
// CHECK-LABEL: define {{.*}}swiftcc void @"$SSo12NSDictionaryCSo12NSEnumeratorCIgxo_ABIgx_TR"(%TSo12NSDictionaryC*, i8*, %swift.refcounted*)
34-
35-
// OPT-LABEL: define {{.*}}swiftcc void @"$S34objc_retainAutoreleasedReturnValue10useClosureyySo12NSDictionaryC_yADctF06$SSo12h43CSo12NSEnumeratorCIgxo_ABIgx_TR049$S34objc_bcD41Value4testyySo12a6CFSo12B7CADcfU_Tf3npf_nTf1nc_nTf4g_n"(%TSo12NSDictionaryC*)
33+
// OPT-LABEL: define {{.*}}swiftcc void @"$S34objc_retainAutoreleasedReturnValue4testyySo12NSDictionaryCFyADcfU_"(%TSo12NSDictionaryC*)
3634
// OPT: entry:
3735
// OPT: call {{.*}}@objc_msgSend
3836
// OPT: notail call i8* @objc_retainAutoreleasedReturnValue

0 commit comments

Comments
 (0)