diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2012-10-03 00:03:00 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2012-10-03 00:03:00 +0000 |
| commit | 75eac5f0ebff4d0ffe10ce6bc8f2867c5f15315b (patch) | |
| tree | 144f058935a0b1390a75daae8268fbf73a98aa68 | |
| parent | 2b87e06d265e83d61873075e8f8e9c51430ff332 (diff) | |
| download | external_llvm-75eac5f0ebff4d0ffe10ce6bc8f2867c5f15315b.zip external_llvm-75eac5f0ebff4d0ffe10ce6bc8f2867c5f15315b.tar.gz external_llvm-75eac5f0ebff4d0ffe10ce6bc8f2867c5f15315b.tar.bz2 | |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165073 91177308-0d34-0410-b5e6-96231b3b80d8
| -rw-r--r-- | include/llvm/ADT/SetVector.h | 5 | ||||
| -rw-r--r-- | lib/Transforms/Scalar/SROA.cpp | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index e8d63ed..0ff0f46 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -141,8 +141,9 @@ public: /// \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; diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 58c3bc0..316742a 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -3273,8 +3273,10 @@ namespace { 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); } }; } |
