@@ -488,7 +488,7 @@ RewritePath::getRulesInEmptyContext(const MutableTerm &term,
488488// / \p redundantConformances equal to the set of conformance rules that are
489489// / not minimal conformances.
490490Optional<std::pair<unsigned , unsigned >> RewriteSystem::
491- findRuleToDelete (llvm::function_ref< bool ( unsigned )> isRedundantRuleFn) {
491+ findRuleToDelete (EliminationPredicate isRedundantRuleFn) {
492492 SmallVector<std::pair<unsigned , unsigned >, 2 > redundancyCandidates;
493493 for (unsigned loopID : indices (Loops)) {
494494 auto &loop = Loops[loopID];
@@ -520,7 +520,10 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
520520 }
521521
522522 for (const auto &pair : redundancyCandidates) {
523+ unsigned loopID = pair.first ;
523524 unsigned ruleID = pair.second ;
525+
526+ const auto &loop = Loops[loopID];
524527 const auto &rule = getRule (ruleID);
525528
526529 // We should not find a rule that has already been marked redundant
@@ -538,18 +541,18 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
538541 // Homotopy reduction runs multiple passes with different filters to
539542 // prioritize the deletion of certain rules ahead of others. Apply
540543 // the filter now.
541- if (!isRedundantRuleFn (ruleID)) {
544+ if (!isRedundantRuleFn (loopID, ruleID)) {
542545 if (Debug.contains (DebugFlags::HomotopyReductionDetail)) {
543546 llvm::dbgs () << " ** Skipping rule " << rule << " from loop #"
544- << pair. first << " \n " ;
547+ << loopID << " \n " ;
545548 }
546549
547550 continue ;
548551 }
549552
550553 if (Debug.contains (DebugFlags::HomotopyReductionDetail)) {
551554 llvm::dbgs () << " ** Candidate rule " << rule << " from loop #"
552- << pair. first << " \n " ;
555+ << loopID << " \n " ;
553556 }
554557
555558 if (!found) {
@@ -561,7 +564,6 @@ findRuleToDelete(llvm::function_ref<bool(unsigned)> isRedundantRuleFn) {
561564 // we've found so far.
562565 const auto &otherRule = getRule (found->second );
563566
564- const auto &loop = Loops[pair.first ];
565567 const auto &otherLoop = Loops[found->first ];
566568
567569 {
@@ -712,7 +714,7 @@ void RewriteSystem::deleteRule(unsigned ruleID,
712714}
713715
714716void RewriteSystem::performHomotopyReduction (
715- llvm::function_ref< bool ( unsigned )> isRedundantRuleFn) {
717+ EliminationPredicate isRedundantRuleFn) {
716718 while (true ) {
717719 auto optPair = findRuleToDelete (isRedundantRuleFn);
718720
@@ -810,7 +812,7 @@ void RewriteSystem::minimizeRewriteSystem() {
810812 llvm::dbgs () << " ---------------------------------------------\n " ;
811813 }
812814
813- performHomotopyReduction ([&](unsigned ruleID) -> bool {
815+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
814816 const auto &rule = getRule (ruleID);
815817
816818 if (rule.isLHSSimplified () &&
@@ -845,7 +847,7 @@ void RewriteSystem::minimizeRewriteSystem() {
845847 llvm::dbgs () << " --------------------------------------------\n " ;
846848 }
847849
848- performHomotopyReduction ([&](unsigned ruleID) -> bool {
850+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
849851 const auto &rule = getRule (ruleID);
850852
851853 if (rule.isAnyConformanceRule () &&
@@ -862,7 +864,7 @@ void RewriteSystem::minimizeRewriteSystem() {
862864 llvm::dbgs () << " ---------------------------------------\n " ;
863865 }
864866
865- performHomotopyReduction ([&](unsigned ruleID) -> bool {
867+ performHomotopyReduction ([&](unsigned loopID, unsigned ruleID) -> bool {
866868 const auto &rule = getRule (ruleID);
867869
868870 if (!rule.isAnyConformanceRule ())
0 commit comments