Skip to content

Commit

Permalink
[Analysis, IR, CodeGen] Use llvm::erase_if (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Dec 20, 2020
1 parent 6fa1230 commit 3285ee1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 38 deletions.
6 changes: 3 additions & 3 deletions llvm/include/llvm/IR/PassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1129,9 +1129,9 @@ class OuterAnalysisManagerProxy
for (auto &KeyValuePair : OuterAnalysisInvalidationMap) {
AnalysisKey *OuterID = KeyValuePair.first;
auto &InnerIDs = KeyValuePair.second;
InnerIDs.erase(llvm::remove_if(InnerIDs, [&](AnalysisKey *InnerID) {
return Inv.invalidate(InnerID, IRUnit, PA); }),
InnerIDs.end());
llvm::erase_if(InnerIDs, [&](AnalysisKey *InnerID) {
return Inv.invalidate(InnerID, IRUnit, PA);
});
if (InnerIDs.empty())
DeadKeys.push_back(OuterID);
}
Expand Down
31 changes: 14 additions & 17 deletions llvm/lib/Analysis/CGSCCPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,23 +1039,20 @@ static LazyCallGraph::SCC &updateCGAndAnalysisManagerForPass(
DeadTargets.push_back(&E.getNode());
}
// Remove the easy cases quickly and actually pull them out of our list.
DeadTargets.erase(
llvm::remove_if(DeadTargets,
[&](Node *TargetN) {
SCC &TargetC = *G.lookupSCC(*TargetN);
RefSCC &TargetRC = TargetC.getOuterRefSCC();

// We can't trivially remove internal targets, so skip
// those.
if (&TargetRC == RC)
return false;

RC->removeOutgoingEdge(N, *TargetN);
LLVM_DEBUG(dbgs() << "Deleting outgoing edge from '"
<< N << "' to '" << TargetN << "'\n");
return true;
}),
DeadTargets.end());
llvm::erase_if(DeadTargets, [&](Node *TargetN) {
SCC &TargetC = *G.lookupSCC(*TargetN);
RefSCC &TargetRC = TargetC.getOuterRefSCC();

// We can't trivially remove internal targets, so skip
// those.
if (&TargetRC == RC)
return false;

RC->removeOutgoingEdge(N, *TargetN);
LLVM_DEBUG(dbgs() << "Deleting outgoing edge from '" << N << "' to '"
<< TargetN << "'\n");
return true;
});

// Now do a batch removal of the internal ref edges left.
auto NewRefSCCs = RC->removeInternalRefEdge(N, DeadTargets);
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11620,9 +11620,7 @@ static bool findArrayDimensionsRec(ScalarEvolution &SE,
}

// Remove all SCEVConstants.
Terms.erase(
remove_if(Terms, [](const SCEV *E) { return isa<SCEVConstant>(E); }),
Terms.end());
erase_if(Terms, [](const SCEV *E) { return isa<SCEVConstant>(E); });

if (Terms.size() > 0)
if (!findArrayDimensionsRec(SE, Terms, Sizes))
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1636,9 +1636,7 @@ bool DwarfDebug::buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,

// Remove all values that are no longer live.
size_t Index = std::distance(EB, EI);
auto Last =
remove_if(OpenRanges, [&](OpenRange &R) { return R.first <= Index; });
OpenRanges.erase(Last, OpenRanges.end());
erase_if(OpenRanges, [&](OpenRange &R) { return R.first <= Index; });

// If we are dealing with a clobbering entry, this iteration will result in
// a location list entry starting after the clobbering instruction.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/RDFLiveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ NodeList Liveness::getAllReachingDefs(RegisterRef RefRR,
auto DeadP = [](const NodeAddr<DefNode*> DA) -> bool {
return DA.Addr->getFlags() & NodeAttrs::Dead;
};
RDefs.resize(std::distance(RDefs.begin(), llvm::remove_if(RDefs, DeadP)));
llvm::erase_if(RDefs, DeadP);

return RDefs;
}
Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/CodeGen/StackMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,7 @@ StackMaps::parseRegisterLiveOutMask(const uint32_t *Mask) const {
}
}

LiveOuts.erase(
llvm::remove_if(LiveOuts,
[](const LiveOutReg &LO) { return LO.Reg == 0; }),
LiveOuts.end());
llvm::erase_if(LiveOuts, [](const LiveOutReg &LO) { return LO.Reg == 0; });

return LiveOuts;
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/IR/LLVMContextImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1304,8 +1304,7 @@ class MDAttachments {
///
/// Erases all attachments matching the \c shouldRemove predicate.
template <class PredTy> void remove_if(PredTy shouldRemove) {
Attachments.erase(llvm::remove_if(Attachments, shouldRemove),
Attachments.end());
llvm::erase_if(Attachments, shouldRemove);
}
};

Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/IR/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,11 +1169,10 @@ bool MDAttachments::erase(unsigned ID) {
return true;
}

auto I = std::remove_if(Attachments.begin(), Attachments.end(),
[ID](const Attachment &A) { return A.MDKind == ID; });
bool Changed = I != Attachments.end();
Attachments.erase(I, Attachments.end());
return Changed;
auto OldSize = Attachments.size();
llvm::erase_if(Attachments,
[ID](const Attachment &A) { return A.MDKind == ID; });
return OldSize != Attachments.size();
}

MDNode *Value::getMetadata(unsigned KindID) const {
Expand Down

0 comments on commit 3285ee1

Please sign in to comment.