@@ -488,7 +488,7 @@ RewritePath::getRulesInEmptyContext(const MutableTerm &term,
488
488
// / \p redundantConformances equal to the set of conformance rules that are
489
489
// / not minimal conformances.
490
490
Optional<std::pair<unsigned , unsigned >> RewriteSystem::
491
- findRuleToDelete (llvm::function_ref< bool ( unsigned )> isRedundantRuleFn) {
491
+ findRuleToDelete (EliminationPredicate isRedundantRuleFn) {
492
492
SmallVector<std::pair<unsigned , unsigned >, 2 > redundancyCandidates;
493
493
for (unsigned loopID : indices (Loops)) {
494
494
auto &loop = Loops[loopID];
@@ -520,7 +520,10 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
520
520
}
521
521
522
522
for (const auto &pair : redundancyCandidates) {
523
+ unsigned loopID = pair.first ;
523
524
unsigned ruleID = pair.second ;
525
+
526
+ const auto &loop = Loops[loopID];
524
527
const auto &rule = getRule (ruleID);
525
528
526
529
// We should not find a rule that has already been marked redundant
@@ -538,18 +541,18 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
538
541
// Homotopy reduction runs multiple passes with different filters to
539
542
// prioritize the deletion of certain rules ahead of others. Apply
540
543
// the filter now.
541
- if (!isRedundantRuleFn (ruleID)) {
544
+ if (!isRedundantRuleFn (loopID, ruleID)) {
542
545
if (Debug.contains (DebugFlags::HomotopyReductionDetail)) {
543
546
llvm::dbgs () << " ** Skipping rule " << rule << " from loop #"
544
- << pair. first << " \n " ;
547
+ << loopID << " \n " ;
545
548
}
546
549
547
550
continue ;
548
551
}
549
552
550
553
if (Debug.contains (DebugFlags::HomotopyReductionDetail)) {
551
554
llvm::dbgs () << " ** Candidate rule " << rule << " from loop #"
552
- << pair. first << " \n " ;
555
+ << loopID << " \n " ;
553
556
}
554
557
555
558
if (!found) {
@@ -561,7 +564,6 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
561
564
// we've found so far.
562
565
const auto &otherRule = getRule (found->second );
563
566
564
- const auto &loop = Loops[pair.first ];
565
567
const auto &otherLoop = Loops[found->first ];
566
568
567
569
{
@@ -712,7 +714,7 @@ void RewriteSystem::deleteRule(unsigned ruleID,
712
714
}
713
715
714
716
void RewriteSystem::performHomotopyReduction (
715
- llvm::function_ref< bool ( unsigned )> isRedundantRuleFn) {
717
+ EliminationPredicate isRedundantRuleFn) {
716
718
while (true ) {
717
719
auto optPair = findRuleToDelete (isRedundantRuleFn);
718
720
@@ -810,7 +812,7 @@ void RewriteSystem::minimizeRewriteSystem() {
810
812
llvm::dbgs () << " ---------------------------------------------\n " ;
811
813
}
812
814
813
- performHomotopyReduction ([&](unsigned ruleID) -> bool {
815
+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
814
816
const auto &rule = getRule (ruleID);
815
817
816
818
if (rule.isLHSSimplified () &&
@@ -845,7 +847,7 @@ void RewriteSystem::minimizeRewriteSystem() {
845
847
llvm::dbgs () << " --------------------------------------------\n " ;
846
848
}
847
849
848
- performHomotopyReduction ([&](unsigned ruleID) -> bool {
850
+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
849
851
const auto &rule = getRule (ruleID);
850
852
851
853
if (rule.isAnyConformanceRule () &&
@@ -862,7 +864,7 @@ void RewriteSystem::minimizeRewriteSystem() {
862
864
llvm::dbgs () << " ---------------------------------------\n " ;
863
865
}
864
866
865
- performHomotopyReduction ([&](unsigned ruleID) -> bool {
867
+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
866
868
const auto &rule = getRule (ruleID);
867
869
868
870
if (!rule.isAnyConformanceRule ())
0 commit comments