[llvm-commits] [llvm] r165073 - in /llvm/trunk: include/llvm/ADT/SetVector.h lib/Transforms/Scalar/SROA.cpp
Chandler Carruth
chandlerc at gmail.com
Tue Oct 2 17:03:00 PDT 2012
Author: chandlerc
Date: Tue Oct 2 19:03:00 2012
New Revision: 165073
URL: http://llvm.org/viewvc/llvm-project?rev=165073&view=rev
Log:
Switch the SetVector::remove_if implementation to use partition which
preserves the values of the relocated entries, unlikely remove_if. This
allows walking them and erasing them.
Also flesh out the predicate we are using for this to support the
various constraints actually imposed on a UnaryPredicate -- without this
we can't compose it with std::not1.
Thanks to Sean Silva for the review here and noticing the issue with
std::remove_if.
Modified:
llvm/trunk/include/llvm/ADT/SetVector.h
llvm/trunk/lib/Transforms/Scalar/SROA.cpp
Modified: llvm/trunk/include/llvm/ADT/SetVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SetVector.h?rev=165073&r1=165072&r2=165073&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SetVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SetVector.h Tue Oct 2 19:03:00 2012
@@ -141,8 +141,9 @@
/// \returns true if any element is removed.
template <typename UnaryPredicate>
bool remove_if(UnaryPredicate P) {
- typename vector_type::iterator B = std::remove_if(vector_.begin(),
- vector_.end(), P),
+ typename vector_type::iterator B = std::partition(vector_.begin(),
+ vector_.end(),
+ std::not1(P)),
E = vector_.end();
if (B == E)
return false;
Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=165073&r1=165072&r2=165073&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Tue Oct 2 19:03:00 2012
@@ -3273,8 +3273,10 @@
const SetType &Set;
public:
+ typedef AllocaInst *argument_type;
+
IsAllocaInSet(const SetType &Set) : Set(Set) {}
- bool operator()(AllocaInst *AI) { return Set.count(AI); }
+ bool operator()(AllocaInst *AI) const { return Set.count(AI); }
};
}
More information about the llvm-commits
mailing list