SROA: Microoptimization: Remove dead entries first, then sort.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 20 Jul 2013 08:38:34 +0000 (08:38 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 20 Jul 2013 08:38:34 +0000 (08:38 +0000)
While there replace an explicit struct with std::mem_fun.

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

lib/Transforms/Scalar/SROA.cpp

index 2c1aef68fbb0a6952063b9d3c6f7c566335ad3bf..021859366590849d3fff9b6923b07db2cfa1965f 100644 (file)
@@ -653,12 +653,6 @@ private:
   }
 };
 
-namespace {
-struct IsSliceDead {
-  bool operator()(const Slice &S) { return S.isDead(); }
-};
-}
-
 AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI)
     :
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
@@ -676,12 +670,13 @@ AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI)
     return;
   }
 
+  Slices.erase(std::remove_if(Slices.begin(), Slices.end(),
+                              std::mem_fun_ref(&Slice::isDead)),
+               Slices.end());
+
   // Sort the uses. This arranges for the offsets to be in ascending order,
   // and the sizes to be in descending order.
   std::sort(Slices.begin(), Slices.end());
-
-  Slices.erase(std::remove_if(Slices.begin(), Slices.end(), IsSliceDead()),
-               Slices.end());
 }
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)