Skip to content

Commit cdcc8ed

Browse files
committed
RequirementMachine: Enable loop normalization by default
1 parent 0045840 commit cdcc8ed

9 files changed

+36
-13
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,14 @@ namespace swift {
540540
RequirementMachineMode RequirementMachineInferredSignatures =
541541
RequirementMachineMode::Verify;
542542

543-
/// Disable preprocessing pass to eliminate conformance requirements
543+
/// Enable preprocessing pass to eliminate conformance requirements
544544
/// on generic parameters which are made concrete. Usually you want this
545545
/// enabled. It can be disabled for debugging and testing.
546546
bool EnableRequirementMachineConcreteContraction = true;
547547

548-
/// Enable the stronger minimization algorithm. This is just for debugging;
549-
/// if you have a testcase which requires this, please submit a bug report.
550-
bool EnableRequirementMachineLoopNormalization = false;
548+
/// Enable the stronger minimization algorithm. Usually you want this
549+
/// enabled. It can be disabled for debugging and testing.
550+
bool EnableRequirementMachineLoopNormalization = true;
551551

552552
/// Enable experimental, more correct support for opaque result types as
553553
/// concrete types. This will sometimes fail to produce a convergent

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def disable_requirement_machine_concrete_contraction : Flag<["-"], "disable-requ
365365
HelpText<"Disable preprocessing pass to eliminate conformance requirements "
366366
"on generic parameters which are made concrete">;
367367

368-
def enable_requirement_machine_loop_normalization : Flag<["-"], "enable-requirement-machine-loop-normalization">,
369-
HelpText<"Enable stronger minimization algorithm, for debugging only">;
368+
def disable_requirement_machine_loop_normalization : Flag<["-"], "disable-requirement-machine-loop-normalization">,
369+
HelpText<"Disable stronger minimization algorithm, for debugging only">;
370370

371371
def enable_requirement_machine_opaque_archetypes : Flag<["-"], "enable-requirement-machine-opaque-archetypes">,
372372
HelpText<"Enable more correct opaque archetype support, which is off by default because it might fail to produce a convergent rewrite system">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
998998
if (Args.hasArg(OPT_disable_requirement_machine_concrete_contraction))
999999
Opts.EnableRequirementMachineConcreteContraction = false;
10001000

1001-
if (Args.hasArg(OPT_enable_requirement_machine_loop_normalization))
1002-
Opts.EnableRequirementMachineLoopNormalization = true;
1001+
if (Args.hasArg(OPT_disable_requirement_machine_loop_normalization))
1002+
Opts.EnableRequirementMachineLoopNormalization = false;
10031003

10041004
if (Args.hasArg(OPT_enable_requirement_machine_opaque_archetypes))
10051005
Opts.EnableRequirementMachineOpaqueArchetypes = true;

test/Generics/concrete_conformance_minimization.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
22
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
3-
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction -enable-requirement-machine-loop-normalization 2>&1 | %FileCheck %s
43

54
struct MyOptionSet : OptionSet {
65
let rawValue: UInt

test/Generics/concrete_conformance_rule_simplified.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
22
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction 2>&1 | %FileCheck %s
3-
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on -disable-requirement-machine-concrete-contraction -enable-requirement-machine-loop-normalization 2>&1 | %FileCheck %s
43

54
protocol P1 {}
65

test/Generics/loop_normalization_1.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on 2>&1 | %FileCheck %s
2-
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-inferred-signatures=on -enable-requirement-machine-loop-normalization 2>&1 | %FileCheck %s
32

43
protocol P {
54
associatedtype T

test/Generics/loop_normalization_2.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2-
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -enable-requirement-machine-loop-normalization 2>&1 | %FileCheck %s
32

43
protocol P1 {
54
associatedtype A
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=on
2+
3+
// This test was reduced from the NonEmpty open-source project; it motivated enabling
4+
// loop normalization by default, since without it, it takes too long to complete.
5+
6+
public protocol WithMinimumCount {}
7+
8+
public protocol NonEmptyProtocol: Swift.Collection, RawRepresentable, WithMinimumCount
9+
where Element == RawValue.Element,
10+
Index == RawValue.Index,
11+
Collection == RawValue
12+
{
13+
associatedtype Collection: Swift.Collection
14+
}
15+
16+
struct G<T>
17+
where T : NonEmptyProtocol,
18+
T.Collection : NonEmptyProtocol,
19+
T.Collection.Collection : NonEmptyProtocol,
20+
T.Collection.Collection.Collection : NonEmptyProtocol,
21+
T.Collection.Collection.Collection.Collection : NonEmptyProtocol,
22+
T.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
23+
T.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
24+
T.Collection.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
25+
T.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
26+
T.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
27+
T.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol,
28+
T.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection.Collection : NonEmptyProtocol {}

test/Generics/redundant_parent_path_in_protocol.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2-
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on -enable-requirement-machine-loop-normalization 2>&1 | %FileCheck %s
32

43
// CHECK-LABEL: redundant_parent_path_in_protocol.(file).P1@
54
// CHECK-NEXT: Requirement signature: <Self>

0 commit comments

Comments
 (0)