Skip to content

Commit 3cd17f7

Browse files
authored
Merge pull request #17326 from rudkx/add-option-to-disable-shrink
Add a frontend option to disable the "shrink" part of the solver.
2 parents a378536 + 14f3f3e commit 3cd17f7

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -183,6 +183,9 @@ namespace swift {
183183
/// before termination of the shrink phrase of the constraint solver.
184184
unsigned SolverShrinkUnsolvedThreshold = 10;
185185

186+
/// Disable the shrink phase of the expression type checker.
187+
bool SolverDisableShrink = false;
188+
186189
/// The maximum depth to which to test decl circularity.
187190
unsigned MaxCircularityDepth = 500;
188191

include/swift/Option/FrontendOptions.td

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -345,6 +345,10 @@ def warn_long_expression_type_checking_EQ : Joined<["-"], "warn-long-expression-
345345

346346
def solver_expression_time_threshold_EQ : Joined<["-"], "solver-expression-time-threshold=">;
347347

348+
def solver_disable_shrink :
349+
Flag<["-"], "solver-disable-shrink">,
350+
HelpText<"Disable the shrink phase of expression type checking">;
351+
348352
def switch_checking_invocation_threshold_EQ : Joined<["-"],
349353
"switch-checking-invocation-threshold=">;
350354

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -279,6 +279,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
279279
Opts.SolverShrinkUnsolvedThreshold = threshold;
280280
}
281281

282+
if (const Arg *A = Args.getLastArg(OPT_solver_disable_shrink))
283+
Opts.SolverDisableShrink = true;
284+
282285
if (const Arg *A = Args.getLastArg(OPT_value_recursion_threshold)) {
283286
unsigned threshold;
284287
if (StringRef(A->getValue()).getAsInteger(10, threshold)) {

lib/Sema/CSSolver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,9 @@ void ConstraintSystem::Candidate::applySolutions(
981981
}
982982

983983
void ConstraintSystem::shrink(Expr *expr) {
984+
if (TC.getLangOpts().SolverDisableShrink)
985+
return;
986+
984987
using DomainMap = llvm::SmallDenseMap<Expr *, ArrayRef<ValueDecl *>>;
985988

986989
// A collection of original domains of all of the expressions,

0 commit comments

Comments
 (0)