]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Split the checking from the sorting logic.
authorRichard Trieu <rtrieu@google.com>
Fri, 4 Jan 2019 06:49:24 +0000 (06:49 +0000)
committerRichard Trieu <rtrieu@google.com>
Fri, 4 Jan 2019 06:49:24 +0000 (06:49 +0000)
Move the check for -1 and identical values outside the vector sorting code.
Compare functions need to be able to compare identical elements to be
conforming.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350379 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp

index a3a256d63f2e6097a6e1b1dd1fef9e457ec30a64..108f2879a071765174a0eb9a5c17339fb0adef9d 100644 (file)
@@ -250,11 +250,22 @@ bool LoopFixer::run() {
              [&](const MachineBasicBlock *A, const MachineBasicBlock *B) {
                auto ANum = A->getNumber();
                auto BNum = B->getNumber();
-               assert(ANum != -1 && BNum != -1);
-               assert(ANum != BNum);
                return ANum < BNum;
              });
 
+#ifndef NDEBUG
+  for (auto Block : SortedEntries)
+    assert(Block->getNumber() != -1);
+  if (SortedEntries.size() > 1) {
+    for (auto I = SortedEntries.begin(), E = SortedEntries.end() - 1;
+         I != E; ++I) {
+      auto ANum = (*I)->getNumber();
+      auto BNum = (*(std::next(I)))->getNumber();
+      assert(ANum != BNum);
+    }
+  }
+#endif
+
   // Create a dispatch block which will contain a jump table to the entries.
   MachineBasicBlock *Dispatch = MF.CreateMachineBasicBlock();
   MF.insert(MF.end(), Dispatch);