From: Richard Trieu Date: Fri, 4 Jan 2019 06:49:24 +0000 (+0000) Subject: [WebAssembly] Split the checking from the sorting logic. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0537adb23571b48621632117bcba3eebf8bc59a;p=llvm [WebAssembly] Split the checking from the sorting logic. 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 --- diff --git a/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp b/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp index a3a256d63f2..108f2879a07 100644 --- a/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp +++ b/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp @@ -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);