[mlir][IRNumbering] Fix the dialect comparator to be strict
authorRiver Riddle <riddleriver@gmail.com>
Wed, 8 Feb 2023 01:37:00 +0000 (17:37 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Wed, 8 Feb 2023 02:06:34 +0000 (18:06 -0800)
Check if rhs is the dialect to be ordered first, ensuring that
we don't inadvertantly order something before it by
falling back to pure number comparison.

This only shows up depending on the implementation of
stable_sort. This was hit in a build of MSVC that was
checking for strict ordering.

mlir/lib/Bytecode/Writer/IRNumbering.cpp

index cf9be57..1ae9c92 100644 (file)
@@ -63,6 +63,8 @@ static void groupByDialectPerByte(T range) {
                           const auto &rhs) {
     if (lhs->dialect->number == dialectToOrderFirst)
       return rhs->dialect->number != dialectToOrderFirst;
+    if (rhs->dialect->number == dialectToOrderFirst)
+      return false;
     return lhs->dialect->number < rhs->dialect->number;
   };