Skip to content

Commit 9bddd08

Browse files
committed
[CoroutineAccessor] Remove old ABI support.
This was useful during bringup. Now that retcon.once.dynamic coroutine splitting is available, it's no longer needed.
1 parent 375bc35 commit 9bddd08

File tree

8 files changed

+43
-110
lines changed

8 files changed

+43
-110
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,6 @@ class IRGenOptions {
502502
// Whether to emit typed malloc during coroutine frame allocation.
503503
unsigned EmitTypeMallocForCoroFrame : 1;
504504

505-
// Whether to use the yield_once ABI when emitting yield_once_2 coroutines.
506-
unsigned EmitYieldOnce2AsYieldOnce : 1;
507-
508505
// Whether to force emission of a frame for all async functions
509506
// (LLVM's 'frame-pointer=all').
510507
unsigned AsyncFramePointerAll : 1;
@@ -621,9 +618,9 @@ class IRGenOptions {
621618
ColocateTypeDescriptors(true), UseRelativeProtocolWitnessTables(false),
622619
UseFragileResilientProtocolWitnesses(false), EnableHotColdSplit(false),
623620
EmitAsyncFramePushPopMetadata(true), EmitTypeMallocForCoroFrame(false),
624-
EmitYieldOnce2AsYieldOnce(true), AsyncFramePointerAll(false),
625-
UseProfilingMarkerThunks(false), UseCoroCCX8664(false),
626-
UseCoroCCArm64(false), DebugInfoForProfiling(false), CmdArgs(),
621+
AsyncFramePointerAll(false), UseProfilingMarkerThunks(false),
622+
UseCoroCCX8664(false), UseCoroCCArm64(false),
623+
DebugInfoForProfiling(false), CmdArgs(),
627624
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
628625
TypeInfoFilter(TypeInfoDumpFilter::All),
629626
PlatformCCallingConvention(llvm::CallingConv::C), UseCASBackend(false),

include/swift/Basic/Features.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CoroutineAccessors, true)
476476
/// modify/read single-yield coroutines always execute code post-yield code
477477
EXPERIMENTAL_FEATURE(CoroutineAccessorsUnwindOnCallerError, false)
478478

479-
/// modify/read coroutines use the callee-allocated ABI
480-
EXPERIMENTAL_FEATURE(CoroutineAccessorsAllocateInCallee, false)
481-
482479
/// When a parameter has unspecified isolation, infer it as main actor isolated.
483480
EXPERIMENTAL_FEATURE(GenerateForceToMainActorThunks, false)
484481

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ UNINTERESTING_FEATURE(SafeInteropWrappers)
392392
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)
393393
UNINTERESTING_FEATURE(ImportNonPublicCxxMembers)
394394
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
395-
UNINTERESTING_FEATURE(CoroutineAccessorsAllocateInCallee)
396395

