[llvm-commits] [llvm] r80789 - /llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp

Andreas Neustifter astifter-llvm at gmx.at
Wed Sep 2 07:03:12 PDT 2009


Author: astifter
Date: Wed Sep  2 09:03:11 2009
New Revision: 80789

URL: http://llvm.org/viewvc/llvm-project?rev=80789&view=rev
Log:
Sort edges in MaximumSpanningTree more stable in case of equal weight.
(See http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090824/085890.html)

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp?rev=80789&r1=80788&r2=80789&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp Wed Sep  2 09:03:11 2009
@@ -30,7 +30,11 @@
                     const ProfileInfo::EdgeWeight Y) const {
       if (X.second > Y.second) return true;
       if (X.second < Y.second) return false;
-#ifndef NDEBUG
+
+      // It would be enough to just compare the weights of the edges and be
+      // done. With edges of the same weight this may lead to a different MST
+      // each time the MST is created. To have more stable sorting (and thus
+      // more stable MSTs) furhter sort the edges.
       if (X.first.first != 0 && Y.first.first == 0) return true;
       if (X.first.first == 0 && Y.first.first != 0) return false;
       if (X.first.first == 0 && Y.first.first == 0) return false;
@@ -44,7 +48,7 @@
 
       if (X.first.second->size() > Y.first.second->size()) return true;
       if (X.first.second->size() < Y.first.second->size()) return false;
-#endif
+
       return false;
     }
   };





More information about the llvm-commits mailing list