MergeFunc: Quick fix for r245140, Ignore second, aka Function*, in sorting.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 16 Aug 2015 02:41:23 +0000 (02:41 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 16 Aug 2015 02:41:23 +0000 (02:41 +0000)
Don't assume second would be ordered in the module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245168 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/MergeFunctions.cpp

index 1c9d2170f92b41aae2e1e82f2b05de160bc4782c..67d6b7fcb674b47e78d4df51f22ca0b0172eca7b 100644 (file)
@@ -1316,7 +1316,12 @@ bool MergeFunctions::runOnModule(Module &M) {
     } 
   }
 
-  std::sort(HashedFuncs.begin(), HashedFuncs.end());
+  std::stable_sort(
+      HashedFuncs.begin(), HashedFuncs.end(),
+      [](const std::pair<FunctionComparator::FunctionHash, Function *> &a,
+         const std::pair<FunctionComparator::FunctionHash, Function *> &b) {
+        return a.first < b.first;
+      });
 
   auto S = HashedFuncs.begin();
   for (auto I = HashedFuncs.begin(), IE = HashedFuncs.end(); I != IE; ++I) {