397396
bool swift::usesFeatureIsolatedDeinit(const Decl *decl) {
398397
if (auto cd = dyn_cast<ClassDecl>(decl)) {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,12 +3674,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
36743674
Args.hasFlag(OPT_enable_fragile_resilient_protocol_witnesses,
36753675
OPT_disable_fragile_resilient_protocol_witnesses,
36763676
Opts.UseFragileResilientProtocolWitnesses);
3677-
Opts.UseProfilingMarkerThunks =
3678-
Args.hasFlag(OPT_enable_profiling_marker_thunks,
3679-
OPT_disable_profiling_marker_thunks,
3680-
Opts.UseProfilingMarkerThunks);
3681-
Opts.EmitYieldOnce2AsYieldOnce =
3682-
!LangOpts.hasFeature(Feature::CoroutineAccessorsAllocateInCallee);
3677+
Opts.UseProfilingMarkerThunks = Args.hasFlag(
3678+
OPT_enable_profiling_marker_thunks, OPT_disable_profiling_marker_thunks,
3679+
Opts.UseProfilingMarkerThunks);
36833680
Opts.EnableHotColdSplit =
36843681
Args.hasFlag(OPT_enable_split_cold_code,
36853682
OPT_disable_split_cold_code,

lib/IRGen/GenCall.cpp

Lines changed: 22 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ static std::optional<Size> getCoroutineContextSize(IRGenModule &IGM,
8787
case SILCoroutineKind::None:
8888
llvm_unreachable("expand a coroutine");
8989
case SILCoroutineKind::YieldOnce2:
90-
if (!IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce)
91-
return std::nullopt;
92-
LLVM_FALLTHROUGH;
90+
return std::nullopt;
9391
case SILCoroutineKind::YieldOnce:
9492
return getYieldOnceCoroutineBufferSize(IGM);
9593
case SILCoroutineKind::YieldMany:
@@ -387,7 +385,7 @@ irgen::expandCallingConv(IRGenModule &IGM,
387385
case SILFunctionTypeRepresentation::KeyPathAccessorSetter:
388386
case SILFunctionTypeRepresentation::KeyPathAccessorEquals:
389387
case SILFunctionTypeRepresentation::KeyPathAccessorHash:
390-
if (isCalleeAllocatedCoro && !IGM.getOptions().EmitYieldOnce2AsYieldOnce)
388+
if (isCalleeAllocatedCoro)
391389
return IGM.SwiftCoroCC;
392390
if (isAsync)
393391
return IGM.SwiftAsyncCC;
@@ -578,7 +576,7 @@ namespace {
578576

579577
/// Expand the components of the continuation entrypoint of the
580578
/// function type.
581-
void expandCoroutineContinuationType(bool emitYieldOnce2AsYieldOnce);
579+
void expandCoroutineContinuationType();
582580

583581
// Expand the components for the async continuation entrypoint of the
584582
// function type (the function to be called on returning).
@@ -646,7 +644,7 @@ namespace {
646644
void expandExternalSignatureTypes();
647645

648646
void expandCoroutineResult(bool forContinuation);
649-
void expandCoroutineContinuationParameters(bool emitYieldOnce2AsYieldOnce);
647+
void expandCoroutineContinuationParameters();
650648

651649
void addIndirectThrowingResult();
652650
llvm::Type *getErrorRegisterType();
@@ -886,12 +884,11 @@ void SignatureExpansion::expandCoroutineResult(bool forContinuation) {
886884
: llvm::StructType::get(IGM.getLLVMContext(), components);
887885
}
888886

889-
void SignatureExpansion::expandCoroutineContinuationParameters(
890-
bool emitYieldOnce2AsYieldOnce) {
887+
void SignatureExpansion::expandCoroutineContinuationParameters() {
891888
// The coroutine context.
892889
addCoroutineContextParameter();
893890

894-
if (FnType->isCalleeAllocatedCoroutine() && !emitYieldOnce2AsYieldOnce) {
891+
if (FnType->isCalleeAllocatedCoroutine()) {
895892
// Whether this is an unwind resumption.
896893
ParamIRTypes.push_back(IGM.CoroAllocatorPtrTy);
897894
} else {
@@ -1950,12 +1947,10 @@ void SignatureExpansion::expandParameters(
19501947
case SILCoroutineKind::None:
19511948
break;
19521949
case SILCoroutineKind::YieldOnce2:
1953-
if (!IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
1954-
addCoroutineContextParameter();
1955-
addCoroutineAllocatorParameter();
1956-
break;
1957-
}
1958-
LLVM_FALLTHROUGH;
1950+
addCoroutineContextParameter();
1951+
addCoroutineAllocatorParameter();
1952+
1953+
break;
19591954
case SILCoroutineKind::YieldOnce:
19601955
case SILCoroutineKind::YieldMany:
19611956
addCoroutineContextParameter();
@@ -2121,10 +2116,9 @@ void SignatureExpansion::expandFunctionType(
21212116
llvm_unreachable("bad abstract calling convention");
21222117
}
21232118

2124-
void SignatureExpansion::expandCoroutineContinuationType(
2125-
bool emitYieldOnce2AsYieldOnce) {
2119+
void SignatureExpansion::expandCoroutineContinuationType() {
21262120
expandCoroutineResult(/*for continuation*/ true);
2127-
expandCoroutineContinuationParameters(emitYieldOnce2AsYieldOnce);
2121+
expandCoroutineContinuationParameters();
21282122
}
21292123

21302124
llvm::Type *SignatureExpansion::getErrorRegisterType() {
@@ -2457,8 +2451,7 @@ Signature Signature::forCoroutineContinuation(IRGenModule &IGM,
24572451
CanSILFunctionType fnType) {
24582452
assert(fnType->isCoroutine());
24592453
SignatureExpansion expansion(IGM, fnType, FunctionPointerKind(fnType));
2460-
expansion.expandCoroutineContinuationType(
2461-
IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce);
2454+
expansion.expandCoroutineContinuationType();
24622455
return expansion.getSignature();
24632456
}
24642457

@@ -2768,15 +2761,15 @@ class SyncCallEmission final : public CallEmission {
27682761
assert(!coroStaticFrame.isValid());
27692762
assert(!coroAllocator);
27702763

2771-
if (IsCalleeAllocatedCoroutine &&
2772-
!IGF.IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
2764+
if (IsCalleeAllocatedCoroutine) {
27732765
llvm::Value *bufferSize32;
27742766
std::tie(calleeFunction, bufferSize32) =
27752767
getCoroFunctionAndSize(IGF, CurCallee.getFunctionPointer());
27762768
auto *bufferSize = IGF.Builder.CreateZExt(bufferSize32, IGF.IGM.SizeTy);
27772769
coroStaticFrame = emitAllocYieldOnce2CoroutineFrame(IGF, bufferSize);
2778-
// TODO: Optimize allocator kind (e.g. async callers only need to use the
2779-
// TaskAllocator if the coroutine is suspended across an await).
2770+
// TODO: CoroutineAccessors: Optimize allocator kind (e.g. async callers
2771+
// only need to use the TaskAllocator if the
2772+
// coroutine is suspended across an await).
27802773
coroAllocator = emitYieldOnce2CoroutineAllocator(
27812774
IGF, IGF.getDefaultCoroutineAllocatorKind());
27822775
}
@@ -2878,11 +2871,8 @@ class SyncCallEmission final : public CallEmission {
28782871
switch (origCalleeType->getCoroutineKind()) {
28792872
case SILCoroutineKind::YieldOnce2:
28802873
// Pass along the coroutine buffer and allocator.
2881-
if (!IGF.IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
2882-
original.transferInto(adjusted, 2);
2883-
break;
2884-
}
2885-
LLVM_FALLTHROUGH;
2874+
original.transferInto(adjusted, 2);
2875+
break;
28862876
case SILCoroutineKind::YieldOnce:
28872877
case SILCoroutineKind::YieldMany:
28882878
// Pass along the coroutine buffer.
@@ -4974,10 +4964,8 @@ irgen::getCoroutineResumeFunctionPointerAuth(IRGenModule &IGM,
49744964
return { IGM.getOptions().PointerAuth.YieldManyResumeFunctions,
49754965
PointerAuthEntity::forYieldTypes(fnType) };
49764966
case SILCoroutineKind::YieldOnce2:
4977-
if (!IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce)
4978-
return {IGM.getOptions().PointerAuth.YieldOnce2ResumeFunctions,
4979-
PointerAuthEntity::forYieldTypes(fnType)};
4980-
LLVM_FALLTHROUGH;
4967+
return {IGM.getOptions().PointerAuth.YieldOnce2ResumeFunctions,
4968+
PointerAuthEntity::forYieldTypes(fnType)};
49814969
case SILCoroutineKind::YieldOnce:
49824970
return { IGM.getOptions().PointerAuth.YieldOnceResumeFunctions,
49834971
PointerAuthEntity::forYieldTypes(fnType) };
@@ -5233,10 +5221,6 @@ void irgen::emitDeallocYieldManyCoroutineBuffer(IRGenFunction &IGF,
52335221

52345222
void irgen::emitDeallocYieldOnce2CoroutineFrame(IRGenFunction &IGF,
52355223
StackAddress frame) {
5236-
if (IGF.IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
5237-
assert(!frame.isValid());
5238-
return;
5239-
}
52405224
assert(frame.isValid());
52415225
emitDeallocCoroStaticFrame(IGF, frame);
52425226
}
@@ -5352,8 +5336,7 @@ llvm::Value *irgen::emitYield(IRGenFunction &IGF,
53525336

53535337
// Perform the yield.
53545338
llvm::Value *isUnwind = nullptr;
5355-
if (coroutineType->isCalleeAllocatedCoroutine() &&
5356-
!IGF.IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
5339+
if (coroutineType->isCalleeAllocatedCoroutine()) {
53575340
IGF.Builder.CreateIntrinsicCall(llvm::Intrinsic::coro_suspend_retcon,
53585341
{IGF.IGM.CoroAllocatorPtrTy}, yieldArgs);
53595342
isUnwind = llvm::ConstantInt::get(IGF.IGM.Int1Ty, 0);

lib/IRGen/IRGenSIL.cpp

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,12 +2144,9 @@ static void emitEntryPointArgumentsNativeCC(IRGenSILFunction &IGF,
21442144
case SILCoroutineKind::None:
21452145
break;
21462146
case SILCoroutineKind::YieldOnce2:
2147-
if (!IGF.IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
2148-
emitYieldOnce2CoroutineEntry(
2149-
IGF, LinkEntity::forSILFunction(IGF.CurSILFn), funcTy, *emission);
2150-
break;
2151-
}
2152-
LLVM_FALLTHROUGH;
2147+
emitYieldOnce2CoroutineEntry(IGF, LinkEntity::forSILFunction(IGF.CurSILFn),
2148+
funcTy, *emission);
2149+
break;
21532150
case SILCoroutineKind::YieldOnce:
21542151
emitYieldOnceCoroutineEntry(IGF, funcTy, *emission);
21552152
break;
@@ -2617,8 +2614,7 @@ void IRGenSILFunction::emitSILFunction() {
26172614
if (isAsyncFn) {
26182615
IGM.noteSwiftAsyncFunctionDef();
26192616
}
2620-
if (funcTy->isCalleeAllocatedCoroutine() &&
2621-
!IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
2617+
if (funcTy->isCalleeAllocatedCoroutine()) {
26222618
emitCoroFunctionPointer(IGM, CurFn, LinkEntity::forSILFunction(CurSILFn));
26232619
}
26242620

@@ -3885,19 +3881,15 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
38853881
case SILCoroutineKind::None:
38863882
break;
38873883

3888-
case SILCoroutineKind::YieldOnce2:
3889-
if (!IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
3890-
assert(calleeFP.getKind().isCoroFunctionPointer());
3891-
auto frame = emission->getCoroStaticFrame();
3892-
auto *allocator = emission->getCoroAllocator();
3893-
llArgs.add(frame.getAddress().getAddress());
3894-
llArgs.add(allocator);
3895-
coroImpl = {CoroutineState::CalleeAllocated{frame, allocator}};
3896-
3897-
break;
3898-
}
3899-
LLVM_FALLTHROUGH;
3900-
3884+
case SILCoroutineKind::YieldOnce2: {
3885+
assert(calleeFP.getKind().isCoroFunctionPointer());
3886+
auto frame = emission->getCoroStaticFrame();
3887+
auto *allocator = emission->getCoroAllocator();
3888+
llArgs.add(frame.getAddress().getAddress());
3889+
llArgs.add(allocator);
3890+
coroImpl = {CoroutineState::CalleeAllocated{frame, allocator}};
3891+
break;
3892+
}
39013893
case SILCoroutineKind::YieldOnce:
39023894
coroutineBuffer = emitAllocYieldOnceCoroutineBuffer(*this);
39033895
coroImpl = {CoroutineState::HeapAllocated{*coroutineBuffer}};
@@ -6592,10 +6584,6 @@ void IRGenSILFunction::visitDeallocStackInst(swift::DeallocStackInst *i) {
65926584
return;
65936585
}
65946586
if (isaResultOf<BeginApplyInst>(i->getOperand())) {
6595-
if (IGM.IRGen.Opts.EmitYieldOnce2AsYieldOnce) {
6596-
// This is a no-op when using the classic retcon.once lowering.
6597-
return;
6598-
}
65996587
auto *mvi = getAsResultOf<BeginApplyInst>(i->getOperand());
66006588
auto *bai = cast<BeginApplyInst>(mvi->getParent());
66016589
const auto &coroutine = getLoweredCoroutine(bai->getTokenResult());

test/IRGen/coroutine_accessors.swift

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
// RUN: %target-swift-emit-irgen \
2-
// RUN: %s \
3-
// RUN: -enable-experimental-feature CoroutineAccessors \
4-
// RUN: -enable-library-evolution \
5-
// RUN: | %IRGenFileCheck %s --check-prefix=CHECK-OLD
6-
71
// RUN: %target-swift-emit-irgen \
82
// RUN: %s \
93
// RUN: -enable-experimental-feature CoroutineAccessors \
10-
// RUN: -enable-experimental-feature CoroutineAccessorsAllocateInCallee \
11-
// RUN: | %IRGenFileCheck %s --check-prefix=CHECK-NEW
4+
// RUN: | %IRGenFileCheck %s
125

136
// REQUIRES: swift_feature_CoroutineAccessors
14-
// REQUIRES: swift_feature_CoroutineAccessorsAllocateInCallee
15-
167

178
@frozen
189
public struct S {
@@ -21,36 +12,18 @@ public var _i: Int = 0
2112

2213
public var irm: Int {
2314
// CHECK-LABEL: define{{.*}} { ptr, {{i64|i32}} } @"$s19coroutine_accessors1SV3irmSivy"(
24-
// CHECK-OLD-SAME: ptr noalias dereferenceable({{32|16}}) %0,
25-
// CHECK-OLD-SAME: ptr %1,
26-
// CHECK-OLD-SAME: [[INT]] %2
2715
// CHECK-SAME: )
2816
// CHECK-SAME: {
2917
// CHECK: }
3018
read {
3119
yield _i
3220
}
3321
// CHECK-LABEL: define{{.*}} { ptr, ptr } @"$s19coroutine_accessors1SV3irmSivx"(
34-
// CHECK-OLD-SAME: ptr noalias dereferenceable({{32|16}}) %0,
35-
// CHECK-OLD-SAME: ptr nocapture swiftself dereferenceable({{16|8}}) %1
3622
// CHECK-SAME: )
3723
// CHECK-SAME: {
38-
// CHECK-OLD: }
24+
// CHECK: }
3925
modify {
4026
yield &_i
4127
}
42-
// CHECK-OLD-LABEL: define{{.*}} { ptr, {{i64|i32}} } @"$s19coroutine_accessors1SV3irmSivr"(
43-
// CHECK-OLD-SAME: ptr noalias dereferenceable({{32|16}}) %0,
44-
// CHECK-OLD-SAME: ptr %1,
45-
// CHECK-OLD-SAME: [[INT]] %2
46-
// CHECK-OLD-SAME: )
47-
// CHECK-OLD-SAME: {
48-
// CHECK-OLD: }
49-
// CHECK-OLD-LABEL: define{{.*}} void @"$s19coroutine_accessors1SV3irmSivs"(
50-
// CHECK-OLD-SAME: [[INT]] %0,
51-
// CHECK-OLD-SAME: ptr nocapture swiftself dereferenceable({{16|8}}) %1
52-
// CHECK-OLD-SAME: )
53-
// CHECK-OLD-SAME: {
54-
// CHECK-OLD: }
5528
} // public var irm
5629
}

test/IRGen/run-coroutine_accessors.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// RUN: -parse-as-library \
77
// RUN: -module-name main \
88
// RUN: -enable-experimental-feature CoroutineAccessors \
9-
// RUN: -enable-experimental-feature CoroutineAccessorsAllocateInCallee \
109
// RUN: -o %t/main
1110
// RUN: %target-codesign %t/main
1211
// RUN: %target-run %t/main | %FileCheck %s

0 commit comments

Comments
 (0)