@@ -2540,26 +2540,11 @@ class ConstraintSystem {
2540
2540
#define CS_STATISTIC (Name, Description ) unsigned Name = 0 ;
2541
2541
#include " ConstraintSolverStats.def"
2542
2542
2543
- // / Check whether there are any retired constraints present.
2544
- bool hasRetiredConstraints () const {
2545
- return !retiredConstraints.empty ();
2546
- }
2547
-
2548
2543
// / Mark given constraint as retired along current solver path.
2549
2544
// /
2550
2545
// / \param constraint The constraint to retire temporarily.
2551
2546
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));
2563
2548
}
2564
2549
2565
2550
// / Add new "generated" constraint along the current solver path.
@@ -2569,49 +2554,26 @@ class ConstraintSystem {
2569
2554
Trail.recordChange (SolverTrail::Change::GeneratedConstraint (constraint));
2570
2555
}
2571
2556
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.
2575
2558
// /
2576
2559
// / \param scope The scope to associate with current solver state.
2577
- void registerScope (SolverScope *scope) {
2560
+ void beginScope (SolverScope *scope) {
2578
2561
++depth;
2579
2562
maxDepth = std::max (maxDepth, depth);
2580
2563
scope->scopeNumber = NumStatesExplored++;
2581
2564
2582
2565
CS.incrementScopeCounter ();
2583
- auto scopeInfo =
2584
- std::make_tuple (scope, retiredConstraints.begin ());
2585
- scopes.push_back (scopeInfo);
2586
2566
}
2587
2567
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.
2593
2569
// /
2594
2570
// / \param scope The solver scope to rollback.
2595
- void rollback (SolverScope *scope) {
2571
+ void endScope (SolverScope *scope) {
2596
2572
--depth;
2597
2573
2598
2574
unsigned countScopesExplored = NumStatesExplored - scope->scopeNumber ;
2599
2575
if (countScopesExplored == 1 )
2600
2576
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);
2615
2577
}
2616
2578
2617
2579
// / Check whether constraint system is allowed to form solutions
@@ -2638,25 +2600,12 @@ class ConstraintSystem {
2638
2600
}
2639
2601
2640
2602
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 ;
2645
2605
2646
2606
// / The set of constraints which were active at the time of this state
2647
2607
// / creating, it's used to re-activate them on destruction.
2648
2608
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 ;
2660
2609
};
2661
2610
2662
2611
class CacheExprTypes : public ASTWalker {
0 commit comments