mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CoroutineAccessors] Control ABI via flag.
This commit is contained in:
@@ -338,6 +338,10 @@ public:
|
||||
// Whether to allow merging traps and cond_fails.
|
||||
bool MergeableTraps = false;
|
||||
|
||||
/// Whether the @yield_once_2 convention is used by accessors added with the
|
||||
/// CoroutineAccessors feature (i.e. read2/modify2).
|
||||
bool CoroutineAccessorsUseYieldOnce2 = false;
|
||||
|
||||
SILOptions() {}
|
||||
|
||||
/// Return a hash code of any components from these options that should
|
||||
|
||||
@@ -1175,6 +1175,12 @@ def enable_arm64_corocc : Flag<["-"], "enable-arm64-corocc">,
|
||||
def disable_arm64_corocc : Flag<["-"], "disable-arm64-corocc">,
|
||||
HelpText<"Don't use swiftcorocc for yield_once_2 routines on arm64 variants.">;
|
||||
|
||||
def enable_callee_allocated_coro_abi : Flag<["-"], "enable-callee-allocated-coro-abi">,
|
||||
HelpText<"Override per-platform settings and use yield_once_2.">;
|
||||
|
||||
def disable_callee_allocated_coro_abi : Flag<["-"], "disable-callee-allocated-coro-abi">,
|
||||
HelpText<"Override per-platform settings and don't use yield_once_2.">;
|
||||
|
||||
def enable_cond_fail_message_annotation : Flag<["-"], "enable-cond-fail-message-annotation">,
|
||||
HelpText<"Enable cond_fail message annotation. Will serialize a .o.yaml file per .o file.">;
|
||||
|
||||
|
||||
@@ -597,6 +597,16 @@ struct SILOptOptions {
|
||||
"enable-address-dependencies",
|
||||
llvm::cl::desc("Enable enforcement of lifetime dependencies on addressable values."));
|
||||
|
||||
llvm::cl::opt<bool> EnableCalleeAllocatedCoroAbi = llvm::cl::opt<bool>(
|
||||
"enable-callee-allocated-coro-abi",
|
||||
llvm::cl::desc("Override per-platform settings and use yield_once_2."),
|
||||
llvm::cl::init(false));
|
||||
llvm::cl::opt<bool> DisableCalleeAllocatedCoroAbi = llvm::cl::opt<bool>(
|
||||
"disable-callee-allocated-coro-abi",
|
||||
llvm::cl::desc(
|
||||
"Override per-platform settings and don't use yield_once_2."),
|
||||
llvm::cl::init(false));
|
||||
|
||||
llvm::cl::opt<bool> MergeableTraps = llvm::cl::opt<bool>(
|
||||
"mergeable-traps",
|
||||
llvm::cl::desc("Enable cond_fail merging."));
|
||||
@@ -918,6 +928,10 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
|
||||
options.EnablePackMetadataStackPromotion;
|
||||
|
||||
SILOpts.EnableAddressDependencies = options.EnableAddressDependencies;
|
||||
if (options.EnableCalleeAllocatedCoroAbi)
|
||||
SILOpts.CoroutineAccessorsUseYieldOnce2 = true;
|
||||
if (options.DisableCalleeAllocatedCoroAbi)
|
||||
SILOpts.CoroutineAccessorsUseYieldOnce2 = false;
|
||||
SILOpts.MergeableTraps = options.MergeableTraps;
|
||||
|
||||
if (options.OptModeFlag == OptimizationMode::NotSet) {
|
||||
|
||||
@@ -3130,6 +3130,16 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
Opts.EnableAddressDependencies = Args.hasFlag(
|
||||
OPT_enable_address_dependencies, OPT_disable_address_dependencies,
|
||||
Opts.EnableAddressDependencies);
|
||||
|
||||
if (LangOpts.Target.isOSDarwin() || LangOpts.Target.isOSLinux()) {
|
||||
// On Darwin and Linux, use yield_once_2 by default.
|
||||
Opts.CoroutineAccessorsUseYieldOnce2 = true;
|
||||
}
|
||||
Opts.CoroutineAccessorsUseYieldOnce2 =
|
||||
Args.hasFlag(OPT_enable_callee_allocated_coro_abi,
|
||||
OPT_disable_callee_allocated_coro_abi,
|
||||
Opts.CoroutineAccessorsUseYieldOnce2);
|
||||
|
||||
Opts.MergeableTraps = Args.hasArg(OPT_mergeable_traps);
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1855,5 +1855,8 @@ bool SILDeclRef::isCalleeAllocatedCoroutine() const {
|
||||
if (!accessor)
|
||||
return false;
|
||||
|
||||
return requiresFeatureCoroutineAccessors(accessor->getAccessorKind());
|
||||
if (!requiresFeatureCoroutineAccessors(accessor->getAccessorKind()))
|
||||
return false;
|
||||
|
||||
return getASTContext().SILOpts.CoroutineAccessorsUseYieldOnce2;
|
||||
}
|
||||
|
||||
@@ -2481,8 +2481,10 @@ static CanSILFunctionType getSILFunctionType(
|
||||
|
||||
if (auto accessor = getAsCoroutineAccessor(constant)) {
|
||||
auto origAccessor = cast<AccessorDecl>(origConstant->getDecl());
|
||||
auto &ctx = origAccessor->getASTContext();
|
||||
coroutineKind =
|
||||
requiresFeatureCoroutineAccessors(accessor->getAccessorKind())
|
||||
(requiresFeatureCoroutineAccessors(accessor->getAccessorKind()) &&
|
||||
ctx.SILOpts.CoroutineAccessorsUseYieldOnce2)
|
||||
? SILCoroutineKind::YieldOnce2
|
||||
: SILCoroutineKind::YieldOnce;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-emit-irgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: | %IRGenFileCheck %s
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-emit-irgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -module-name backdep \
|
||||
// RUN: -target %target-swift-5.6-abi-triple \
|
||||
// RUN: -Onone \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-emit-irgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -module-name backdep \
|
||||
// RUN: -target %target-swift-5.7-abi-triple \
|
||||
// RUN: -Onone \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// RUN: %target-swift-emit-irgen \
|
||||
// RUN: %s \
|
||||
// RUN: -Onone \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: -enable-arm64-corocc \
|
||||
// RUN: -enable-x86_64-corocc \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-frontend \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -module-name Library \
|
||||
// RUN: -emit-ir \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
|
||||
@@ -94,8 +94,6 @@
|
||||
// UNSUPPORTED: wasm
|
||||
// UNSUPPORTED: OS=wasi
|
||||
// UNSUPPORTED: CPU=wasm32
|
||||
// TODO: CoroutineAccessors: Enable on Windows.
|
||||
// UNSUPPORTED: OS=windows-msvc
|
||||
|
||||
// REQUIRES: swift_feature_CoroutineAccessors
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// RUN: %target-swift-frontend \
|
||||
// RUN: %t/Library.swift \
|
||||
// RUN: %t/LibImpl.underscored.swift \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -emit-module \
|
||||
// RUN: -module-name Library \
|
||||
// RUN: -parse-as-library \
|
||||
@@ -13,6 +14,7 @@
|
||||
|
||||
// RUN: %target-swift-frontend \
|
||||
// RUN: %t/Executable.swift \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -c \
|
||||
// RUN: -parse-as-library \
|
||||
// RUN: -module-name Executable \
|
||||
@@ -22,6 +24,7 @@
|
||||
// RUN: %target-build-swift-dylib(%t/%target-library-name(Library)) \
|
||||
// RUN: %t/Library.swift \
|
||||
// RUN: %t/LibImpl.nonunderscored.swift \
|
||||
// RUN: -Xfrontend -enable-callee-allocated-coro-abi \
|
||||
// RUN: -emit-module \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: | %FileCheck %s --check-prefixes=CHECK,CHECK-NOUNWIND
|
||||
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessorsUnwindOnCallerError \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-emit-silgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -experimental-skip-non-inlinable-function-bodies \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
@@ -7,6 +8,7 @@
|
||||
|
||||
// RUN: %target-swift-emit-silgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -experimental-skip-non-inlinable-function-bodies \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-swift-emit-silgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature BuiltinModule \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
@@ -7,6 +8,7 @@
|
||||
|
||||
// RUN: %target-swift-emit-silgen \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-experimental-feature BuiltinModule \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: | %FileCheck %s --check-prefix=CHECK-FRAGILE
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: | %FileCheck %s --check-prefixes=CHECK,CHECK-NORMAL,CHECK-%target-abi-stability
|
||||
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types \
|
||||
// RUN: %s \
|
||||
// RUN: -enable-callee-allocated-coro-abi \
|
||||
// RUN: -enable-library-evolution \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessorsUnwindOnCallerError \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-sil-opt \
|
||||
// RUN: -devirtualizer \
|
||||
// RUN: -enable-callee-allocated-coro-abi\
|
||||
// RUN: %s \
|
||||
// RUN: -enable-sil-verify-all \
|
||||
// RUN: -enable-experimental-feature CoroutineAccessors \
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// RUN: %target-build-swift-dylib(%t/%target-library-name(thing)) \
|
||||
// RUN: %s \
|
||||
// RUN: -Xfrontend -enable-callee-allocated-coro-abi \
|
||||
// RUN: -emit-tbd \
|
||||
// RUN: -Xfrontend -validate-tbd-against-ir=all \
|
||||
// RUN: -enable-library-evolution \
|
||||
|
||||
Reference in New Issue
Block a user