Skip to content

Commit f98b211

Browse files
Merge pull request #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;

lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ class MoveOnlyAddressCheckerTesterPass : public SILFunctionTransform {
7878
void run() override {
7979
auto *fn = getFunction();
8080

81-
// Only run this pass if the move only language feature is enabled.
82-
if (!fn->getASTContext().supportsMoveOnlyTypes())
83-
return;
84-
8581
// Don't rerun diagnostics on deserialized functions.
8682
if (getFunction()->wasDeserializedCanonical())
8783
return;

lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureTester.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ class MoveOnlyBorrowToDestructureTransformPass : public SILFunctionTransform {
7171
void run() override {
7272
auto *fn = getFunction();
7373

74-
// Only run this pass if the move only language feature is enabled.
75-
if (!fn->getASTContext().supportsMoveOnlyTypes())
76-
return;
77-
7874
// Don't rerun diagnostics on deserialized functions.
7975
if (getFunction()->wasDeserializedCanonical())
8076
return;

lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ class MoveOnlyCheckerPass : public SILFunctionTransform {
215215
void run() override {
216216
auto *fn = getFunction();
217217

218-
// Only run this pass if the move only language feature is enabled.
219-
if (!fn->getASTContext().supportsMoveOnlyTypes())
220-
return;
221-
222218
// Don't rerun diagnostics on deserialized functions.
223219
if (getFunction()->wasDeserializedCanonical())
224220
return;

lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class MoveOnlyObjectCheckerTesterPass : public SILFunctionTransform {
7575
void run() override {
7676
auto *fn = getFunction();
7777

78-
// Only run this pass if the move only language feature is enabled.
79-
if (!fn->getASTContext().supportsMoveOnlyTypes())
80-
return;
81-
8278
// Don't rerun diagnostics on deserialized functions.
8379
if (getFunction()->wasDeserializedCanonical())
8480
return;

lib/SILOptimizer/Mandatory/MoveOnlyTempAllocationFromLetTester.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ struct MoveOnlyTempAllocationFromLetTester : SILFunctionTransform {
3434
void run() override {
3535
auto *fn = getFunction();
3636

37-
// Only run this pass if the move only language feature is enabled.
38-
if (!fn->getASTContext().supportsMoveOnlyTypes())
39-
return;
40-
4137
// Don't rerun diagnostics on deserialized functions.
4238
if (getFunction()->wasDeserializedCanonical())
4339
return;

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,9 +2390,6 @@ void AttributeChecker::visitFinalAttr(FinalAttr *attr) {
23902390
}
23912391

23922392
void AttributeChecker::visitMoveOnlyAttr(MoveOnlyAttr *attr) {
2393-
if (!D->getASTContext().supportsMoveOnlyTypes())
2394-
D->diagnose(diag::moveOnly_requires_lexical_lifetimes);
2395-
23962393
if (isa<StructDecl>(D) || isa<EnumDecl>(D))
23972394
return;
23982395

lib/Sema/TypeCheckDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,10 +931,6 @@ InvertibleAnnotationRequest::evaluate(Evaluator &evaluator,
931931
if (auto attr = decl->getAttrs().getAttribute<MoveOnlyAttr>()) {
932932
assert((isa<StructDecl, EnumDecl, ClassDecl>(decl)));
933933

934-
// FIXME: just never allow lexical-lifetimes to be disabled?
935-
if (!ctx.supportsMoveOnlyTypes())
936-
decl->diagnose(diag::moveOnly_requires_lexical_lifetimes);
937-
938934
return InverseMarking::forInverse(Kind::LegacyExplicit,
939935
attr->getLocation());
940936
}

test/IRGen/debug_poison.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -emit-ir -Onone -enable-copy-propagation -enable-lexical-borrow-scopes=false | %FileCheck %s -DINT=i%target-ptrsize
1+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -Onone -enable-copy-propagation | %FileCheck %s -DINT=i%target-ptrsize
22
//
33
// This test is currently disabled because mandatory copy propagation
44
// is not part of the pipeline. It may be re-added to the pipeline,

test/Interpreter/builtin_bridge_object.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-Onone -parse-stdlib -Xfrontend -enable-copy-propagation -Xfrontend -enable-lexical-borrow-scopes=false) | %FileCheck %s --check-prefixes=CHECK,CHECK-DBG
2-
// RUN: %target-run-simple-swift(-O -parse-stdlib -Xfrontend -enable-copy-propagation -Xfrontend -enable-lexical-borrow-scopes=false) | %FileCheck --check-prefixes=CHECK,CHECK-OPT %s
1+
// RUN: %target-run-simple-swift(-Onone -parse-stdlib -Xfrontend -enable-copy-propagation) | %FileCheck %s --check-prefixes=CHECK,CHECK-DBG
2+
// RUN: %target-run-simple-swift(-O -parse-stdlib -Xfrontend -enable-copy-propagation) | %FileCheck --check-prefixes=CHECK,CHECK-OPT %s
33

44
// REQUIRES: executable_test
55
// REQUIRES: objc_interop
@@ -70,7 +70,6 @@ if true {
7070
print(x === x1)
7171
// CHECK-NEXT: true
7272
print(x === x2)
73-
// CHECK-OPT-NEXT: deallocated
7473

7574
print(nonPointerBits(bo) == 0)
7675
// CHECK-NEXT: true
@@ -84,7 +83,7 @@ if true {
8483
_fixLifetime(bo3)
8584
_fixLifetime(bo4)
8685
}
87-
// CHECK-DBG-NEXT: deallocated
86+
// CHECK-NEXT: deallocated
8887
// CHECK-NEXT: deallocated
8988

9089
// Try with all spare bits set.
@@ -99,7 +98,6 @@ if true {
9998
print(x === x1)
10099
// CHECK-NEXT: true
101100
print(x === x2)
102-
// CHECK-OPT-NEXT: deallocated
103101

104102
print(nonPointerBits(bo) == NATIVE_SPARE_BITS)
105103
// CHECK-NEXT: true
@@ -113,7 +111,7 @@ if true {
113111
_fixLifetime(bo3)
114112
_fixLifetime(bo4)
115113
}
116-
// CHECK-DBG-NEXT: deallocated
114+
// CHECK-NEXT: deallocated
117115
// CHECK-NEXT: deallocated
118116

119117

test/SILOptimizer/allocbox_to_stack.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -sil-print-debuginfo -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s
1+
// RUN: %target-sil-opt -sil-print-debuginfo -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only | %FileCheck %s
22

33
sil_stage raw
44

test/SILOptimizer/allocbox_to_stack_ownership.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only | %FileCheck %s
22

33
sil_stage raw
44

test/SILOptimizer/allocbox_to_stack_ownership_attrs.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s
1+
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only | %FileCheck %s
22

33
sil_stage raw
44

test/SILOptimizer/assemblyvision_remark/attributes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false -emit-sil %s -verify -Osize -o /dev/null -module-name main
1+
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -emit-sil %s -verify -Osize -o /dev/null -module-name main
22
//
33
// NOTE: We only emit opt-remarks with -Osize,-O today! -O does drop way more
44
// stuff though, so we test with -Osize.

0 commit comments

Comments
 (0)