Skip to content

Commit f98b211

Browse files
Merge pull request swiftlang#71403 from nate-chandler/delete-flag
[Frontend] Removed enable-lexical-borrow-scopes flag.
2 parents d46bd33 + 336afca commit f98b211

30 files changed

+89
-198
lines changed

include/swift/AST/ASTContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,6 @@ class ASTContext final {
743743
FuncDecl *getMakeInvocationEncoderOnDistributedActorSystem(
744744
AbstractFunctionDecl *thunk) const;
745745

746-
/// Indicates whether move-only / noncopyable types are supported.
747-
bool supportsMoveOnlyTypes() const;
748-
749746
// Retrieve the declaration of
750747
// DistributedInvocationEncoder.recordGenericSubstitution(_:).
751748
//

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7690,10 +7690,6 @@ ERROR(copy_expression_not_passed_lvalue,none,
76907690
ERROR(copy_expression_cannot_be_used_with_noncopyable_types,none,
76917691
"'copy' cannot be applied to noncopyable types", ())
76927692

7693-
ERROR(moveOnly_requires_lexical_lifetimes,none,
7694-
"noncopyable types require lexical borrow scopes "
7695-
"(add -enable-lexical-borrow-scopes=true)", ())
7696-
76977693
// Experimental noncopyable feature diagnostics:
76987694
ERROR(experimental_moveonly_feature_can_only_be_used_when_enabled,
76997695
none, "Can not use feature when experimental move only is disabled! Pass"

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
namespace swift {
3232

3333
enum class LexicalLifetimesOption : uint8_t {
34-
// Do not insert lexical markers.
35-
Off = 0,
36-
3734
// Insert lexical markers via lexical borrow scopes and the lexical flag on
3835
// alloc_stacks produced from alloc_boxes, but strip them when lowering out of
3936
// Raw SIL.

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,6 @@ def enable_experimental_concurrency :
320320
Flag<["-"], "enable-experimental-concurrency">,
321321
HelpText<"Enable experimental concurrency model">;
322322

323-
def enable_lexical_borrow_scopes :
324-
Joined<["-"], "enable-lexical-borrow-scopes=">,
325-
HelpText<"Whether to emit lexical borrow scopes (default: true)">,
326-
MetaVarName<"true|false">;
327-
328323
def enable_experimental_move_only :
329324
Flag<["-"], "enable-experimental-move-only">,
330325
HelpText<"Enable experimental move only">;

include/swift/SIL/SILModule.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,9 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SILModule &M){
10751075
inline bool SILOptions::supportsLexicalLifetimes(const SILModule &mod) const {
10761076
switch (mod.getStage()) {
10771077
case SILStage::Raw:
1078-
// In raw SIL, lexical markers are used for diagnostics. These markers are
1079-
// present as long as the lexical lifetimes feature is not disabled
1080-
// entirely.
1081-
return LexicalLifetimes != LexicalLifetimesOption::Off;
1078+
// In raw SIL, lexical markers are used for diagnostics and are always
1079+
// present.
1080+
return true;
10821081
case SILStage::Canonical:
10831082
case SILStage::Lowered:
10841083
// In Canonical SIL, lexical markers are used to ensure that object

lib/AST/ASTContext.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6593,8 +6593,3 @@ Type ASTContext::getNamedSwiftType(ModuleDecl *module, StringRef name) {
65936593
return nominalDecl->getDeclaredType();
65946594
return decl->getDeclaredInterfaceType();
65956595
}
6596-
6597-
bool ASTContext::supportsMoveOnlyTypes() const {
6598-
// currently the only thing holding back whether the types can appear is this.
6599-
return SILOpts.LexicalLifetimes != LexicalLifetimesOption::Off;
6600-
}

lib/DriverTool/sil_opt_main.cpp

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -228,17 +228,10 @@ struct SILOptOptions {
228228
EnableExperimentalConcurrency = llvm::cl::opt<bool>("enable-experimental-concurrency",
229229
llvm::cl::desc("Enable experimental concurrency model."));
230230

231-
llvm::cl::opt<llvm::cl::boolOrDefault>
232-
EnableLexicalLifetimes = llvm::cl::opt<llvm::cl::boolOrDefault>(
233-
"enable-lexical-lifetimes", llvm::cl::init(llvm::cl::BOU_UNSET),
234-
llvm::cl::desc("Enable lexical lifetimes. Mutually exclusive with "
235-
"enable-lexical-borrow-scopes and "
236-
"disable-lexical-lifetimes."));
237-
238-
llvm::cl::opt<llvm::cl::boolOrDefault>
239-
EnableLexicalBorrowScopes = llvm::cl::opt<llvm::cl::boolOrDefault>("enable-lexical-borrow-scopes",
240-
llvm::cl::init(llvm::cl::BOU_UNSET),
241-
llvm::cl::desc("Enable lexical borrow scopes."));
231+
llvm::cl::opt<llvm::cl::boolOrDefault> EnableLexicalLifetimes =
232+
llvm::cl::opt<llvm::cl::boolOrDefault>(
233+
"enable-lexical-lifetimes", llvm::cl::init(llvm::cl::BOU_UNSET),
234+
llvm::cl::desc("Enable lexical lifetimes."));
242235

243236
llvm::cl::opt<llvm::cl::boolOrDefault>
244237
EnableExperimentalMoveOnly = llvm::cl::opt<llvm::cl::boolOrDefault>(
@@ -771,32 +764,11 @@ int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
771764

772765
llvm::Optional<bool> enableLexicalLifetimes =
773766
toOptionalBool(options.EnableLexicalLifetimes);
774-
llvm::Optional<bool> enableLexicalBorrowScopes =
775-
toOptionalBool(options.EnableLexicalBorrowScopes);
776-
777-
// Enable lexical lifetimes if it is set or if experimental move only is
778-
// enabled. This is because move only depends on lexical lifetimes being
779-
// enabled and it saved some typing ; ).
780-
bool specifiedLexicalLifetimesEnabled =
781-
enableExperimentalMoveOnly && *enableExperimentalMoveOnly &&
782-
enableLexicalLifetimes && *enableLexicalLifetimes;
783-
if (specifiedLexicalLifetimesEnabled && enableLexicalBorrowScopes &&
784-
!*enableLexicalBorrowScopes) {
785-
fprintf(
786-
stderr,
787-
"Error! Cannot specify both -enable-lexical-borrow-scopes=false and "
788-
"either -enable-lexical-lifetimes or -enable-experimental-move-only.");
789-
exit(-1);
790-
}
767+
791768
if (enableLexicalLifetimes)
792769
SILOpts.LexicalLifetimes =
793770
*enableLexicalLifetimes ? LexicalLifetimesOption::On
794771
: LexicalLifetimesOption::DiagnosticMarkersOnly;
795-
if (enableLexicalBorrowScopes)
796-
SILOpts.LexicalLifetimes =
797-
*enableLexicalBorrowScopes
798-
? LexicalLifetimesOption::DiagnosticMarkersOnly
799-
: LexicalLifetimesOption::Off;
800772

801773
SILOpts.EnablePackMetadataStackPromotion =
802774
options.EnablePackMetadataStackPromotion;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,15 +2198,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
21982198
Opts.CopyPropagation = *specifiedCopyPropagationOption;
21992199
}
22002200

2201-
llvm::Optional<bool> enableLexicalBorrowScopesFlag;
2202-
if (Arg *A = Args.getLastArg(OPT_enable_lexical_borrow_scopes)) {
2203-
enableLexicalBorrowScopesFlag =
2204-
llvm::StringSwitch<llvm::Optional<bool>>(A->getValue())
2205-
.Case("true", true)
2206-
.Case("false", false)
2207-
.Default(llvm::None);
2208-
}
2209-
22102201
// Allow command line flags to override the default value of
22112202
// Opts.LexicalLifetimes. If no explicit flags are passed, then
22122203
// Opts.LexicalLifetimes retains its initial value.
@@ -2231,26 +2222,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
22312222
}
22322223
}
22332224

2234-
if (enableLexicalLifetimesFlag.value_or(false) &&
2235-
!enableLexicalBorrowScopesFlag.value_or(true)) {
2236-
// Error if lexical lifetimes have been enabled but lexical borrow scopes--
2237-
// on which they are dependent--have been disabled.
2238-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
2239-
"enable-lexical-lifetimes=true",
2240-
"enable-lexical-borrow-scopes=false");
2241-
return true;
2242-
}
2243-
2244-
if (Args.hasArg(OPT_enable_experimental_move_only) &&
2245-
!enableLexicalBorrowScopesFlag.value_or(true)) {
2246-
// Error if move-only is enabled and lexical borrow scopes--on which it
2247-
// depends--has been disabled.
2248-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
2249-
"enable-experimental-move-only",
2250-
"enable-lexical-borrow-scopes=false");
2251-
return true;
2252-
}
2253-
22542225
// Unless overridden below, enabling copy propagation means enabling lexical
22552226
// lifetimes.
22562227
if (Opts.CopyPropagation == CopyPropagationOption::On) {
@@ -2277,13 +2248,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
22772248
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
22782249
}
22792250
}
2280-
if (enableLexicalBorrowScopesFlag) {
2281-
if (*enableLexicalBorrowScopesFlag) {
2282-
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
2283-
} else {
2284-
Opts.LexicalLifetimes = LexicalLifetimesOption::Off;
2285-
}
2286-
}
22872251
if (specifiedDestroyHoistingOption)
22882252
Opts.DestroyHoisting = *specifiedDestroyHoistingOption;
22892253

lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,10 +2463,6 @@ class ConsumeOperatorCopyableAddressesCheckerPass
24632463
auto *fn = getFunction();
24642464
auto &astContext = fn->getASTContext();
24652465

2466-
// Only run this pass if the move only language feature is enabled.
2467-
if (!astContext.supportsMoveOnlyTypes())
2468-
return;
2469-
24702466
// Don't rerun diagnostics on deserialized functions.
24712467
if (getFunction()->wasDeserializedCanonical())
24722468
return;

lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,6 @@ class ConsumeOperatorCopyableValuesCheckerPass : public SILFunctionTransform {
553553
void run() override {
554554
auto *fn = getFunction();
555555

556-
// Only run this pass if the move only language feature is enabled.
557-
if (!fn->getASTContext().supportsMoveOnlyTypes())
558-
return;
559-
560556
// Don't rerun diagnostics on deserialized functions.
561557
if (fn->wasDeserializedCanonical())
562558
return;

0 commit comments

Comments
 (0)