From 7c6d0d26b1792fdf437b3e33b98c55fee9b06516 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 14 Jun 2024 22:49:36 -0700 Subject: [PATCH] [llvm] Use llvm::unique (NFC) (#95628) --- llvm/include/llvm/ADT/IntervalTree.h | 2 +- llvm/include/llvm/ExecutionEngine/Orc/Core.h | 2 +- llvm/include/llvm/ProfileData/InstrProf.h | 3 +-- llvm/lib/Analysis/Delinearization.cpp | 2 +- .../ImportedFunctionsInliningStatistics.cpp | 5 ++--- llvm/lib/Analysis/StackSafetyAnalysis.cpp | 2 +- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 4 +--- llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h | 8 ++++---- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 10 +++++----- llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 +--- llvm/lib/CodeGen/RegisterCoalescer.cpp | 3 +-- llvm/lib/CodeGen/SplitKit.cpp | 3 +-- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 15 ++++++++------- llvm/lib/MC/MCParser/AsmParser.cpp | 3 +-- llvm/lib/MC/MCParser/MasmParser.cpp | 3 +-- llvm/lib/MCA/HardwareUnits/RegisterFile.cpp | 2 +- llvm/lib/ProfileData/Coverage/CoverageMapping.cpp | 2 +- llvm/lib/ProfileData/InstrProfWriter.cpp | 3 +-- llvm/lib/Target/NVPTX/NVVMReflect.cpp | 2 +- llvm/lib/Target/X86/X86ISelLowering.cpp | 10 ++++------ .../X86/X86LoadValueInjectionLoadHardening.cpp | 5 ++--- .../Target/X86/X86SpeculativeLoadHardening.cpp | 3 +-- llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp | 2 +- llvm/lib/Transforms/IPO/AttributorAttributes.cpp | 2 +- llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp | 3 +-- llvm/lib/Transforms/Scalar/Reassociate.cpp | 8 ++++---- .../Transforms/Scalar/RewriteStatepointsForGC.cpp | 2 +- llvm/lib/Transforms/Scalar/SROA.cpp | 3 +-- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 +- llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 4 ++-- llvm/tools/llvm-nm/llvm-nm.cpp | 3 +-- llvm/tools/llvm-objdump/llvm-objdump.cpp | 3 +-- 32 files changed, 55 insertions(+), 73 deletions(-) diff --git a/llvm/include/llvm/ADT/IntervalTree.h b/llvm/include/llvm/ADT/IntervalTree.h index 01301ad06b72fe..918c86227576e3 100644 --- a/llvm/include/llvm/ADT/IntervalTree.h +++ b/llvm/include/llvm/ADT/IntervalTree.h @@ -654,7 +654,7 @@ class IntervalTree { 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()); diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 6ce6affe38e059..9a737f6f2f8abd 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -361,7 +361,7 @@ class SymbolLookupSet { /// 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()); } diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index 0c899e6d84965c..76002cdf565f2a 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/include/llvm/ProfileData/InstrProf.h @@ -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; } diff --git a/llvm/lib/Analysis/Delinearization.cpp b/llvm/lib/Analysis/Delinearization.cpp index a45d8815e54ce9..3cc83db02128ff 100644 --- a/llvm/lib/Analysis/Delinearization.cpp +++ b/llvm/lib/Analysis/Delinearization.cpp @@ -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) { diff --git a/llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp b/llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp index d24cb1c3c7a154..279f76da4d1d9a 100644 --- a/llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp +++ b/llvm/lib/Analysis/ImportedFunctionsInliningStatistics.cpp @@ -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]; diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp index 7acae15e24ba22..c5334959115d96 100644 --- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp +++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp @@ -690,7 +690,7 @@ void StackSafetyDataFlowAnalysis::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); diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp index 5b679fd3b9f92b..4957f70b23f089 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -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 diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h index 726aba18bb804c..069766ccddc2f1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h +++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h @@ -238,10 +238,10 @@ class DebugLocEntry { 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()); } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 7de9432325d8a5..7d3ea9352bd6c3 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1130,11 +1130,11 @@ sortGlobalExprs(SmallVectorImpl &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; } diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 0e01080bd75cc9..bb2c76d3d97604 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -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; diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index a808a541103f5f..3397cb4f3661fe 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -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) { diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp index d6c0a782465e13..b671e510387530 100644 --- a/llvm/lib/CodeGen/SplitKit.cpp +++ b/llvm/lib/CodeGen/SplitKit.cpp @@ -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. diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index b7297c18da7c99..207f081edf05a3 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -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 &L, - const std::optional &R) { - if (L && R) - return L->Base == R->Base && L->Size == R->Size; - return false; - }), + llvm::unique( + Contributions, + [](const std::optional &L, + const std::optional &R) { + if (L && R) + return L->Base == R->Base && L->Size == R->Size; + return false; + }), Contributions.end()); return Contributions; } diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 8014ef9d039487..ddbf99b3050dde 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -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]); diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp index 51563ea86a6c52..5ed66fb2fbb85c 100644 --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -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]); diff --git a/llvm/lib/MCA/HardwareUnits/RegisterFile.cpp b/llvm/lib/MCA/HardwareUnits/RegisterFile.cpp index 53663a10e8a7d9..3c1c35adf88977 100644 --- a/llvm/lib/MCA/HardwareUnits/RegisterFile.cpp +++ b/llvm/lib/MCA/HardwareUnits/RegisterFile.cpp @@ -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)); } diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp index 455124efd5b248..e2b0dd3ebcb331 100644 --- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp +++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp @@ -1352,7 +1352,7 @@ std::vector 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; } diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp index 7cf4704a79faae..cf2416c4e80746 100644 --- a/llvm/lib/ProfileData/InstrProfWriter.cpp +++ b/llvm/lib/ProfileData/InstrProfWriter.cpp @@ -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. diff --git a/llvm/lib/Target/NVPTX/NVVMReflect.cpp b/llvm/lib/Target/NVPTX/NVVMReflect.cpp index 29c95e4226bf40..4024953bb51dbc 100644 --- a/llvm/lib/Target/NVPTX/NVVMReflect.cpp +++ b/llvm/lib/Target/NVPTX/NVVMReflect.cpp @@ -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) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 88c7a4159856a8..bffd778cb552de 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -13353,11 +13353,11 @@ static SDValue lowerV8I16GeneralSingleInputShuffle( SmallVector 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 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 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 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 InPlaceInputs = TargetLo ? LoInputs : HiInputs; diff --git a/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp b/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp index fff5d17160230e..d5c23295ee9a65 100644 --- a/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp +++ b/llvm/lib/Target/X86/X86LoadValueInjectionLoadHardening.cpp @@ -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 diff --git a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp index 489c8f49252432..46317cb33776fa 100644 --- a/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp +++ b/llvm/lib/Target/X86/X86SpeculativeLoadHardening.cpp @@ -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, diff --git a/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp b/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp index 5e91cce1068b46..7503bf1561ccc9 100644 --- a/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp +++ b/llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp @@ -79,7 +79,7 @@ static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) { do { SmallVector 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(WU)) { diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 05a38cdd7d7b6e..a9bf32e0a8498b 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -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(&Ty); diff --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp index dcdea6e7b62ae7..ce54806c560dfd 100644 --- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp +++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -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. diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index f36e21b296bd1f..5cfa5f46b33168 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -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 diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 10fc4050966bdf..e0a9cff620189c 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -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) { diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index c2997913a0a255..1c19a9eb8e1bea 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -2178,8 +2178,7 @@ checkVectorTypesForPromotion(Partition &P, const DataLayout &DL, cast(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 diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 9c7f90b0613a0b..bccfb80f2b6cb4 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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. diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 2bfc9705368e46..d00cf520757120 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -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"; diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index e3b81451fcac91..d3e8d4c5ed987c 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -2395,8 +2395,7 @@ exportSymbolNamesFromFiles(const std::vector &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); } diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 675364a1c1bcfd..8265ab9d7fe6b2 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -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();