[COFF] Stabilize sort
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 28 Mar 2020 20:38:50 +0000 (21:38 +0100)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 28 Mar 2020 20:38:50 +0000 (21:38 +0100)
Found by llvm::sort's expensive checks.

lld/COFF/PDB.cpp

index 3754bd0..8ecfdca 100644 (file)
@@ -1385,6 +1385,8 @@ void PDBLinker::printStats() {
       TypeIndex typeIndex;
       uint64_t totalInputSize() const { return uint64_t(dupCount) * typeSize; }
       bool operator<(const TypeSizeInfo &rhs) const {
+        if (totalInputSize() == rhs.totalInputSize())
+          return typeIndex < rhs.typeIndex;
         return totalInputSize() < rhs.totalInputSize();
       }
     };