@@ -543,7 +543,7 @@ void RewriteSystem::minimizeRewriteSystem() {
543543 // Check invariants after homotopy reduction.
544544 verifyRewriteLoops ();
545545 verifyRedundantConformances (redundantConformances);
546- verifyMinimizedRules ();
546+ verifyMinimizedRules (redundantConformances );
547547}
548548
549549// / In a conformance-valid rewrite system, any rule with unresolved symbols on
@@ -656,7 +656,7 @@ void RewriteSystem::verifyRewriteLoops() const {
656656// / Assert if homotopy reduction failed to eliminate a redundant conformance,
657657// / since this suggests a misunderstanding on my part.
658658void RewriteSystem::verifyRedundantConformances (
659- llvm::DenseSet<unsigned > redundantConformances) const {
659+ const llvm::DenseSet<unsigned > & redundantConformances) const {
660660#ifndef NDEBUG
661661 for (unsigned ruleID : redundantConformances) {
662662 const auto &rule = getRule (ruleID);
@@ -680,9 +680,12 @@ void RewriteSystem::verifyRedundantConformances(
680680
681681// Assert if homotopy reduction failed to eliminate a rewrite rule it was
682682// supposed to delete.
683- void RewriteSystem::verifyMinimizedRules () const {
683+ void RewriteSystem::verifyMinimizedRules (
684+ const llvm::DenseSet<unsigned > &redundantConformances) const {
684685#ifndef NDEBUG
685- for (const auto &rule : Rules) {
686+ for (unsigned ruleID : indices (Rules)) {
687+ const auto &rule = getRule (ruleID);
688+
686689 // Note that sometimes permanent rules can be simplified, but they can never
687690 // be redundant.
688691 if (rule.isPermanent ()) {
@@ -706,6 +709,15 @@ void RewriteSystem::verifyMinimizedRules() const {
706709 dump (llvm::errs ());
707710 abort ();
708711 }
712+
713+ if (rule.isRedundant () &&
714+ rule.isAnyConformanceRule () &&
715+ !rule.containsUnresolvedSymbols () &&
716+ !redundantConformances.count (ruleID)) {
717+ llvm::errs () << " Minimal conformance is redundant: " << rule << " \n\n " ;
718+ dump (llvm::errs ());
719+ abort ();
720+ }
709721 }
710722#endif
711723}
0 commit comments