[llvm] r186761 - SROA: Microoptimization: Remove dead entries first, then sort.

Benjamin Kramer benny.kra at googlemail.com
Sat Jul 20 01:38:35 PDT 2013


Author: d0k
Date: Sat Jul 20 03:38:34 2013
New Revision: 186761

URL: http://llvm.org/viewvc/llvm-project?rev=186761&view=rev
Log:
SROA: Microoptimization: Remove dead entries first, then sort.

While there replace an explicit struct with std::mem_fun.

Modified:
    llvm/trunk/lib/Transforms/Scalar/SROA.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=186761&r1=186760&r2=186761&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Sat Jul 20 03:38:34 2013
@@ -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 DataLay
     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)





More information about the llvm-commits mailing list