[llvm-commits] [llvm] r121669 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Chris Lattner sabre at nondot.org
Sun Dec 12 18:00:58 PST 2010


Author: lattner
Date: Sun Dec 12 20:00:58 2010
New Revision: 121669

URL: http://llvm.org/viewvc/llvm-project?rev=121669&view=rev
Log:
convert an std::sort to array_pod_sort.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=121669&r1=121668&r2=121669&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Sun Dec 12 20:00:58 2010
@@ -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 @@
   };
 }
 
+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 @@
       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.





More information about the llvm-commits mailing list