aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorAndreas Neustifter <astifter-llvm@gmx.at>2009-09-02 14:03:11 +0000
committerAndreas Neustifter <astifter-llvm@gmx.at>2009-09-02 14:03:11 +0000
commit2252d481d66ddc3462acbd7473d9a1d4702b64ee (patch)
tree48673033ddd3f10d9e64139f6876a9bd89396086 /lib/Transforms
parent8f123b85c63c35d9838d971cd9e62cc8c8082dd5 (diff)
downloadexternal_llvm-2252d481d66ddc3462acbd7473d9a1d4702b64ee.zip
external_llvm-2252d481d66ddc3462acbd7473d9a1d4702b64ee.tar.gz
external_llvm-2252d481d66ddc3462acbd7473d9a1d4702b64ee.tar.bz2
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) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Instrumentation/MaximumSpanningTree.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp b/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
index 80f1a15..ffd100e 100644
--- a/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
+++ b/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
@@ -30,7 +30,11 @@ namespace {
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 @@ namespace {
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;
}
};