@@ -2540,26 +2540,11 @@ class ConstraintSystem {
25402540 #define CS_STATISTIC (Name, Description ) unsigned Name = 0 ;
25412541 #include " ConstraintSolverStats.def"
25422542
2543- // / Check whether there are any retired constraints present.
2544- bool hasRetiredConstraints () const {
2545- return !retiredConstraints.empty ();
2546- }
2547-
25482543 // / Mark given constraint as retired along current solver path.
25492544 // /
25502545 // / \param constraint The constraint to retire temporarily.
25512546 void retireConstraint (Constraint *constraint) {
2552- retiredConstraints.push_front (constraint);
2553- }
2554-
2555- // / Iterate over all of the retired constraints registered with
2556- // / current solver state.
2557- // /
2558- // / \param processor The processor function to be applied to each of
2559- // / the constraints retrieved.
2560- void forEachRetired (llvm::function_ref<void (Constraint &)> processor) {
2561- for (auto &constraint : retiredConstraints)
2562- processor (constraint);
2547+ Trail.recordChange (SolverTrail::Change::RetiredConstraint (constraint));
25632548 }
25642549
25652550 // / Add new "generated" constraint along the current solver path.
@@ -2569,49 +2554,26 @@ class ConstraintSystem {
25692554 Trail.recordChange (SolverTrail::Change::GeneratedConstraint (constraint));
25702555 }
25712556
2572- // / Register given scope to be tracked by the current solver state,
2573- // / this helps to make sure that all of the retired/generated constraints
2574- // / are dealt with correctly when the life time of the scope ends.
2557+ // / Update statistics when a scope begins.
25752558 // /
25762559 // / \param scope The scope to associate with current solver state.
2577- void registerScope (SolverScope *scope) {
2560+ void beginScope (SolverScope *scope) {
25782561 ++depth;
25792562 maxDepth = std::max (maxDepth, depth);
25802563 scope->scopeNumber = NumStatesExplored++;
25812564
25822565 CS.incrementScopeCounter ();
2583- auto scopeInfo =
2584- std::make_tuple (scope, retiredConstraints.begin ());
2585- scopes.push_back (scopeInfo);
25862566 }
25872567
2588- // / Restore all of the retired/generated constraints to the state
2589- // / before given scope. This is required because retired constraints have
2590- // / to be re-introduced to the system in order of arrival (LIFO) and list
2591- // / of the generated constraints has to be truncated back to the
2592- // / original size.
2568+ // / Update statistics when a scope ends.
25932569 // /
25942570 // / \param scope The solver scope to rollback.
2595- void rollback (SolverScope *scope) {
2571+ void endScope (SolverScope *scope) {
25962572 --depth;
25972573
25982574 unsigned countScopesExplored = NumStatesExplored - scope->scopeNumber ;
25992575 if (countScopesExplored == 1 )
26002576 CS.incrementLeafScopes ();
2601-
2602- SolverScope *savedScope;
2603- // The position of last retired constraint before given scope.
2604- ConstraintList::iterator lastRetiredPos;
2605-
2606- std::tie (savedScope, lastRetiredPos) =
2607- scopes.pop_back_val ();
2608-
2609- assert (savedScope == scope && " Scope rollback not in LIFO order!" );
2610-
2611- // Restore all of the retired constraints.
2612- CS.InactiveConstraints .splice (CS.InactiveConstraints .end (),
2613- retiredConstraints,
2614- retiredConstraints.begin (), lastRetiredPos);
26152577 }
26162578
26172579 // / Check whether constraint system is allowed to form solutions
@@ -2638,25 +2600,12 @@ class ConstraintSystem {
26382600 }
26392601
26402602 private:
2641- // / The list of constraints that have been retired along the
2642- // / current path, this list is used in LIFO fashion when
2643- // / constraints are added back to the circulation.
2644- ConstraintList retiredConstraints;
2603+ // / Depth of the solution stack.
2604+ unsigned depth = 0 ;
26452605
26462606 // / The set of constraints which were active at the time of this state
26472607 // / creating, it's used to re-activate them on destruction.
26482608 SmallVector<Constraint *, 4 > activeConstraints;
2649-
2650- // / The collection which holds association between solver scope
2651- // / and position of the last retired constraint and number of
2652- // / constraints generated before registration of given scope,
2653- // / this helps to rollback all of the constraints retired/generated
2654- // / each of the registered scopes correct (LIFO) order.
2655- llvm::SmallVector<
2656- std::tuple<SolverScope *, ConstraintList::iterator>, 4 > scopes;
2657-
2658- // / Depth of the solution stack.
2659- unsigned depth = 0 ;
26602609 };
26612610
26622611 class CacheExprTypes : public ASTWalker {
0 commit comments