Skip to content

Commit 8568ca7

Browse files
Use llvm::erase_if (NFC)
1 parent 62627c7 commit 8568ca7

File tree

8 files changed

+21
-43
lines changed

8 files changed

+21
-43
lines changed

Diff for: lld/COFF/Writer.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -1090,18 +1090,14 @@ void Writer::removeUnusedSections() {
10901090
// later. Only remove sections that have no Chunks at all.
10911091
return s->chunks.empty();
10921092
};
1093-
ctx.outputSections.erase(std::remove_if(ctx.outputSections.begin(),
1094-
ctx.outputSections.end(), isUnused),
1095-
ctx.outputSections.end());
1093+
llvm::erase_if(ctx.outputSections, isUnused);
10961094
}
10971095

10981096
// The Windows loader doesn't seem to like empty sections,
10991097
// so we remove them if any.
11001098
void Writer::removeEmptySections() {
11011099
auto isEmpty = [](OutputSection *s) { return s->getVirtualSize() == 0; };
1102-
ctx.outputSections.erase(std::remove_if(ctx.outputSections.begin(),
1103-
ctx.outputSections.end(), isEmpty),
1104-
ctx.outputSections.end());
1100+
llvm::erase_if(ctx.outputSections, isEmpty);
11051101
}
11061102

11071103
void Writer::assignOutputSectionIndices() {

Diff for: lld/lib/Core/Resolver.cpp

+8-15
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,9 @@ void Resolver::deadStripOptimize() {
380380
markLive(dsrAtom);
381381

382382
// now remove all non-live atoms from _atoms
383-
_atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(),
384-
[&](OwningAtomPtr<Atom> &a) {
385-
return _liveAtoms.count(a.get()) == 0;
386-
}),
387-
_atoms.end());
383+
llvm::erase_if(_atoms, [&](OwningAtomPtr<Atom> &a) {
384+
return _liveAtoms.count(a.get()) == 0;
385+
});
388386
}
389387

390388
// error out if some undefines remain
@@ -396,10 +394,8 @@ bool Resolver::checkUndefines() {
396394
std::vector<const UndefinedAtom *> undefinedAtoms = _symbolTable.undefines();
397395
if (_ctx.deadStrip()) {
398396
// When dead code stripping, we don't care if dead atoms are undefined.
399-
undefinedAtoms.erase(
400-
std::remove_if(undefinedAtoms.begin(), undefinedAtoms.end(),
401-
[&](const Atom *a) { return _liveAtoms.count(a) == 0; }),
402-
undefinedAtoms.end());
397+
llvm::erase_if(undefinedAtoms,
398+
[&](const Atom *a) { return _liveAtoms.count(a) == 0; });
403399
}
404400

405401
if (undefinedAtoms.empty())
@@ -440,12 +436,9 @@ void Resolver::removeCoalescedAwayAtoms() {
440436
DEBUG_WITH_TYPE("resolver",
441437
llvm::dbgs() << "******** Removing coalesced away atoms:\n");
442438
ScopedTask task(getDefaultDomain(), "removeCoalescedAwayAtoms");
443-
_atoms.erase(std::remove_if(_atoms.begin(), _atoms.end(),
444-
[&](OwningAtomPtr<Atom> &a) {
445-
return _symbolTable.isCoalescedAway(a.get()) ||
446-
_deadAtoms.count(a.get());
447-
}),
448-
_atoms.end());
439+
llvm::erase_if(_atoms, [&](OwningAtomPtr<Atom> &a) {
440+
return _symbolTable.isCoalescedAway(a.get()) || _deadAtoms.count(a.get());
441+
});
449442
}
450443

451444
bool Resolver::resolve() {

Diff for: lldb/source/Breakpoint/BreakpointList.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ void BreakpointList::RemoveAllowed(bool notify) {
101101
NotifyChange(bp_sp, eBreakpointEventTypeRemoved);
102102
}
103103

104-
m_breakpoints.erase(
105-
std::remove_if(m_breakpoints.begin(), m_breakpoints.end(),
106-
[&](const BreakpointSP &bp) { return bp->AllowDelete(); }),
107-
m_breakpoints.end());
104+
llvm::erase_if(m_breakpoints,
105+
[&](const BreakpointSP &bp) { return bp->AllowDelete(); });
108106
}
109107

110108
BreakpointList::bp_collection::iterator

Diff for: llvm/include/llvm/Analysis/InlineOrder.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
160160
auto PredWrapper = [=](HeapT P) -> bool {
161161
return Pred(std::make_pair(P.first, 0));
162162
};
163-
Heap.erase(std::remove_if(Heap.begin(), Heap.end(), PredWrapper),
164-
Heap.end());
163+
llvm::erase_if(Heap, PredWrapper);
165164
std::make_heap(Heap.begin(), Heap.end(), cmp);
166165
}
167166

