aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2019-01-04 06:49:24 +0000
committerRichard Trieu <rtrieu@google.com>2019-01-04 06:49:24 +0000
commite1fef949aea5918dfb802620972f423ca0d5c97f (patch)
treebebd6cc19bf4e093f2a258d5e9b4d2f2eca43eff /llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
parent47beee2f3ffa2ae980b5a64e5a5bc21c7d15f30a (diff)
downloadllvm-e1fef949aea5918dfb802620972f423ca0d5c97f.zip
llvm-e1fef949aea5918dfb802620972f423ca0d5c97f.tar.gz
llvm-e1fef949aea5918dfb802620972f423ca0d5c97f.tar.bz2
[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. llvm-svn: 350379
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
index a3a256d..108f287 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
+++ b/llvm/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);