@@ -1964,9 +1964,6 @@ enum class ConstraintSystemFlags {
19641964
19651965 // / Disable macro expansions.
19661966 DisableMacroExpansions = 0x40 ,
1967-
1968- // / Enable old type-checker performance hacks.
1969- EnablePerformanceHacks = 0x80 ,
19701967};
19711968
19721969// / Options that affect the constraint system as a whole.
@@ -2466,74 +2463,6 @@ class ConstraintSystem {
24662463 SynthesizedConformances;
24672464
24682465private:
2469- // / Describe the candidate expression for partial solving.
2470- // / This class used by shrink & solve methods which apply
2471- // / variation of directional path consistency algorithm in attempt
2472- // / to reduce scopes of the overload sets (disjunctions) in the system.
2473- class Candidate {
2474- Expr *E;
2475- DeclContext *DC;
2476- llvm::BumpPtrAllocator &Allocator;
2477-
2478- // Contextual Information.
2479- Type CT;
2480- ContextualTypePurpose CTP;
2481-
2482- public:
2483- Candidate (ConstraintSystem &cs, Expr *expr, Type ct = Type(),
2484- ContextualTypePurpose ctp = ContextualTypePurpose::CTP_Unused)
2485- : E(expr), DC(cs.DC), Allocator(cs.Allocator), CT(ct), CTP(ctp) {}
2486-
2487- // / Return underlying expression.
2488- Expr *getExpr () const { return E; }
2489-
2490- // / Try to solve this candidate sub-expression
2491- // / and re-write it's OSR domains afterwards.
2492- // /
2493- // / \param shrunkExprs The set of expressions which
2494- // / domains have been successfully shrunk so far.
2495- // /
2496- // / \returns true on solver failure, false otherwise.
2497- bool solve (llvm::SmallSetVector<OverloadSetRefExpr *, 4 > &shrunkExprs);
2498-
2499- // / Apply solutions found by solver as reduced OSR sets for
2500- // / for current and all of it's sub-expressions.
2501- // /
2502- // / \param solutions The solutions found by running solver on the
2503- // / this candidate expression.
2504- // /
2505- // / \param shrunkExprs The set of expressions which
2506- // / domains have been successfully shrunk so far.
2507- void applySolutions (
2508- llvm::SmallVectorImpl<Solution> &solutions,
2509- llvm::SmallSetVector<OverloadSetRefExpr *, 4 > &shrunkExprs) const ;
2510-
2511- // / Check if attempt at solving of the candidate makes sense given
2512- // / the current conditions - number of shrunk domains which is related
2513- // / to the given candidate over the total number of disjunctions present.
2514- static bool
2515- isTooComplexGiven (ConstraintSystem *const cs,
2516- llvm::SmallSetVector<OverloadSetRefExpr *, 4 > &shrunkExprs) {
2517- SmallVector<Constraint *, 8 > disjunctions;
2518- cs->collectDisjunctions (disjunctions);
2519-
2520- unsigned unsolvedDisjunctions = disjunctions.size ();
2521- for (auto *disjunction : disjunctions) {
2522- auto *locator = disjunction->getLocator ();
2523- if (!locator)
2524- continue ;
2525-
2526- if (auto *OSR = getAsExpr<OverloadSetRefExpr>(locator->getAnchor ())) {
2527- if (shrunkExprs.count (OSR) > 0 )
2528- --unsolvedDisjunctions;
2529- }
2530- }
2531-
2532- // The threshold used to be `TypeCheckerOpts.SolverShrinkUnsolvedThreshold`
2533- return unsolvedDisjunctions >= 10 ;
2534- }
2535- };
2536-
25372466 // / Describes the current solver state.
25382467 struct SolverState {
25392468 SolverState (ConstraintSystem &cs,
@@ -3490,12 +3419,6 @@ class ConstraintSystem {
34903419 return Options.contains (ConstraintSystemFlags::ForCodeCompletion);
34913420 }
34923421
3493- // / Check whether old type-checker performance hacks has been explicitly
3494- // / enabled.
3495- bool performanceHacksEnabled () const {
3496- return Options.contains (ConstraintSystemFlags::EnablePerformanceHacks);
3497- }
3498-
34993422 // / Log and record the application of the fix. Return true iff any
35003423 // / subsequent solution would be worse than the best known solution.
35013424 bool recordFix (ConstraintFix *fix, unsigned impact = 1 ,
@@ -5347,24 +5270,12 @@ class ConstraintSystem {
53475270 // / \returns true if an error occurred, false otherwise.
53485271 bool solveSimplified (SmallVectorImpl<Solution> &solutions);
53495272
5350- // / Find reduced domains of disjunction constraints for given
5351- // / expression, this is achieved to solving individual sub-expressions
5352- // / and combining resolving types. Such algorithm is called directional
5353- // / path consistency because it goes from children to parents for all
5354- // / related sub-expressions taking union of their domains.
5355- // /
5356- // / \param expr The expression to find reductions for.
5357- void shrink (Expr *expr);
5358-
53595273 // / Pick a disjunction from the InactiveConstraints list.
53605274 // /
53615275 // / \returns The selected disjunction and a set of it's favored choices.
53625276 std::optional<std::pair<Constraint *, llvm::TinyPtrVector<Constraint *>>>
53635277 selectDisjunction ();
53645278
5365- // / The old method that is only used when performance hacks are enabled.
5366- Constraint *selectDisjunctionWithHacks ();
5367-
53685279 // / Pick a conjunction from the InactiveConstraints list.
53695280 // /
53705281 // / \returns The selected conjunction.
@@ -5556,11 +5467,6 @@ class ConstraintSystem {
55565467 bool applySolutionToBody (TapExpr *tapExpr,
55575468 SyntacticElementTargetRewriter &rewriter);
55585469
5559- // / Reorder the disjunctive clauses for a given expression to
5560- // / increase the likelihood that a favored constraint will be successfully
5561- // / resolved before any others.
5562- void optimizeConstraints (Expr *e);
5563-
55645470 // / Set the current sub-expression (of a multi-statement closure, etc) for
55655471 // / the purposes of diagnosing "reasonable time" errors.
55665472 void startExpression (ASTNode node);
0 commit comments