convert an std::sort to array_pod_sort.
authorChris Lattner <sabre@nondot.org>
Mon, 13 Dec 2010 02:00:58 +0000 (02:00 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Dec 2010 02:00:58 +0000 (02:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121669 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 8cc63e603ad3b018518c8583ec37a89296ae6d31..912d1d6352040da51e5fa0b67cfa68369f6047f8 100644 (file)
@@ -29,8 +29,8 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/ADT/STLExtras.h"
 #include <algorithm>
-#include <functional>
 #include <set>
 #include <map>
 using namespace llvm;
@@ -610,6 +610,12 @@ namespace {
   };
 }
 
+static int ConstantIntSortPredicate(const void *P1, const void *P2) {
+  const ConstantInt *LHS = *(const ConstantInt**)P1;
+  const ConstantInt *RHS = *(const ConstantInt**)P2;
+  return LHS->getValue().ult(RHS->getValue());
+}
+
 /// FoldValueComparisonIntoPredecessors - The specified terminator is a value
 /// equality comparison instruction (either a switch or a branch on "X == c").
 /// See if any of the predecessors of the terminator block are value comparisons
@@ -1985,7 +1991,7 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
       if (CompVal) {
         // There might be duplicate constants in the list, which the switch
         // instruction can't handle, remove them now.
-        std::sort(Values.begin(), Values.end(), ConstantIntOrdering());
+        array_pod_sort(Values.begin(), Values.end(), ConstantIntSortPredicate);
         Values.erase(std::unique(Values.begin(), Values.end()), Values.end());
         
         // Figure out which block is which destination.