mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 06:46:43 +00:00
[llvm] Use llvm::unique (NFC) (#95628)
This commit is contained in:
parent
bb3091a6f3
commit
7c6d0d26b1
@ -654,7 +654,7 @@ public:
|
||||
References.push_back(std::addressof(Data));
|
||||
}
|
||||
std::stable_sort(Points.begin(), Points.end());
|
||||
auto Last = std::unique(Points.begin(), Points.end());
|
||||
auto Last = llvm::unique(Points);
|
||||
Points.erase(Last, Points.end());
|
||||
|
||||
EndPoints.assign(Points.begin(), Points.end());
|
||||
|
@ -361,7 +361,7 @@ public:
|
||||
/// by construction, this method can be used to turn it into a proper set.
|
||||
void removeDuplicates() {
|
||||
sortByAddress();
|
||||
auto LastI = std::unique(Symbols.begin(), Symbols.end());
|
||||
auto LastI = llvm::unique(Symbols);
|
||||
Symbols.erase(LastI, Symbols.end());
|
||||
}
|
||||
|
||||
|
@ -696,8 +696,7 @@ void InstrProfSymtab::finalizeSymtab() {
|
||||
llvm::sort(MD5NameMap, less_first());
|
||||
llvm::sort(MD5FuncMap, less_first());
|
||||
llvm::sort(AddrToMD5Map, less_first());
|
||||
AddrToMD5Map.erase(std::unique(AddrToMD5Map.begin(), AddrToMD5Map.end()),
|
||||
AddrToMD5Map.end());
|
||||
AddrToMD5Map.erase(llvm::unique(AddrToMD5Map), AddrToMD5Map.end());
|
||||
Sorted = true;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ void llvm::findArrayDimensions(ScalarEvolution &SE,
|
||||
|
||||
// Remove duplicates.
|
||||
array_pod_sort(Terms.begin(), Terms.end());
|
||||
Terms.erase(std::unique(Terms.begin(), Terms.end()), Terms.end());
|
||||
Terms.erase(llvm::unique(Terms), Terms.end());
|
||||
|
||||
// Put larger terms first.
|
||||
llvm::sort(Terms, [](const SCEV *LHS, const SCEV *RHS) {
|
||||
|
@ -175,9 +175,8 @@ void ImportedFunctionsInliningStatistics::dump(const bool Verbose) {
|
||||
void ImportedFunctionsInliningStatistics::calculateRealInlines() {
|
||||
// Removing duplicated Callers.
|
||||
llvm::sort(NonImportedCallers);
|
||||
NonImportedCallers.erase(
|
||||
std::unique(NonImportedCallers.begin(), NonImportedCallers.end()),
|
||||
NonImportedCallers.end());
|
||||
NonImportedCallers.erase(llvm::unique(NonImportedCallers),
|
||||
NonImportedCallers.end());
|
||||
|
||||
for (const auto &Name : NonImportedCallers) {
|
||||
auto &Node = *NodesMap[Name];
|
||||
|
@ -690,7 +690,7 @@ void StackSafetyDataFlowAnalysis<CalleeTy>::runDataFlow() {
|
||||
Callees.push_back(CS.first.Callee);
|
||||
|
||||
llvm::sort(Callees);
|
||||
Callees.erase(std::unique(Callees.begin(), Callees.end()), Callees.end());
|
||||
Callees.erase(llvm::unique(Callees), Callees.end());
|
||||
|
||||
for (auto &Callee : Callees)
|
||||
Callers[Callee].push_back(F.first);
|
||||
|
@ -49,9 +49,7 @@ void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {
|
||||
[](const AccelTableData *A, const AccelTableData *B) {
|
||||
return *A < *B;
|
||||
});
|
||||
E.second.Values.erase(
|
||||
std::unique(E.second.Values.begin(), E.second.Values.end()),
|
||||
E.second.Values.end());
|
||||
E.second.Values.erase(llvm::unique(E.second.Values), E.second.Values.end());
|
||||
}
|
||||
|
||||
// Figure out how many buckets we need, then compute the bucket contents and
|
||||
|
@ -238,10 +238,10 @@ public:
|
||||
if (Values.size() == 1)
|
||||
return;
|
||||
llvm::sort(Values);
|
||||
Values.erase(std::unique(Values.begin(), Values.end(),
|
||||
[](const DbgValueLoc &A, const DbgValueLoc &B) {
|
||||
return A.getExpression() == B.getExpression();
|
||||
}),
|
||||
Values.erase(llvm::unique(Values,
|
||||
[](const DbgValueLoc &A, const DbgValueLoc &B) {
|
||||
return A.getExpression() == B.getExpression();
|
||||
}),
|
||||
Values.end());
|
||||
}
|
||||
|
||||
|
@ -1130,11 +1130,11 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
|
||||
return !!FragmentB;
|
||||
return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
|
||||
});
|
||||
GVEs.erase(std::unique(GVEs.begin(), GVEs.end(),
|
||||
[](DwarfCompileUnit::GlobalExpr A,
|
||||
DwarfCompileUnit::GlobalExpr B) {
|
||||
return A.Expr == B.Expr;
|
||||
}),
|
||||
GVEs.erase(llvm::unique(GVEs,
|
||||
[](DwarfCompileUnit::GlobalExpr A,
|
||||
DwarfCompileUnit::GlobalExpr B) {
|
||||
return A.Expr == B.Expr;
|
||||
}),
|
||||
GVEs.end());
|
||||
return GVEs;
|
||||
}
|
||||
|
@ -6271,9 +6271,7 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
|
||||
};
|
||||
// Sorting all the GEPs of the same data structures based on the offsets.
|
||||
llvm::sort(LargeOffsetGEPs, compareGEPOffset);
|
||||
LargeOffsetGEPs.erase(
|
||||
std::unique(LargeOffsetGEPs.begin(), LargeOffsetGEPs.end()),
|
||||
LargeOffsetGEPs.end());
|
||||
LargeOffsetGEPs.erase(llvm::unique(LargeOffsetGEPs), LargeOffsetGEPs.end());
|
||||
// Skip if all the GEPs have the same offsets.
|
||||
if (LargeOffsetGEPs.front().second == LargeOffsetGEPs.back().second)
|
||||
continue;
|
||||
|
@ -4248,8 +4248,7 @@ bool RegisterCoalescer::runOnMachineFunction(MachineFunction &fn) {
|
||||
// Removing sub-register operands may allow GR32_ABCD -> GR32 and DPR_VFP2 ->
|
||||
// DPR inflation.
|
||||
array_pod_sort(InflateRegs.begin(), InflateRegs.end());
|
||||
InflateRegs.erase(std::unique(InflateRegs.begin(), InflateRegs.end()),
|
||||
InflateRegs.end());
|
||||
InflateRegs.erase(llvm::unique(InflateRegs), InflateRegs.end());
|
||||
LLVM_DEBUG(dbgs() << "Trying to inflate " << InflateRegs.size()
|
||||
<< " regs.\n");
|
||||
for (Register Reg : InflateRegs) {
|
||||
|
@ -184,8 +184,7 @@ void SplitAnalysis::analyzeUses() {
|
||||
|
||||
// Remove duplicates, keeping the smaller slot for each instruction.
|
||||
// That is what we want for early clobbers.
|
||||
UseSlots.erase(std::unique(UseSlots.begin(), UseSlots.end(),
|
||||
SlotIndex::isSameInstr),
|
||||
UseSlots.erase(llvm::unique(UseSlots, SlotIndex::isSameInstr),
|
||||
UseSlots.end());
|
||||
|
||||
// Compute per-live block info.
|
||||
|
@ -807,13 +807,14 @@ collectContributionData(DWARFContext::unit_iterator_range Units) {
|
||||
// type units in dwo or dwp files) share contributions. We don't want
|
||||
// to report them more than once.
|
||||
Contributions.erase(
|
||||
std::unique(Contributions.begin(), Contributions.end(),
|
||||
[](const std::optional<StrOffsetsContributionDescriptor> &L,
|
||||
const std::optional<StrOffsetsContributionDescriptor> &R) {
|
||||
if (L && R)
|
||||
return L->Base == R->Base && L->Size == R->Size;
|
||||
return false;
|
||||
}),
|
||||
llvm::unique(
|
||||
Contributions,
|
||||
[](const std::optional<StrOffsetsContributionDescriptor> &L,
|
||||
const std::optional<StrOffsetsContributionDescriptor> &R) {
|
||||
if (L && R)
|
||||
return L->Base == R->Base && L->Size == R->Size;
|
||||
return false;
|
||||
}),
|
||||
Contributions.end());
|
||||
return Contributions;
|
||||
}
|
||||
|
@ -6079,8 +6079,7 @@ bool AsmParser::parseMSInlineAsm(
|
||||
|
||||
// Set the unique clobbers.
|
||||
array_pod_sort(ClobberRegs.begin(), ClobberRegs.end());
|
||||
ClobberRegs.erase(std::unique(ClobberRegs.begin(), ClobberRegs.end()),
|
||||
ClobberRegs.end());
|
||||
ClobberRegs.erase(llvm::unique(ClobberRegs), ClobberRegs.end());
|
||||
Clobbers.assign(ClobberRegs.size(), std::string());
|
||||
for (unsigned I = 0, E = ClobberRegs.size(); I != E; ++I) {
|
||||
raw_string_ostream OS(Clobbers[I]);
|
||||
|
@ -7443,8 +7443,7 @@ bool MasmParser::parseMSInlineAsm(
|
||||
|
||||
// Set the unique clobbers.
|
||||
array_pod_sort(ClobberRegs.begin(), ClobberRegs.end());
|
||||
ClobberRegs.erase(std::unique(ClobberRegs.begin(), ClobberRegs.end()),
|
||||
ClobberRegs.end());
|
||||
ClobberRegs.erase(llvm::unique(ClobberRegs), ClobberRegs.end());
|
||||
Clobbers.assign(ClobberRegs.size(), std::string());
|
||||
for (unsigned I = 0, E = ClobberRegs.size(); I != E; ++I) {
|
||||
raw_string_ostream OS(Clobbers[I]);
|
||||
|
@ -550,7 +550,7 @@ void RegisterFile::collectWrites(
|
||||
sort(Writes, [](const WriteRef &Lhs, const WriteRef &Rhs) {
|
||||
return Lhs.getWriteState() < Rhs.getWriteState();
|
||||
});
|
||||
auto It = std::unique(Writes.begin(), Writes.end());
|
||||
auto It = llvm::unique(Writes);
|
||||
Writes.resize(std::distance(Writes.begin(), It));
|
||||
}
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ std::vector<StringRef> CoverageMapping::getUniqueSourceFiles() const {
|
||||
for (const auto &Function : getCoveredFunctions())
|
||||
llvm::append_range(Filenames, Function.Filenames);
|
||||
llvm::sort(Filenames);
|
||||
auto Last = std::unique(Filenames.begin(), Filenames.end());
|
||||
auto Last = llvm::unique(Filenames);
|
||||
Filenames.erase(Last, Filenames.end());
|
||||
return Filenames;
|
||||
}
|
||||
|
@ -920,8 +920,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
|
||||
|
||||
// Remove duplicate binary ids.
|
||||
llvm::sort(BinaryIds);
|
||||
BinaryIds.erase(std::unique(BinaryIds.begin(), BinaryIds.end()),
|
||||
BinaryIds.end());
|
||||
BinaryIds.erase(llvm::unique(BinaryIds), BinaryIds.end());
|
||||
|
||||
for (const auto &BI : BinaryIds) {
|
||||
// Increment by binary id length data type size.
|
||||
|
@ -209,7 +209,7 @@ static bool runNVVMReflect(Function &F, unsigned SmVersion) {
|
||||
// Removing via isInstructionTriviallyDead may add duplicates to the ToRemove
|
||||
// array. Filter out the duplicates before starting to erase from parent.
|
||||
std::sort(ToRemove.begin(), ToRemove.end());
|
||||
auto NewLastIter = std::unique(ToRemove.begin(), ToRemove.end());
|
||||
auto NewLastIter = llvm::unique(ToRemove);
|
||||
ToRemove.erase(NewLastIter, ToRemove.end());
|
||||
|
||||
for (Instruction *I : ToRemove)
|
||||
|
@ -13353,11 +13353,11 @@ static SDValue lowerV8I16GeneralSingleInputShuffle(
|
||||
SmallVector<int, 4> LoInputs;
|
||||
copy_if(LoMask, std::back_inserter(LoInputs), [](int M) { return M >= 0; });
|
||||
array_pod_sort(LoInputs.begin(), LoInputs.end());
|
||||
LoInputs.erase(std::unique(LoInputs.begin(), LoInputs.end()), LoInputs.end());
|
||||
LoInputs.erase(llvm::unique(LoInputs), LoInputs.end());
|
||||
SmallVector<int, 4> HiInputs;
|
||||
copy_if(HiMask, std::back_inserter(HiInputs), [](int M) { return M >= 0; });
|
||||
array_pod_sort(HiInputs.begin(), HiInputs.end());
|
||||
HiInputs.erase(std::unique(HiInputs.begin(), HiInputs.end()), HiInputs.end());
|
||||
HiInputs.erase(llvm::unique(HiInputs), HiInputs.end());
|
||||
int NumLToL = llvm::lower_bound(LoInputs, 4) - LoInputs.begin();
|
||||
int NumHToL = LoInputs.size() - NumLToL;
|
||||
int NumLToH = llvm::lower_bound(HiInputs, 4) - HiInputs.begin();
|
||||
@ -14245,13 +14245,11 @@ static SDValue lowerV16I8Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
|
||||
copy_if(Mask, std::back_inserter(LoInputs),
|
||||
[](int M) { return M >= 0 && M < 8; });
|
||||
array_pod_sort(LoInputs.begin(), LoInputs.end());
|
||||
LoInputs.erase(std::unique(LoInputs.begin(), LoInputs.end()),
|
||||
LoInputs.end());
|
||||
LoInputs.erase(llvm::unique(LoInputs), LoInputs.end());
|
||||
SmallVector<int, 4> HiInputs;
|
||||
copy_if(Mask, std::back_inserter(HiInputs), [](int M) { return M >= 8; });
|
||||
array_pod_sort(HiInputs.begin(), HiInputs.end());
|
||||
HiInputs.erase(std::unique(HiInputs.begin(), HiInputs.end()),
|
||||
HiInputs.end());
|
||||
HiInputs.erase(llvm::unique(HiInputs), HiInputs.end());
|
||||
|
||||
bool TargetLo = LoInputs.size() >= HiInputs.size();
|
||||
ArrayRef<int> InPlaceInputs = TargetLo ? LoInputs : HiInputs;
|
||||
|
@ -439,9 +439,8 @@ X86LoadValueInjectionLoadHardeningPass::getGadgetGraph(
|
||||
|
||||
// Remove duplicate transmitters
|
||||
llvm::sort(DefTransmitters);
|
||||
DefTransmitters.erase(
|
||||
std::unique(DefTransmitters.begin(), DefTransmitters.end()),
|
||||
DefTransmitters.end());
|
||||
DefTransmitters.erase(llvm::unique(DefTransmitters),
|
||||
DefTransmitters.end());
|
||||
};
|
||||
|
||||
// Find all of the transmitters
|
||||
|
@ -822,8 +822,7 @@ X86SpeculativeLoadHardeningPass::tracePredStateThroughCFG(
|
||||
|
||||
// Sort and unique the codes to minimize them.
|
||||
llvm::sort(UncondCodeSeq);
|
||||
UncondCodeSeq.erase(std::unique(UncondCodeSeq.begin(), UncondCodeSeq.end()),
|
||||
UncondCodeSeq.end());
|
||||
UncondCodeSeq.erase(llvm::unique(UncondCodeSeq), UncondCodeSeq.end());
|
||||
|
||||
// Build a checking version of the successor.
|
||||
BuildCheckingBlockForSuccAndConds(MBB, *UncondSucc, /*SuccCount*/ 1,
|
||||
|
@ -79,7 +79,7 @@ static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) {
|
||||
do {
|
||||
SmallVector<WeakTrackingVH, 8> WUsers(CE->users());
|
||||
llvm::sort(WUsers);
|
||||
WUsers.erase(std::unique(WUsers.begin(), WUsers.end()), WUsers.end());
|
||||
WUsers.erase(llvm::unique(WUsers), WUsers.end());
|
||||
while (!WUsers.empty())
|
||||
if (WeakTrackingVH WU = WUsers.pop_back_val()) {
|
||||
if (PHINode *PN = dyn_cast<PHINode>(WU)) {
|
||||
|
@ -1473,7 +1473,7 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl {
|
||||
|
||||
// Make a strictly ascending list of offsets as required by addAccess()
|
||||
llvm::sort(Offsets);
|
||||
auto *Last = std::unique(Offsets.begin(), Offsets.end());
|
||||
auto *Last = llvm::unique(Offsets);
|
||||
Offsets.erase(Last, Offsets.end());
|
||||
|
||||
VectorType *VT = dyn_cast<VectorType>(&Ty);
|
||||
|
@ -310,8 +310,7 @@ bool PlaceSafepointsPass::runImpl(Function &F, const TargetLibraryInfo &TLI) {
|
||||
// We can sometimes end up with duplicate poll locations. This happens if
|
||||
// a single loop is visited more than once. The fact this happens seems
|
||||
// wrong, but it does happen for the split-backedge.ll test case.
|
||||
PollLocations.erase(std::unique(PollLocations.begin(), PollLocations.end()),
|
||||
PollLocations.end());
|
||||
PollLocations.erase(llvm::unique(PollLocations), PollLocations.end());
|
||||
|
||||
// Insert a poll at each point the analysis pass identified
|
||||
// The poll location must be the terminator of a loop latch block.
|
||||
|
@ -1815,10 +1815,10 @@ ReassociatePass::buildMinimalMultiplyDAG(IRBuilderBase &Builder,
|
||||
}
|
||||
// Unique factors with equal powers -- we've folded them into the first one's
|
||||
// base.
|
||||
Factors.erase(std::unique(Factors.begin(), Factors.end(),
|
||||
[](const Factor &LHS, const Factor &RHS) {
|
||||
return LHS.Power == RHS.Power;
|
||||
}),
|
||||
Factors.erase(llvm::unique(Factors,
|
||||
[](const Factor &LHS, const Factor &RHS) {
|
||||
return LHS.Power == RHS.Power;
|
||||
}),
|
||||
Factors.end());
|
||||
|
||||
// Iteratively collect the base of each factor with an add power into the
|
||||
|
@ -2148,7 +2148,7 @@ static void relocationViaAlloca(
|
||||
}
|
||||
|
||||
llvm::sort(Uses);
|
||||
auto Last = std::unique(Uses.begin(), Uses.end());
|
||||
auto Last = llvm::unique(Uses);
|
||||
Uses.erase(Last, Uses.end());
|
||||
|
||||
for (Instruction *Use : Uses) {
|
||||
|
@ -2178,8 +2178,7 @@ checkVectorTypesForPromotion(Partition &P, const DataLayout &DL,
|
||||
cast<FixedVectorType>(LHSTy)->getNumElements();
|
||||
};
|
||||
llvm::sort(CandidateTys, RankVectorTypesComp);
|
||||
CandidateTys.erase(std::unique(CandidateTys.begin(), CandidateTys.end(),
|
||||
RankVectorTypesEq),
|
||||
CandidateTys.erase(llvm::unique(CandidateTys, RankVectorTypesEq),
|
||||
CandidateTys.end());
|
||||
} else {
|
||||
// The only way to have the same element type in every vector type is to
|
||||
|
@ -4905,7 +4905,7 @@ bool SimplifyCFGOpt::SimplifyBranchOnICmpChain(BranchInst *BI,
|
||||
// There might be duplicate constants in the list, which the switch
|
||||
// instruction can't handle, remove them now.
|
||||
array_pod_sort(Values.begin(), Values.end(), ConstantIntSortPredicate);
|
||||
Values.erase(std::unique(Values.begin(), Values.end()), Values.end());
|
||||
Values.erase(llvm::unique(Values), Values.end());
|
||||
|
||||
// If Extra was used, we require at least two switch values to do the
|
||||
// transformation. A switch with one value is just a conditional branch.
|
||||
|
@ -502,7 +502,7 @@ static void filterByAccelName(
|
||||
getDies(DICtx, DICtx.getDebugNames(), Name, Dies);
|
||||
}
|
||||
llvm::sort(Dies);
|
||||
Dies.erase(std::unique(Dies.begin(), Dies.end()), Dies.end());
|
||||
Dies.erase(llvm::unique(Dies), Dies.end());
|
||||
|
||||
DIDumpOptions DumpOpts = getDumpOpts(DICtx);
|
||||
DumpOpts.GetNameForDWARFReg = GetNameForDWARFReg;
|
||||
@ -646,7 +646,7 @@ static bool collectObjectSources(ObjectFile &Obj, DWARFContext &DICtx,
|
||||
|
||||
// Dedup and order the sources.
|
||||
llvm::sort(Sources);
|
||||
Sources.erase(std::unique(Sources.begin(), Sources.end()), Sources.end());
|
||||
Sources.erase(llvm::unique(Sources), Sources.end());
|
||||
|
||||
for (StringRef Name : Sources)
|
||||
OS << Name << "\n";
|
||||
|
@ -2395,8 +2395,7 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
|
||||
llvm::erase_if(SymbolList,
|
||||
[](const NMSymbol &s) { return !s.shouldPrint(); });
|
||||
sortSymbolList(SymbolList);
|
||||
SymbolList.erase(std::unique(SymbolList.begin(), SymbolList.end()),
|
||||
SymbolList.end());
|
||||
SymbolList.erase(llvm::unique(SymbolList), SymbolList.end());
|
||||
printExportSymbolList(SymbolList);
|
||||
}
|
||||
|
||||
|
@ -1570,8 +1570,7 @@ static void addSymbolizer(
|
||||
LabelAddrs.insert(LabelAddrs.end(), LabelAddrsRef.begin(),
|
||||
LabelAddrsRef.end());
|
||||
llvm::sort(LabelAddrs);
|
||||
LabelAddrs.resize(std::unique(LabelAddrs.begin(), LabelAddrs.end()) -
|
||||
LabelAddrs.begin());
|
||||
LabelAddrs.resize(llvm::unique(LabelAddrs) - LabelAddrs.begin());
|
||||
// Add the labels.
|
||||
for (unsigned LabelNum = 0; LabelNum != LabelAddrs.size(); ++LabelNum) {
|
||||
auto Name = std::make_unique<std::string>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user