Skip to content

[SILGen] Use opaque AP for ObjC-async returns. #42485

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 1 commit into from
Apr 20, 2022
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
2 changes: 1 addition & 1 deletion lib/SIL/IR/SILInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2839,7 +2839,7 @@ SILType GetAsyncContinuationInstBase::getLoweredResumeType() const {
auto formalType = getFormalResumeType();
auto &M = getFunction()->getModule();
auto c = getFunction()->getTypeExpansionContext();
return M.Types.getLoweredType(AbstractionPattern(formalType), formalType, c);
return M.Types.getLoweredType(AbstractionPattern::getOpaque(), formalType, c);
}

ReturnInst::ReturnInst(SILFunction &func, SILDebugLocation debugLoc,
Expand Down
19 changes: 8 additions & 11 deletions lib/SILGen/ResultPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,8 @@ class ForeignAsyncInitializationPlan final : public ResultPlan {
{
// Allocate space to receive the resume value when the continuation is
// resumed.
opaqueResumeType =
SGF.getLoweredType(AbstractionPattern(calleeTypeInfo.substResultType),
calleeTypeInfo.substResultType);
opaqueResumeType = SGF.getLoweredType(AbstractionPattern::getOpaque(),
calleeTypeInfo.substResultType);
resumeBuf = SGF.emitTemporaryAllocation(loc, opaqueResumeType);
}

Expand Down Expand Up @@ -707,14 +706,12 @@ class ForeignAsyncInitializationPlan final : public ResultPlan {
// The incoming value is the maximally-abstracted result type of the
// continuation. Move it out of the resume buffer and reabstract it if
// necessary.
auto resumeResult = SGF.emitLoad(loc, resumeBuf,
calleeTypeInfo.origResultType
? *calleeTypeInfo.origResultType
: AbstractionPattern(calleeTypeInfo.substResultType),
calleeTypeInfo.substResultType,
SGF.getTypeLowering(calleeTypeInfo.substResultType),
SGFContext(), IsTake);

auto resumeResult =
SGF.emitLoad(loc, resumeBuf, AbstractionPattern::getOpaque(),
calleeTypeInfo.substResultType,
SGF.getTypeLowering(calleeTypeInfo.substResultType),
SGFContext(), IsTake);

return RValue(SGF, loc, calleeTypeInfo.substResultType, resumeResult);
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// RUN: %target-swift-frontend %s -emit-silgen -disable-availability-checking -import-objc-header %S/Inputs/rdar79383990.h
// REQUIRES: objc_interop
// REQUIRES: OS=macosx

import Foundation

Expand Down
2 changes: 0 additions & 2 deletions validation-test/compiler_crashers_2_fixed/rdar81590807.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

// REQUIRES: executable_test
// REQUIRES: OS=macosx || OS=ios
// Enable with rdar://85526879
// UNSUPPORTED: CPU=arm64e

// rdar://82123254
// UNSUPPORTED: use_os_stdlib
Expand Down
2 changes: 0 additions & 2 deletions validation-test/compiler_crashers_2_fixed/rdar81617749.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

// Enable with rdar://81617749
// UNSUPPORTED: CPU=i386 && OS=watchos
// Enable with rdar://85526916
// UNSUPPORTED: CPU=arm64e

// rdar://82123254
// UNSUPPORTED: use_os_stdlib
Expand Down