Diff for: llvm/lib/CodeGen/LiveInterval.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,8 @@ void LiveRange::removeSegment(SlotIndex Start, SlotIndex End,
631631
/// Also remove the value# from value# list.
632632
void LiveRange::removeValNo(VNInfo *ValNo) {
633633
if (empty()) return;
634-
segments.erase(remove_if(*this, [ValNo](const Segment &S) {
635-
return S.valno == ValNo;
636-
}), end());
634+
llvm::erase_if(segments,
635+
[ValNo](const Segment &S) { return S.valno == ValNo; });
637636
// Now that ValNo is dead, remove it.
638637
markValNoForDeletion(ValNo);
639638
}

Diff for: llvm/lib/Target/AMDGPU/AMDGPUReplaceLDSUseWithPointer.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,9 @@ class ReplaceLDSUseImpl {
130130
std::vector<GlobalVariable *> LDSGlobals = AMDGPU::findVariablesToLower(M);
131131

132132
// Remove LDS which don't qualify for replacement.
133-
LDSGlobals.erase(std::remove_if(LDSGlobals.begin(), LDSGlobals.end(),
134-
[&](GlobalVariable *GV) {
135-
return shouldIgnorePointerReplacement(GV);
136-
}),
137-
LDSGlobals.end());
133+
llvm::erase_if(LDSGlobals, [&](GlobalVariable *GV) {
134+
return shouldIgnorePointerReplacement(GV);
135+
});
138136

139137
return LDSGlobals;
140138
}

Diff for: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -2027,12 +2027,8 @@ SDValue WebAssemblyTargetLowering::LowerBUILD_VECTOR(SDValue Op,
20272027
size_t NumShuffleLanes = 0;
20282028
if (ShuffleCounts.size()) {
20292029
std::tie(ShuffleSrc1, NumShuffleLanes) = GetMostCommon(ShuffleCounts);
2030-
ShuffleCounts.erase(std::remove_if(ShuffleCounts.begin(),
2031-
ShuffleCounts.end(),
2032-
[&](const auto &Pair) {
2033-
return Pair.first == ShuffleSrc1;
2034-
}),
2035-
ShuffleCounts.end());
2030+
llvm::erase_if(ShuffleCounts,
2031+
[&](const auto &Pair) { return Pair.first == ShuffleSrc1; });
20362032
}
20372033
if (ShuffleCounts.size()) {
20382034
size_t AdditionalShuffleLanes;

Diff for: polly/lib/Analysis/ScopInfo.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,7 @@ void ScopStmt::removeMemoryAccess(MemoryAccess *MA) {
13031303
Parent.removeAccessData(MA);
13041304
}
13051305
}
1306-
MemAccs.erase(std::remove_if(MemAccs.begin(), MemAccs.end(), Predicate),
1307-
MemAccs.end());
1306+
llvm::erase_if(MemAccs, Predicate);
13081307
InstructionToAccess.erase(MA->getAccessInstruction());
13091308
}
13101309

0 commit comments

Comments
 (0)