[llvm] r288693 - TableGen/AsmMatcherEmitter: Bring sorting check back under EXPENSIVE_CHECKS

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 11:44:31 PST 2016


Author: matze
Date: Mon Dec  5 13:44:31 2016
New Revision: 288693

URL: http://llvm.org/viewvc/llvm-project?rev=288693&view=rev
Log:
TableGen/AsmMatcherEmitter: Bring sorting check back under EXPENSIVE_CHECKS

Bring the sorting check back that I removed in r288655 but put it under
EXPENSIVE_CHECKS this time. Also document that this the check isn't
purely about having a sorted list but also about operator < having the
correct transitive behavior.

Apply the same to the other check in the file.

Modified:
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=288693&r1=288692&r2=288693&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Mon Dec  5 13:44:31 2016
@@ -1595,15 +1595,15 @@ void AsmMatcherInfo::buildInfo() {
   // Reorder classes so that classes precede super classes.
   Classes.sort();
 
-#ifndef NDEBUG
-  // Verify that the table is now sorted
+#ifdef EXPENSIVE_CHECKS
+  // Verify that the table is sorted and operator < works transitively.
   for (auto I = Classes.begin(), E = Classes.end(); I != E; ++I) {
     for (auto J = I; J != E; ++J) {
       assert(!(*J < *I));
       assert(I == J || !J->isSubsetOf(*I));
     }
   }
-#endif // NDEBUG
+#endif
 }
 
 /// buildInstructionOperandReference - The specified operand is a reference to a
@@ -2719,6 +2719,16 @@ void AsmMatcherEmitter::run(raw_ostream
                       const std::unique_ptr<MatchableInfo> &b){
                      return *a < *b;});
 
+#ifdef EXPENSIVE_CHECKS
+  // Verify that the table is sorted and operator < works transitively.
+  for (auto I = Info.Matchables.begin(), E = Info.Matchables.end(); I != E;
+       ++I) {
+    for (auto J = I; J != E; ++J) {
+      assert(!(**J < **I));
+    }
+  }
+#endif
+
   DEBUG_WITH_TYPE("instruction_info", {
       for (const auto &MI : Info.Matchables)
         MI->dump();




More information about the llvm-commits mailing list