Skip to content

[OpaqueValues] Map-into-context back-deploy thunk results. #62857

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/SILGen/SILGenBackDeploy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ static void emitBackDeployForwardApplyAndReturnOrThrow(

// Emit error block.
SGF.B.emitBlock(errorBB);
SILValue error = errorBB->createPhiArgument(fnConv.getSILErrorType(TEC),
OwnershipKind::Owned);
SILValue error = errorBB->createPhiArgument(
SGF.F.mapTypeIntoContext(fnConv.getSILErrorType(TEC)),
OwnershipKind::Owned);
SGF.B.createBranch(loc, SGF.ThrowDest.getBlock(), {error});

// Emit normal block.
SGF.B.emitBlock(normalBB);
SILValue result = normalBB->createPhiArgument(fnConv.getSILResultType(TEC),
OwnershipKind::Owned);
SILValue result = normalBB->createPhiArgument(
SGF.F.mapTypeIntoContext(fnConv.getSILResultType(TEC)),
OwnershipKind::Owned);
SmallVector<SILValue, 4> directResults;
extractAllElements(result, loc, SGF.B, directResults);

Expand Down
9 changes: 9 additions & 0 deletions test/SILGen/opaque_values_silgen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -636,3 +636,12 @@ func takeKeyPathString<T>(_ kp: KeyPath<T, String>) {
func giveKeyPathString() {
takeKeyPathString(\StructWithAReadableStringProperty.s)
}

// CHECK-LABEL: sil {{.*}}@$s20opaque_values_silgen29backDeployingReturningGenericyxxKlFTwb : {{.*}} <T> {{.*}} {
// Ensure that there aren't any "normal" (in the sense of try_apply) blocks that
// take unbound generic parameters (τ_0_0).
// CHECK-NOT: {{bb[0-9]+}}({{%[^,]+}} : @owned $τ_0_0):
// CHECK-LABEL: } // end sil function '$s20opaque_values_silgen29backDeployingReturningGenericyxxKlFTwb'
@available(SwiftStdlib 5.1, *)
@_backDeploy(before: SwiftStdlib 5.8)
public func backDeployingReturningGeneric<T>(_ t: T) throws -> T { t }