summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation')
-rw-r--r--llvm/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp b/llvm/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
index 80f1a15d632..ffd100e0533 100644
--- a/llvm/lib/Transforms/Instrumentation/MaximumSpanningTree.cpp
+++ b/llvm/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;
}
};
OpenPOWER on IntegriCloud