mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[moveOnly] Add a frontend flag -enable-experimental-move-only to control usage of move only features.
These include _move and @_noImplicitCopy. I still need to wire up the parsing of those behind this feature. The reason that I am adding this now is that I am going to now need to make some changes behind a feature flag and I have not yet needed to add one. The specific reason I needed to add one here is to ensure that I properly guard inside _move the call to Builtin.move so as to prevent a "cond_fail" incident. P.S.: This work depends on experimental lexical lifetimes being enabled as well, so I did that at the same time in this PR.
This commit is contained in:
@@ -320,6 +320,9 @@ namespace swift {
|
||||
/// Enable experimental 'distributed' actors and functions.
|
||||
bool EnableExperimentalDistributed = false;
|
||||
|
||||
/// Enable experimental 'move only' features.
|
||||
bool EnableExperimentalMoveOnly = false;
|
||||
|
||||
/// Disable the implicit import of the _Concurrency module.
|
||||
bool DisableImplicitConcurrencyModuleImport =
|
||||
!SWIFT_IMPLICIT_CONCURRENCY_IMPORT;
|
||||
|
||||
@@ -259,6 +259,10 @@ def enable_experimental_lexical_lifetimes :
|
||||
Flag<["-"], "enable-experimental-lexical-lifetimes">,
|
||||
HelpText<"Enable experimental lexical lifetimes">;
|
||||
|
||||
def enable_experimental_move_only :
|
||||
Flag<["-"], "enable-experimental-move-only">,
|
||||
HelpText<"Enable experimental move only">;
|
||||
|
||||
def enable_experimental_distributed :
|
||||
Flag<["-"], "enable-experimental-distributed">,
|
||||
HelpText<"Enable experimental 'distributed' actors and functions">;
|
||||
|
||||
@@ -443,6 +443,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.EnableExperimentalDistributed |=
|
||||
Args.hasArg(OPT_enable_experimental_distributed);
|
||||
|
||||
Opts.EnableExperimentalMoveOnly |=
|
||||
Args.hasArg(OPT_enable_experimental_move_only);
|
||||
|
||||
Opts.EnableInferPublicSendable |=
|
||||
Args.hasFlag(OPT_enable_infer_public_concurrent_value,
|
||||
OPT_disable_infer_public_concurrent_value,
|
||||
@@ -1399,6 +1402,11 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
|
||||
Opts.EnableExperimentalLexicalLifetimes |=
|
||||
Args.hasArg(OPT_enable_experimental_lexical_lifetimes);
|
||||
// If experimental move only is enabled, always enable lexical lifetime as
|
||||
// well. Move only depends on lexical lifetimes.
|
||||
Opts.EnableExperimentalLexicalLifetimes |=
|
||||
Args.hasArg(OPT_enable_experimental_move_only);
|
||||
|
||||
Opts.EnableCopyPropagation |= Args.hasArg(OPT_enable_copy_propagation);
|
||||
Opts.DisableCopyPropagation |= Args.hasArg(OPT_disable_copy_propagation);
|
||||
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);
|
||||
|
||||
@@ -108,6 +108,10 @@ static llvm::cl::opt<bool> EnableExperimentalLexicalLifetimes(
|
||||
"enable-experimental-lexical-lifetimes",
|
||||
llvm::cl::desc("Enable experimental lexical lifetimes."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
EnableExperimentalMoveOnly("enable-experimental-move-only",
|
||||
llvm::cl::desc("Enable experimental distributed actors."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
EnableExperimentalDistributed("enable-experimental-distributed",
|
||||
llvm::cl::desc("Enable experimental distributed actors."));
|
||||
@@ -424,6 +428,8 @@ int main(int argc, char **argv) {
|
||||
EnableExperimentalConcurrency;
|
||||
Invocation.getLangOptions().EnableExperimentalDistributed =
|
||||
EnableExperimentalDistributed;
|
||||
Invocation.getLangOptions().EnableExperimentalMoveOnly =
|
||||
EnableExperimentalMoveOnly;
|
||||
|
||||
Invocation.getLangOptions().EnableObjCInterop =
|
||||
EnableObjCInterop ? true :
|
||||
@@ -513,6 +519,11 @@ int main(int argc, char **argv) {
|
||||
SILOpts.DisableCopyPropagation = DisableCopyPropagation;
|
||||
SILOpts.EnableExperimentalLexicalLifetimes =
|
||||
EnableExperimentalLexicalLifetimes;
|
||||
// Also enable lexical lifetimes if experimental move only is enabled. This is
|
||||
// because move only depends on lexical lifetimes being enabled and it saved
|
||||
// some typing ; ).
|
||||
SILOpts.EnableExperimentalLexicalLifetimes |=
|
||||
EnableExperimentalMoveOnly;
|
||||
|
||||
serialization::ExtendedValidationInfo extendedInfo;
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
|
||||
|
||||
Reference in New Issue
Block a user