[llvm] r278475 - Use the range variant of remove_if instead of unpacking begin/end
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 21:32:37 PDT 2016
Author: majnemer
Date: Thu Aug 11 23:32:37 2016
New Revision: 278475
URL: http://llvm.org/viewvc/llvm-project?rev=278475&view=rev
Log:
Use the range variant of remove_if instead of unpacking begin/end
No functionality change is intended.
Modified:
llvm/trunk/include/llvm/ADT/PriorityWorklist.h
llvm/trunk/include/llvm/ADT/SetVector.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
llvm/trunk/lib/CodeGen/LiveInterval.cpp
llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
llvm/trunk/lib/CodeGen/StackMaps.cpp
llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp
llvm/trunk/lib/IR/LLVMContextImpl.h
llvm/trunk/lib/Linker/IRMover.cpp
llvm/trunk/lib/Option/ArgList.cpp
llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp
llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp
llvm/trunk/lib/Target/Hexagon/HexagonGenInsert.cpp
llvm/trunk/lib/Target/Hexagon/HexagonSplitDouble.cpp
llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp
llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/trunk/lib/Transforms/Scalar/SROA.cpp
llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
Modified: llvm/trunk/include/llvm/ADT/PriorityWorklist.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PriorityWorklist.h?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/PriorityWorklist.h (original)
+++ llvm/trunk/include/llvm/ADT/PriorityWorklist.h Thu Aug 11 23:32:37 2016
@@ -147,7 +147,7 @@ public:
/// write it:
///
/// \code
- /// V.erase(std::remove_if(V.begin(), V.end(), P), V.end());
+ /// V.erase(remove_if(V, P), V.end());
/// \endcode
///
/// However, PriorityWorklist doesn't expose non-const iterators, making any
@@ -156,8 +156,8 @@ public:
/// \returns true if any element is removed.
template <typename UnaryPredicate>
bool erase_if(UnaryPredicate P) {
- typename VectorT::iterator E = std::remove_if(
- V.begin(), V.end(), TestAndEraseFromMap<UnaryPredicate>(P, M));
+ typename VectorT::iterator E =
+ remove_if(V, TestAndEraseFromMap<UnaryPredicate>(P, M));
if (E == V.end())
return false;
for (auto I = V.begin(); I != E; ++I)
Modified: llvm/trunk/include/llvm/ADT/SetVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SetVector.h?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SetVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SetVector.h Thu Aug 11 23:32:37 2016
@@ -176,7 +176,7 @@ public:
/// write it:
///
/// \code
- /// V.erase(std::remove_if(V.begin(), V.end(), P), V.end());
+ /// V.erase(remove_if(V, P), V.end());
/// \endcode
///
/// However, SetVector doesn't expose non-const iterators, making any
@@ -185,9 +185,8 @@ public:
/// \returns true if any element is removed.
template <typename UnaryPredicate>
bool remove_if(UnaryPredicate P) {
- typename vector_type::iterator I
- = std::remove_if(vector_.begin(), vector_.end(),
- TestAndEraseFromSet<UnaryPredicate>(P, set_));
+ typename vector_type::iterator I =
+ remove_if(vector_, TestAndEraseFromSet<UnaryPredicate>(P, set_));
if (I == vector_.end())
return false;
vector_.erase(I, vector_.end());
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Aug 11 23:32:37 2016
@@ -9146,10 +9146,9 @@ static bool findArrayDimensionsRec(Scala
}
// Remove all SCEVConstants.
- Terms.erase(std::remove_if(Terms.begin(), Terms.end(), [](const SCEV *E) {
- return isa<SCEVConstant>(E);
- }),
- Terms.end());
+ Terms.erase(
+ remove_if(Terms, [](const SCEV *E) { return isa<SCEVConstant>(E); }),
+ Terms.end());
if (Terms.size() > 0)
if (!findArrayDimensionsRec(SE, Terms, Sizes))
Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Thu Aug 11 23:32:37 2016
@@ -571,7 +571,7 @@ void LiveRange::removeSegment(SlotIndex
/// Also remove the value# from value# list.
void LiveRange::removeValNo(VNInfo *ValNo) {
if (empty()) return;
- segments.erase(std::remove_if(begin(), end(), [ValNo](const Segment &S) {
+ segments.erase(remove_if(*this, [ValNo](const Segment &S) {
return S.valno == ValNo;
}), end());
// Now that ValNo is dead, remove it.
Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Thu Aug 11 23:32:37 2016
@@ -790,10 +790,10 @@ MachineBasicBlock *MachineBlockPlacement
// worklist of already placed entries.
// FIXME: If this shows up on profiles, it could be folded (at the cost of
// some code complexity) into the loop below.
- WorkList.erase(std::remove_if(WorkList.begin(), WorkList.end(),
- [&](MachineBasicBlock *BB) {
- return BlockToChain.lookup(BB) == &Chain;
- }),
+ WorkList.erase(remove_if(WorkList,
+ [&](MachineBasicBlock *BB) {
+ return BlockToChain.lookup(BB) == &Chain;
+ }),
WorkList.end());
if (WorkList.empty())
Modified: llvm/trunk/lib/CodeGen/StackMaps.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackMaps.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackMaps.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackMaps.cpp Thu Aug 11 23:32:37 2016
@@ -272,8 +272,7 @@ StackMaps::parseRegisterLiveOutMask(cons
}
LiveOuts.erase(
- std::remove_if(LiveOuts.begin(), LiveOuts.end(),
- [](const LiveOutReg &LO) { return LO.Reg == 0; }),
+ remove_if(LiveOuts, [](const LiveOutReg &LO) { return LO.Reg == 0; }),
LiveOuts.end());
return LiveOuts;
Modified: llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/SectionMemoryManager.cpp Thu Aug 11 23:32:37 2016
@@ -196,8 +196,8 @@ SectionMemoryManager::applyMemoryGroupPe
// Remove all blocks which are now empty
MemGroup.FreeMem.erase(
- std::remove_if(MemGroup.FreeMem.begin(), MemGroup.FreeMem.end(),
- [](FreeMemBlock &FreeMB) { return FreeMB.Free.size() == 0; }),
+ remove_if(MemGroup.FreeMem,
+ [](FreeMemBlock &FreeMB) { return FreeMB.Free.size() == 0; }),
MemGroup.FreeMem.end());
return std::error_code();
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Thu Aug 11 23:32:37 2016
@@ -998,9 +998,7 @@ public:
///
/// Erases all attachments matching the \c shouldRemove predicate.
template <class PredTy> void remove_if(PredTy shouldRemove) {
- Attachments.erase(
- std::remove_if(Attachments.begin(), Attachments.end(), shouldRemove),
- Attachments.end());
+ Attachments.erase(remove_if(Attachments, shouldRemove), Attachments.end());
}
};
Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Thu Aug 11 23:32:37 2016
@@ -807,15 +807,15 @@ IRLinker::linkAppendingVarProto(GlobalVa
if (IsNewStructor)
SrcElements.erase(
- std::remove_if(SrcElements.begin(), SrcElements.end(),
- [this](Constant *E) {
- auto *Key = dyn_cast<GlobalValue>(
- E->getAggregateElement(2)->stripPointerCasts());
- if (!Key)
- return false;
- GlobalValue *DGV = getLinkedToGlobal(Key);
- return !shouldLink(DGV, *Key);
- }),
+ remove_if(SrcElements,
+ [this](Constant *E) {
+ auto *Key = dyn_cast<GlobalValue>(
+ E->getAggregateElement(2)->stripPointerCasts());
+ if (!Key)
+ return false;
+ GlobalValue *DGV = getLinkedToGlobal(Key);
+ return !shouldLink(DGV, *Key);
+ }),
SrcElements.end());
uint64_t NewSize = DstNumElements + SrcElements.size();
ArrayType *NewType = ArrayType::get(EltTy, NewSize);
Modified: llvm/trunk/lib/Option/ArgList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/ArgList.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Option/ArgList.cpp (original)
+++ llvm/trunk/lib/Option/ArgList.cpp Thu Aug 11 23:32:37 2016
@@ -39,9 +39,9 @@ void ArgList::append(Arg *A) {
}
void ArgList::eraseArg(OptSpecifier Id) {
- Args.erase(std::remove_if(begin(), end(),
- [=](Arg *A) { return A->getOption().matches(Id); }),
- end());
+ Args.erase(
+ remove_if(*this, [=](Arg *A) { return A->getOption().matches(Id); }),
+ end());
}
Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
Modified: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp Thu Aug 11 23:32:37 2016
@@ -1174,8 +1174,7 @@ bool HexagonAsmParser::isLabel(AsmToken
StringRef Raw (String.data(), Third.getString().data() - String.data() +
Third.getString().size());
std::string Collapsed = Raw;
- Collapsed.erase(std::remove_if(Collapsed.begin(), Collapsed.end(), isspace),
- Collapsed.end());
+ Collapsed.erase(remove_if(Collapsed, isspace), Collapsed.end());
StringRef Whole = Collapsed;
std::pair<StringRef, StringRef> DotSplit = Whole.split('.');
if (!matchRegister(DotSplit.first.lower()))
@@ -1219,8 +1218,7 @@ bool HexagonAsmParser::ParseRegister(uns
NeededWorkaround = NeededWorkaround || (Again && !(Contigious && Type));
}
std::string Collapsed = RawString;
- Collapsed.erase(std::remove_if(Collapsed.begin(), Collapsed.end(), isspace),
- Collapsed.end());
+ Collapsed.erase(remove_if(Collapsed, isspace), Collapsed.end());
StringRef FullString = Collapsed;
std::pair<StringRef, StringRef> DotSplit = FullString.split('.');
unsigned DotReg = matchRegister(DotSplit.first.lower());
Modified: llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonCommonGEP.cpp Thu Aug 11 23:32:37 2016
@@ -639,8 +639,7 @@ void HexagonCommonGEP::common() {
// Node for removal.
Erase.insert(*I);
}
- NodeVect::iterator NewE = std::remove_if(Nodes.begin(), Nodes.end(),
- in_set(Erase));
+ NodeVect::iterator NewE = remove_if(Nodes, in_set(Erase));
Nodes.resize(std::distance(Nodes.begin(), NewE));
DEBUG(dbgs() << "Gep nodes after post-commoning cleanup:\n" << Nodes);
Modified: llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonExpandCondsets.cpp Thu Aug 11 23:32:37 2016
@@ -398,8 +398,7 @@ void HexagonExpandCondsets::removeImpDef
return S.start.isRegister() &&
LocalImpDefs.count(LIS->getInstructionFromIndex(S.start));
};
- Range.segments.erase(std::remove_if(Range.begin(), Range.end(), StartImpDef),
- Range.end());
+ Range.segments.erase(remove_if(Range, StartImpDef), Range.end());
}
void HexagonExpandCondsets::updateDeadsInRange(unsigned Reg, LaneBitmask LM,
Modified: llvm/trunk/lib/Target/Hexagon/HexagonGenInsert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonGenInsert.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonGenInsert.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonGenInsert.cpp Thu Aug 11 23:32:37 2016
@@ -1052,7 +1052,7 @@ void HexagonGenInsert::pruneCoveredSets(
auto IsEmpty = [] (const IFRecordWithRegSet &IR) -> bool {
return IR.second.empty();
};
- auto End = std::remove_if(LL.begin(), LL.end(), IsEmpty);
+ auto End = remove_if(LL, IsEmpty);
if (End != LL.end())
LL.erase(End, LL.end());
} else {
@@ -1144,7 +1144,7 @@ void HexagonGenInsert::pruneRegCopies(un
auto IsCopy = [] (const IFRecordWithRegSet &IR) -> bool {
return IR.first.Wdh == 32 && (IR.first.Off == 0 || IR.first.Off == 32);
};
- auto End = std::remove_if(LL.begin(), LL.end(), IsCopy);
+ auto End = remove_if(LL, IsCopy);
if (End != LL.end())
LL.erase(End, LL.end());
}
Modified: llvm/trunk/lib/Target/Hexagon/HexagonSplitDouble.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonSplitDouble.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonSplitDouble.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonSplitDouble.cpp Thu Aug 11 23:32:37 2016
@@ -510,7 +510,7 @@ void HexagonSplitDoubleRegs::collectIndR
}
return true;
};
- UVect::iterator End = std::remove_if(DP.begin(), DP.end(), NoIndOp);
+ UVect::iterator End = remove_if(DP, NoIndOp);
Rs.insert(DP.begin(), End);
Rs.insert(CmpR1);
Rs.insert(CmpR2);
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Thu Aug 11 23:32:37 2016
@@ -1886,8 +1886,7 @@ class BitPermutationSelector {
}
void eraseMatchingBitGroups(function_ref<bool(const BitGroup &)> F) {
- BitGroups.erase(std::remove_if(BitGroups.begin(), BitGroups.end(), F),
- BitGroups.end());
+ BitGroups.erase(remove_if(BitGroups, F), BitGroups.end());
}
SmallVector<ValueBit, 64> Bits;
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp Thu Aug 11 23:32:37 2016
@@ -205,7 +205,7 @@ static std::string getSignature(Function
if (FTy->isVarArg())
OS << "_...";
Sig = OS.str();
- Sig.erase(std::remove_if(Sig.begin(), Sig.end(), isspace), Sig.end());
+ Sig.erase(remove_if(Sig, isspace), Sig.end());
// When s2wasm parses .s file, a comma means the end of an argument. So a
// mangled function name can contain any character but a comma.
std::replace(Sig.begin(), Sig.end(), ',', '.');
Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Thu Aug 11 23:32:37 2016
@@ -1740,9 +1740,8 @@ static void relocationViaAlloca(
/// tests in ways which make them less useful in testing fused safepoints.
template <typename T> static void unique_unsorted(SmallVectorImpl<T> &Vec) {
SmallSet<T, 8> Seen;
- Vec.erase(std::remove_if(Vec.begin(), Vec.end(), [&](const T &V) {
- return !Seen.insert(V).second;
- }), Vec.end());
+ Vec.erase(remove_if(Vec, [&](const T &V) { return !Seen.insert(V).second; }),
+ Vec.end());
}
/// Insert holders so that each Value is obviously live through the entire
Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Thu Aug 11 23:32:37 2016
@@ -995,10 +995,7 @@ AllocaSlices::AllocaSlices(const DataLay
return;
}
- Slices.erase(std::remove_if(Slices.begin(), Slices.end(),
- [](const Slice &S) {
- return S.isDead();
- }),
+ Slices.erase(remove_if(Slices, [](const Slice &S) { return S.isDead(); }),
Slices.end());
#ifndef NDEBUG
@@ -1814,10 +1811,10 @@ static VectorType *isVectorPromotionViab
// do that until all the backends are known to produce good code for all
// integer vector types.
if (!HaveCommonEltTy) {
- CandidateTys.erase(std::remove_if(CandidateTys.begin(), CandidateTys.end(),
- [](VectorType *VTy) {
- return !VTy->getElementType()->isIntegerTy();
- }),
+ CandidateTys.erase(remove_if(CandidateTys,
+ [](VectorType *VTy) {
+ return !VTy->getElementType()->isIntegerTy();
+ }),
CandidateTys.end());
// If there were no integer vector types, give up.
@@ -3461,63 +3458,60 @@ bool SROA::presplitLoadsAndStores(Alloca
// match relative to their starting offset. We have to verify this prior to
// any rewriting.
Stores.erase(
- std::remove_if(Stores.begin(), Stores.end(),
- [&UnsplittableLoads, &SplitOffsetsMap](StoreInst *SI) {
- // Lookup the load we are storing in our map of split
- // offsets.
- auto *LI = cast<LoadInst>(SI->getValueOperand());
- // If it was completely unsplittable, then we're done,
- // and this store can't be pre-split.
- if (UnsplittableLoads.count(LI))
- return true;
-
- auto LoadOffsetsI = SplitOffsetsMap.find(LI);
- if (LoadOffsetsI == SplitOffsetsMap.end())
- return false; // Unrelated loads are definitely safe.
- auto &LoadOffsets = LoadOffsetsI->second;
-
- // Now lookup the store's offsets.
- auto &StoreOffsets = SplitOffsetsMap[SI];
-
- // If the relative offsets of each split in the load and
- // store match exactly, then we can split them and we
- // don't need to remove them here.
- if (LoadOffsets.Splits == StoreOffsets.Splits)
- return false;
-
- DEBUG(dbgs()
- << " Mismatched splits for load and store:\n"
- << " " << *LI << "\n"
- << " " << *SI << "\n");
-
- // We've found a store and load that we need to split
- // with mismatched relative splits. Just give up on them
- // and remove both instructions from our list of
- // candidates.
- UnsplittableLoads.insert(LI);
- return true;
- }),
+ remove_if(Stores,
+ [&UnsplittableLoads, &SplitOffsetsMap](StoreInst *SI) {
+ // Lookup the load we are storing in our map of split
+ // offsets.
+ auto *LI = cast<LoadInst>(SI->getValueOperand());
+ // If it was completely unsplittable, then we're done,
+ // and this store can't be pre-split.
+ if (UnsplittableLoads.count(LI))
+ return true;
+
+ auto LoadOffsetsI = SplitOffsetsMap.find(LI);
+ if (LoadOffsetsI == SplitOffsetsMap.end())
+ return false; // Unrelated loads are definitely safe.
+ auto &LoadOffsets = LoadOffsetsI->second;
+
+ // Now lookup the store's offsets.
+ auto &StoreOffsets = SplitOffsetsMap[SI];
+
+ // If the relative offsets of each split in the load and
+ // store match exactly, then we can split them and we
+ // don't need to remove them here.
+ if (LoadOffsets.Splits == StoreOffsets.Splits)
+ return false;
+
+ DEBUG(dbgs() << " Mismatched splits for load and store:\n"
+ << " " << *LI << "\n"
+ << " " << *SI << "\n");
+
+ // We've found a store and load that we need to split
+ // with mismatched relative splits. Just give up on them
+ // and remove both instructions from our list of
+ // candidates.
+ UnsplittableLoads.insert(LI);
+ return true;
+ }),
Stores.end());
// Now we have to go *back* through all the stores, because a later store may
// have caused an earlier store's load to become unsplittable and if it is
// unsplittable for the later store, then we can't rely on it being split in
// the earlier store either.
- Stores.erase(std::remove_if(Stores.begin(), Stores.end(),
- [&UnsplittableLoads](StoreInst *SI) {
- auto *LI =
- cast<LoadInst>(SI->getValueOperand());
- return UnsplittableLoads.count(LI);
- }),
+ Stores.erase(remove_if(Stores,
+ [&UnsplittableLoads](StoreInst *SI) {
+ auto *LI = cast<LoadInst>(SI->getValueOperand());
+ return UnsplittableLoads.count(LI);
+ }),
Stores.end());
// Once we've established all the loads that can't be split for some reason,
// filter any that made it into our list out.
- Loads.erase(std::remove_if(Loads.begin(), Loads.end(),
- [&UnsplittableLoads](LoadInst *LI) {
- return UnsplittableLoads.count(LI);
- }),
+ Loads.erase(remove_if(Loads,
+ [&UnsplittableLoads](LoadInst *LI) {
+ return UnsplittableLoads.count(LI);
+ }),
Loads.end());
-
// If no loads or stores are left, there is no pre-splitting to be done for
// this alloca.
if (Loads.empty() && Stores.empty())
@@ -3775,9 +3769,7 @@ bool SROA::presplitLoadsAndStores(Alloca
}
// Remove the killed slices that have ben pre-split.
- AS.erase(std::remove_if(AS.begin(), AS.end(), [](const Slice &S) {
- return S.isDead();
- }), AS.end());
+ AS.erase(remove_if(AS, [](const Slice &S) { return S.isDead(); }), AS.end());
// Insert our new slices. This will sort and merge them into the sorted
// sequence.
@@ -3792,8 +3784,8 @@ bool SROA::presplitLoadsAndStores(Alloca
// Finally, don't try to promote any allocas that new require re-splitting.
// They have already been added to the worklist above.
PromotableAllocas.erase(
- std::remove_if(
- PromotableAllocas.begin(), PromotableAllocas.end(),
+ remove_if(
+ PromotableAllocas,
[&](AllocaInst *AI) { return ResplitPromotableAllocas.count(AI); }),
PromotableAllocas.end());
@@ -4228,9 +4220,7 @@ PreservedAnalyses SROA::runImpl(Function
auto IsInSet = [&](AllocaInst *AI) { return DeletedAllocas.count(AI); };
Worklist.remove_if(IsInSet);
PostPromotionWorklist.remove_if(IsInSet);
- PromotableAllocas.erase(std::remove_if(PromotableAllocas.begin(),
- PromotableAllocas.end(),
- IsInSet),
+ PromotableAllocas.erase(remove_if(PromotableAllocas, IsInSet),
PromotableAllocas.end());
DeletedAllocas.clear();
}
Modified: llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp Thu Aug 11 23:32:37 2016
@@ -478,10 +478,10 @@ void LowerSwitch::processSwitchInst(Swit
// cases.
assert(MaxPop > 0 && PopSucc);
Default = PopSucc;
- Cases.erase(std::remove_if(
- Cases.begin(), Cases.end(),
- [PopSucc](const CaseRange &R) { return R.BB == PopSucc; }),
- Cases.end());
+ Cases.erase(
+ remove_if(Cases,
+ [PopSucc](const CaseRange &R) { return R.BB == PopSucc; }),
+ Cases.end());
// If there are no cases left, just branch.
if (Cases.empty()) {
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Thu Aug 11 23:32:37 2016
@@ -450,10 +450,8 @@ void AsmWriterEmitter::EmitPrintInstruct
}
// Okay, delete instructions with no operand info left.
- auto I = std::remove_if(Instructions.begin(), Instructions.end(),
- [](AsmWriterInst &Inst) {
- return Inst.Operands.empty();
- });
+ auto I = remove_if(Instructions,
+ [](AsmWriterInst &Inst) { return Inst.Operands.empty(); });
Instructions.erase(I, Instructions.end());
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=278475&r1=278474&r2=278475&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Thu Aug 11 23:32:37 2016
@@ -239,8 +239,7 @@ bool EEVT::TypeSet::EnforceInteger(TreeP
TypeSet InputSet(*this);
// Filter out all the fp types.
- TypeVec.erase(std::remove_if(TypeVec.begin(), TypeVec.end(),
- std::not1(std::ptr_fun(isInteger))),
+ TypeVec.erase(remove_if(TypeVec, std::not1(std::ptr_fun(isInteger))),
TypeVec.end());
if (TypeVec.empty()) {
@@ -265,8 +264,7 @@ bool EEVT::TypeSet::EnforceFloatingPoint
TypeSet InputSet(*this);
// Filter out all the integer types.
- TypeVec.erase(std::remove_if(TypeVec.begin(), TypeVec.end(),
- std::not1(std::ptr_fun(isFloatingPoint))),
+ TypeVec.erase(remove_if(TypeVec, std::not1(std::ptr_fun(isFloatingPoint))),
TypeVec.end());
if (TypeVec.empty()) {
@@ -292,8 +290,7 @@ bool EEVT::TypeSet::EnforceScalar(TreePa
TypeSet InputSet(*this);
// Filter out all the vector types.
- TypeVec.erase(std::remove_if(TypeVec.begin(), TypeVec.end(),
- std::not1(std::ptr_fun(isScalar))),
+ TypeVec.erase(remove_if(TypeVec, std::not1(std::ptr_fun(isScalar))),
TypeVec.end());
if (TypeVec.empty()) {
@@ -317,8 +314,7 @@ bool EEVT::TypeSet::EnforceVector(TreePa
bool MadeChange = false;
// Filter out all the scalar types.
- TypeVec.erase(std::remove_if(TypeVec.begin(), TypeVec.end(),
- std::not1(std::ptr_fun(isVector))),
+ TypeVec.erase(remove_if(TypeVec, std::not1(std::ptr_fun(isVector))),
TypeVec.end());
if (TypeVec.empty()) {
@@ -395,16 +391,15 @@ bool EEVT::TypeSet::EnforceSmallerThan(E
A.getSizeInBits() < B.getSizeInBits());
});
- auto I = std::remove_if(Other.TypeVec.begin(), Other.TypeVec.end(),
- [Smallest](MVT OtherVT) {
- // Don't compare vector and non-vector types.
- if (OtherVT.isVector() != Smallest.isVector())
- return false;
- // The getSizeInBits() check here is only needed for vectors, but is
- // a subset of the scalar check for scalars so no need to qualify.
- return OtherVT.getScalarSizeInBits() <= Smallest.getScalarSizeInBits()||
- OtherVT.getSizeInBits() < Smallest.getSizeInBits();
- });
+ auto I = remove_if(Other.TypeVec, [Smallest](MVT OtherVT) {
+ // Don't compare vector and non-vector types.
+ if (OtherVT.isVector() != Smallest.isVector())
+ return false;
+ // The getSizeInBits() check here is only needed for vectors, but is
+ // a subset of the scalar check for scalars so no need to qualify.
+ return OtherVT.getScalarSizeInBits() <= Smallest.getScalarSizeInBits() ||
+ OtherVT.getSizeInBits() < Smallest.getSizeInBits();
+ });
MadeChange |= I != Other.TypeVec.end(); // If we're about to remove types.
Other.TypeVec.erase(I, Other.TypeVec.end());
@@ -428,14 +423,13 @@ bool EEVT::TypeSet::EnforceSmallerThan(E
(A.getScalarSizeInBits() == B.getScalarSizeInBits() &&
A.getSizeInBits() < B.getSizeInBits());
});
- auto I = std::remove_if(TypeVec.begin(), TypeVec.end(),
- [Largest](MVT OtherVT) {
- // Don't compare vector and non-vector types.
- if (OtherVT.isVector() != Largest.isVector())
- return false;
- return OtherVT.getScalarSizeInBits() >= Largest.getScalarSizeInBits() ||
- OtherVT.getSizeInBits() > Largest.getSizeInBits();
- });
+ auto I = remove_if(TypeVec, [Largest](MVT OtherVT) {
+ // Don't compare vector and non-vector types.
+ if (OtherVT.isVector() != Largest.isVector())
+ return false;
+ return OtherVT.getScalarSizeInBits() >= Largest.getScalarSizeInBits() ||
+ OtherVT.getSizeInBits() > Largest.getSizeInBits();
+ });
MadeChange |= I != TypeVec.end(); // If we're about to remove types.
TypeVec.erase(I, TypeVec.end());
@@ -460,10 +454,9 @@ bool EEVT::TypeSet::EnforceVectorEltType
TypeSet InputSet(*this);
// Filter out all the types which don't have the right element type.
- auto I = std::remove_if(TypeVec.begin(), TypeVec.end(),
- [VT](MVT VVT) {
- return VVT.getVectorElementType().SimpleTy != VT;
- });
+ auto I = remove_if(TypeVec, [VT](MVT VVT) {
+ return VVT.getVectorElementType().SimpleTy != VT;
+ });
MadeChange |= I != TypeVec.end();
TypeVec.erase(I, TypeVec.end());
@@ -547,10 +540,9 @@ bool EEVT::TypeSet::EnforceVectorSubVect
// Only keep types that have less elements than VTOperand.
TypeSet InputSet(VTOperand);
- auto I = std::remove_if(VTOperand.TypeVec.begin(), VTOperand.TypeVec.end(),
- [NumElems](MVT VVT) {
- return VVT.getVectorNumElements() >= NumElems;
- });
+ auto I = remove_if(VTOperand.TypeVec, [NumElems](MVT VVT) {
+ return VVT.getVectorNumElements() >= NumElems;
+ });
MadeChange |= I != VTOperand.TypeVec.end();
VTOperand.TypeVec.erase(I, VTOperand.TypeVec.end());
@@ -571,10 +563,9 @@ bool EEVT::TypeSet::EnforceVectorSubVect
// Only keep types that have more elements than 'this'.
TypeSet InputSet(*this);
- auto I = std::remove_if(TypeVec.begin(), TypeVec.end(),
- [NumElems](MVT VVT) {
- return VVT.getVectorNumElements() <= NumElems;
- });
+ auto I = remove_if(TypeVec, [NumElems](MVT VVT) {
+ return VVT.getVectorNumElements() <= NumElems;
+ });
MadeChange |= I != TypeVec.end();
TypeVec.erase(I, TypeVec.end());
@@ -609,10 +600,9 @@ bool EEVT::TypeSet::EnforceVectorSameNum
// Only keep types that have same elements as 'this'.
TypeSet InputSet(VTOperand);
- auto I = std::remove_if(VTOperand.TypeVec.begin(), VTOperand.TypeVec.end(),
- [NumElems](MVT VVT) {
- return VVT.getVectorNumElements() != NumElems;
- });
+ auto I = remove_if(VTOperand.TypeVec, [NumElems](MVT VVT) {
+ return VVT.getVectorNumElements() != NumElems;
+ });
MadeChange |= I != VTOperand.TypeVec.end();
VTOperand.TypeVec.erase(I, VTOperand.TypeVec.end());
@@ -629,10 +619,9 @@ bool EEVT::TypeSet::EnforceVectorSameNum
// Only keep types that have same elements as VTOperand.
TypeSet InputSet(*this);
- auto I = std::remove_if(TypeVec.begin(), TypeVec.end(),
- [NumElems](MVT VVT) {
- return VVT.getVectorNumElements() != NumElems;
- });
+ auto I = remove_if(TypeVec, [NumElems](MVT VVT) {
+ return VVT.getVectorNumElements() != NumElems;
+ });
MadeChange |= I != TypeVec.end();
TypeVec.erase(I, TypeVec.end());
@@ -663,10 +652,8 @@ bool EEVT::TypeSet::EnforceSameSize(EEVT
// Only keep types that have the same size as 'this'.
TypeSet InputSet(VTOperand);
- auto I = std::remove_if(VTOperand.TypeVec.begin(), VTOperand.TypeVec.end(),
- [&](MVT VT) {
- return VT.getSizeInBits() != Size;
- });
+ auto I = remove_if(VTOperand.TypeVec,
+ [&](MVT VT) { return VT.getSizeInBits() != Size; });
MadeChange |= I != VTOperand.TypeVec.end();
VTOperand.TypeVec.erase(I, VTOperand.TypeVec.end());
@@ -683,10 +670,8 @@ bool EEVT::TypeSet::EnforceSameSize(EEVT
// Only keep types that have the same size as VTOperand.
TypeSet InputSet(*this);
- auto I = std::remove_if(TypeVec.begin(), TypeVec.end(),
- [&](MVT VT) {
- return VT.getSizeInBits() != Size;
- });
+ auto I =
+ remove_if(TypeVec, [&](MVT VT) { return VT.getSizeInBits() != Size; });
MadeChange |= I != TypeVec.end();
TypeVec.erase(I, TypeVec.end());
More information about the llvm-commits
mailing list