@@ -150,8 +150,11 @@ namespace {
150
150
// / Utility class to encapsulate some shared state.
151
151
class GeneratingConformances {
152
152
const RewriteSystem &System;
153
+
153
154
RewriteContext &Context;
154
155
156
+ DebugOptions Debug;
157
+
155
158
// All conformance rules, sorted by (isExplicit(), getLHS()), with non-explicit
156
159
// rules with longer left hand sides coming first.
157
160
//
@@ -209,6 +212,7 @@ class GeneratingConformances {
209
212
llvm::DenseSet<unsigned > &redundantConformances)
210
213
: System(system),
211
214
Context(system.getRewriteContext()),
215
+ Debug(system.getDebugOptions()),
212
216
RedundantConformances(redundantConformances) {}
213
217
214
218
void collectConformanceRules ();
@@ -481,7 +485,7 @@ void GeneratingConformances::computeCandidateConformancePaths() {
481
485
if (result.empty ())
482
486
continue ;
483
487
484
- if (System. getDebugOptions () .contains (DebugFlags::GeneratingConformances)) {
488
+ if (Debug .contains (DebugFlags::GeneratingConformances)) {
485
489
llvm::dbgs () << " Candidate homotopy generator: " ;
486
490
loop.dump (llvm::dbgs (), System);
487
491
llvm::dbgs () << " \n " ;
@@ -497,7 +501,7 @@ void GeneratingConformances::computeCandidateConformancePaths() {
497
501
if (inEmptyContext.empty ())
498
502
continue ;
499
503
500
- if (System. getDebugOptions () .contains (DebugFlags::GeneratingConformances)) {
504
+ if (Debug .contains (DebugFlags::GeneratingConformances)) {
501
505
llvm::dbgs () << " * Protocol " << proto->getName () << " :\n " ;
502
506
llvm::dbgs () << " ** Conformance rules not in context:\n " ;
503
507
for (unsigned ruleID : inEmptyContext) {
@@ -755,7 +759,7 @@ void GeneratingConformances::verifyGeneratingConformanceEquations() const {
755
759
llvm::errs () << " Mismatched conformance:\n " ;
756
760
llvm::errs () << " Base rule: " << rule << " \n " ;
757
761
llvm::errs () << " Final rule: " << otherRule << " \n\n " ;
758
- System. dump (llvm::errs ());
762
+ dumpGeneratingConformanceEquations (llvm::errs ());
759
763
abort ();
760
764
}
761
765
@@ -772,7 +776,7 @@ void GeneratingConformances::verifyGeneratingConformanceEquations() const {
772
776
pair.first , pair.second );
773
777
llvm::errs () << " \n " ;
774
778
llvm::errs () << " Term: " << rule << " \n " ;
775
- System. dump (llvm::errs ());
779
+ dumpGeneratingConformanceEquations (llvm::errs ());
776
780
abort ();
777
781
}
778
782
@@ -789,7 +793,7 @@ void GeneratingConformances::verifyGeneratingConformanceEquations() const {
789
793
llvm::errs () << " Invalid conformance path:\n " ;
790
794
llvm::errs () << " Expected: " << baseTerm << " \n " ;
791
795
llvm::errs () << " Got: " << otherTerm << " \n\n " ;
792
- System. dump (llvm::errs ());
796
+ dumpGeneratingConformanceEquations (llvm::errs ());
793
797
abort ();
794
798
}
795
799
}
@@ -824,6 +828,12 @@ void GeneratingConformances::computeGeneratingConformances(
824
828
// considered in the second pass.
825
829
if (!derivedViaConcrete)
826
830
continue ;
831
+
832
+ if (Debug.contains (DebugFlags::GeneratingConformances)) {
833
+ llvm::dbgs () << " Derived-via-concrete: " ;
834
+ dumpGeneratingConformanceEquation (llvm::dbgs (), ruleID, paths);
835
+ llvm::dbgs () << " \n " ;
836
+ }
827
837
} else {
828
838
// Ignore rules already determined to be redundant by the first pass.
829
839
if (RedundantConformances.count (ruleID) > 0 )
@@ -843,6 +853,14 @@ void GeneratingConformances::computeGeneratingConformances(
843
853
844
854
if (isValidConformancePath (visited, path,
845
855
/* allowConcrete=*/ true )) {
856
+ if (Debug.contains (DebugFlags::GeneratingConformances)) {
857
+ llvm::dbgs () << " Redundant rule in " ;
858
+ llvm::dbgs () << (firstPass ? " first" : " second" );
859
+ llvm::dbgs () << " pass: " ;
860
+ llvm::dbgs () << System.getRule (ruleID).getLHS ();
861
+ llvm::dbgs () << " \n " ;
862
+ }
863
+
846
864
RedundantConformances.insert (ruleID);
847
865
break ;
848
866
}
@@ -869,7 +887,7 @@ void GeneratingConformances::verifyGeneratingConformances() const {
869
887
/* allowConcrete=*/ true )) {
870
888
llvm::errs () << " Redundant conformance is not recoverable:\n " ;
871
889
llvm::errs () << rule << " \n\n " ;
872
- System. dump (llvm::errs ());
890
+ dumpGeneratingConformanceEquations (llvm::errs ());
873
891
abort ();
874
892
}
875
893
@@ -879,14 +897,14 @@ void GeneratingConformances::verifyGeneratingConformances() const {
879
897
if (rule.isRedundant ()) {
880
898
llvm::errs () << " Generating conformance is redundant: " ;
881
899
llvm::errs () << rule << " \n\n " ;
882
- System. dump (llvm::errs ());
900
+ dumpGeneratingConformanceEquations (llvm::errs ());
883
901
abort ();
884
902
}
885
903
886
904
if (rule.getLHS ().containsUnresolvedSymbols ()) {
887
905
llvm::errs () << " Generating conformance contains unresolved symbols: " ;
888
906
llvm::errs () << rule << " \n\n " ;
889
- System. dump (llvm::errs ());
907
+ dumpGeneratingConformanceEquations (llvm::errs ());
890
908
abort ();
891
909
}
892
910
}
0 commit comments