Author: Kazu Hirata Date: 2021-01-17T10:39:45-08:00 New Revision: 352fcfc69788093b50971a9f5540a61fa0887ce1
URL: https://github.com/llvm/llvm-project/commit/352fcfc69788093b50971a9f5540a61fa0887ce1 DIFF: https://github.com/llvm/llvm-project/commit/352fcfc69788093b50971a9f5540a61fa0887ce1.diff LOG: [llvm] Use llvm::sort (NFC) Added: Modified: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/DWARFLinker/DWARFLinker.cpp llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp llvm/lib/DebugInfo/GSYM/GsymCreator.cpp llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp llvm/lib/FileCheck/FileCheck.cpp llvm/lib/Object/COFFObjectFile.cpp llvm/lib/Support/DebugCounter.cpp llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp llvm/lib/TextAPI/MachO/TextStub.cpp llvm/tools/llvm-cov/CoverageExporterJson.cpp llvm/tools/llvm-cov/CoverageExporterLcov.cpp llvm/tools/llvm-jitlink/llvm-jitlink.cpp Removed: ################################################################################ diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 9f62cce028f8..4d886f708cd4 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3830,7 +3830,7 @@ void ModuleBitcodeWriterBase::writeModuleLevelReferences( NameVals.push_back(VE.getValueID(RI.getValue())); // Sort the refs for determinism output, the vector returned by FS->refs() has // been initialized from a DenseSet. - llvm::sort(NameVals.begin() + SizeBeforeRefs, NameVals.end()); + llvm::sort(drop_begin(NameVals, SizeBeforeRefs)); if (VTableFuncs.empty()) Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals, diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp index a09cbf9c95ea..b57d14bfcf55 100644 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -2590,7 +2590,7 @@ bool DWARFLinker::link() { std::vector<std::pair<StringRef, DebugInfoSize>> Sorted; for (auto &E : SizeByObject) Sorted.emplace_back(E.first(), E.second); - llvm::sort(Sorted.begin(), Sorted.end(), [](auto &LHS, auto &RHS) { + llvm::sort(Sorted, [](auto &LHS, auto &RHS) { return LHS.second.Output > RHS.second.Output; }); diff --git a/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp b/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp index be8c32d5b294..9bc69abea102 100644 --- a/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp +++ b/llvm/lib/DebugInfo/CodeView/DebugFrameDataSubsection.cpp @@ -47,10 +47,9 @@ Error DebugFrameDataSubsection::commit(BinaryStreamWriter &Writer) const { } std::vector<FrameData> SortedFrames(Frames.begin(), Frames.end()); - std::sort(SortedFrames.begin(), SortedFrames.end(), - [](const FrameData &LHS, const FrameData &RHS) { - return LHS.RvaStart < RHS.RvaStart; - }); + llvm::sort(SortedFrames, [](const FrameData &LHS, const FrameData &RHS) { + return LHS.RvaStart < RHS.RvaStart; + }); if (auto EC = Writer.writeArray(makeArrayRef(SortedFrames))) return EC; return Error::success(); diff --git a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp index 7d9b72c6283d..2001478e8047 100644 --- a/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp +++ b/llvm/lib/DebugInfo/GSYM/GsymCreator.cpp @@ -169,7 +169,7 @@ llvm::Error GsymCreator::finalize(llvm::raw_ostream &OS) { Finalized = true; // Sort function infos so we can emit sorted functions. - llvm::sort(Funcs.begin(), Funcs.end()); + llvm::sort(Funcs); // Don't let the string table indexes change by finalizing in order. StrTab.finalizeInOrder(); diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp index 9017c824098b..fd9a0deb54d6 100644 --- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp @@ -514,11 +514,10 @@ SymbolCache::findLineTable(uint16_t Modi) const { } // Sort EntryList, and add flattened contents to the line table. - std::sort(EntryList.begin(), EntryList.end(), - [](const std::vector<LineTableEntry> &LHS, - const std::vector<LineTableEntry> &RHS) { - return LHS[0].Addr < RHS[0].Addr; - }); + llvm::sort(EntryList, [](const std::vector<LineTableEntry> &LHS, + const std::vector<LineTableEntry> &RHS) { + return LHS[0].Addr < RHS[0].Addr; + }); for (size_t I = 0; I < EntryList.size(); ++I) llvm::append_range(ModuleLineTable, EntryList[I]); diff --git a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp index 7240c1ed0ce9..c2fa4466eab6 100644 --- a/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp +++ b/llvm/lib/ExecutionEngine/Orc/SpeculateAnalyses.cpp @@ -106,11 +106,10 @@ BlockFreqQuery::ResultTy BlockFreqQuery::operator()(Function &F) { assert(IBBs.size() == BBFreqs.size() && "BB Count Mismatch"); - llvm::sort(BBFreqs.begin(), BBFreqs.end(), - [](decltype(BBFreqs)::const_reference BBF, - decltype(BBFreqs)::const_reference BBS) { - return BBF.second > BBS.second ? true : false; - }); + llvm::sort(BBFreqs, [](decltype(BBFreqs)::const_reference BBF, + decltype(BBFreqs)::const_reference BBS) { + return BBF.second > BBS.second ? true : false; + }); // ignoring number of direct calls in a BB auto Topk = numBBToGet(BBFreqs.size()); diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 2a213fcfe901..3169afaed58c 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -1386,12 +1386,11 @@ void Pattern::printVariableDefs(const SourceMgr &SM, } // Sort variable captures by the order in which they matched the input. // Ranges shouldn't be overlapping, so we can just compare the start. - std::sort(VarCaptures.begin(), VarCaptures.end(), - [](const VarCapture &A, const VarCapture &B) { - assert(A.Range.Start != B.Range.Start && - "unexpected overlapping variable captures"); - return A.Range.Start.getPointer() < B.Range.Start.getPointer(); - }); + llvm::sort(VarCaptures, [](const VarCapture &A, const VarCapture &B) { + assert(A.Range.Start != B.Range.Start && + "unexpected overlapping variable captures"); + return A.Range.Start.getPointer() < B.Range.Start.getPointer(); + }); // Create notes for the sorted captures. for (const VarCapture &VC : VarCaptures) { SmallString<256> Msg; diff --git a/llvm/lib/Object/COFFObjectFile.cpp b/llvm/lib/Object/COFFObjectFile.cpp index 2e44a38ccdaa..6e9a8eb35dcf 100644 --- a/llvm/lib/Object/COFFObjectFile.cpp +++ b/llvm/lib/Object/COFFObjectFile.cpp @@ -1791,10 +1791,9 @@ Error ResourceSectionRef::load(const COFFObjectFile *O, const SectionRef &S) { Relocs.reserve(OrigRelocs.size()); for (const coff_relocation &R : OrigRelocs) Relocs.push_back(&R); - std::sort(Relocs.begin(), Relocs.end(), - [](const coff_relocation *A, const coff_relocation *B) { - return A->VirtualAddress < B->VirtualAddress; - }); + llvm::sort(Relocs, [](const coff_relocation *A, const coff_relocation *B) { + return A->VirtualAddress < B->VirtualAddress; + }); return Error::success(); } diff --git a/llvm/lib/Support/DebugCounter.cpp b/llvm/lib/Support/DebugCounter.cpp index 8c579f395282..7bb231c79239 100644 --- a/llvm/lib/Support/DebugCounter.cpp +++ b/llvm/lib/Support/DebugCounter.cpp @@ -118,7 +118,7 @@ void DebugCounter::push_back(const std::string &Val) { void DebugCounter::print(raw_ostream &OS) const { SmallVector<StringRef, 16> CounterNames(RegisteredCounters.begin(), RegisteredCounters.end()); - sort(CounterNames.begin(), CounterNames.end()); + sort(CounterNames); auto &Us = instance(); OS << "Counters and values:\n"; diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index f1a3a963352e..1dabcea0f7a5 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -775,10 +775,10 @@ bool AMDGPUPromoteAllocaImpl::hasSufficientLocalMem(const Function &F) { // // FIXME: We should really do something to fix the addresses to a more optimal // value instead - llvm::sort(AllocatedSizes.begin(), AllocatedSizes.end(), - [](std::pair<uint64_t, Align> LHS, std::pair<uint64_t, Align> RHS) { - return LHS.second < RHS.second; - }); + llvm::sort(AllocatedSizes, [](std::pair<uint64_t, Align> LHS, + std::pair<uint64_t, Align> RHS) { + return LHS.second < RHS.second; + }); // Check how much local memory is being used by global objects CurrentLocalMemUsage = 0; diff --git a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp index 1f49e0d14de9..56ee3cd60c17 100644 --- a/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp +++ b/llvm/lib/Target/Hexagon/HexagonBlockRanges.cpp @@ -84,7 +84,7 @@ void HexagonBlockRanges::RangeList::unionize(bool MergeAdjacent) { if (empty()) return; - llvm::sort(begin(), end()); + llvm::sort(*this); iterator Iter = begin(); while (Iter != end()-1) { diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index a212e8ffa620..1d6352b2e126 100644 --- a/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/llvm/lib/TextAPI/MachO/TextStub.cpp @@ -521,13 +521,12 @@ template <> struct MappingTraits<const InterfaceFile *> { break; } } - llvm::sort(Section.Symbols.begin(), Section.Symbols.end()); - llvm::sort(Section.Classes.begin(), Section.Classes.end()); - llvm::sort(Section.ClassEHs.begin(), Section.ClassEHs.end()); - llvm::sort(Section.IVars.begin(), Section.IVars.end()); - llvm::sort(Section.WeakDefSymbols.begin(), - Section.WeakDefSymbols.end()); - llvm::sort(Section.TLVSymbols.begin(), Section.TLVSymbols.end()); + llvm::sort(Section.Symbols); + llvm::sort(Section.Classes); + llvm::sort(Section.ClassEHs); + llvm::sort(Section.IVars); + llvm::sort(Section.WeakDefSymbols); + llvm::sort(Section.TLVSymbols); Exports.emplace_back(std::move(Section)); } @@ -579,12 +578,11 @@ template <> struct MappingTraits<const InterfaceFile *> { break; } } - llvm::sort(Section.Symbols.begin(), Section.Symbols.end()); - llvm::sort(Section.Classes.begin(), Section.Classes.end()); - llvm::sort(Section.ClassEHs.begin(), Section.ClassEHs.end()); - llvm::sort(Section.IVars.begin(), Section.IVars.end()); - llvm::sort(Section.WeakRefSymbols.begin(), - Section.WeakRefSymbols.end()); + llvm::sort(Section.Symbols); + llvm::sort(Section.Classes); + llvm::sort(Section.ClassEHs); + llvm::sort(Section.IVars); + llvm::sort(Section.WeakRefSymbols); Undefineds.emplace_back(std::move(Section)); } } diff --git a/llvm/tools/llvm-cov/CoverageExporterJson.cpp b/llvm/tools/llvm-cov/CoverageExporterJson.cpp index 0a47dd2b88c7..d1446f379f00 100644 --- a/llvm/tools/llvm-cov/CoverageExporterJson.cpp +++ b/llvm/tools/llvm-cov/CoverageExporterJson.cpp @@ -287,16 +287,15 @@ void CoverageExporterJson::renderRoot(ArrayRef<std::string> SourceFiles) { SourceFiles, Options); auto Files = renderFiles(Coverage, SourceFiles, FileReports, Options); // Sort files in order of their names. - std::sort(Files.begin(), Files.end(), - [](const json::Value &A, const json::Value &B) { - const json::Object *ObjA = A.getAsObject(); - const json::Object *ObjB = B.getAsObject(); - assert(ObjA != nullptr && "Value A was not an Object"); - assert(ObjB != nullptr && "Value B was not an Object"); - const StringRef FilenameA = ObjA->getString("filename").getValue(); - const StringRef FilenameB = ObjB->getString("filename").getValue(); - return FilenameA.compare(FilenameB) < 0; - }); + llvm::sort(Files, [](const json::Value &A, const json::Value &B) { + const json::Object *ObjA = A.getAsObject(); + const json::Object *ObjB = B.getAsObject(); + assert(ObjA != nullptr && "Value A was not an Object"); + assert(ObjB != nullptr && "Value B was not an Object"); + const StringRef FilenameA = ObjA->getString("filename").getValue(); + const StringRef FilenameB = ObjB->getString("filename").getValue(); + return FilenameA.compare(FilenameB) < 0; + }); auto Export = json::Object( {{"files", std::move(Files)}, {"totals", renderSummary(Totals)}}); // Skip functions-level information if necessary. diff --git a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp index 08115e0494b0..99ca037e7b5e 100644 --- a/llvm/tools/llvm-cov/CoverageExporterLcov.cpp +++ b/llvm/tools/llvm-cov/CoverageExporterLcov.cpp @@ -127,7 +127,7 @@ void renderBranchExecutionCounts(raw_ostream &OS, // Sort branches based on line number to ensure branches corresponding to the // same source line are counted together. - std::sort(Branches.begin(), Branches.end(), sortLine); + llvm::sort(Branches, sortLine); auto NextBranch = Branches.begin(); auto EndBranch = Branches.end(); diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 763189904a82..da4a1643b4e1 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -259,18 +259,17 @@ static void dumpSectionContents(raw_ostream &OS, LinkGraph &G) { for (auto &S : G.sections()) Sections.push_back(&S); - std::sort(Sections.begin(), Sections.end(), - [](const Section *LHS, const Section *RHS) { - if (llvm::empty(LHS->symbols()) && llvm::empty(RHS->symbols())) - return false; - if (llvm::empty(LHS->symbols())) - return false; - if (llvm::empty(RHS->symbols())) - return true; - SectionRange LHSRange(*LHS); - SectionRange RHSRange(*RHS); - return LHSRange.getStart() < RHSRange.getStart(); - }); + llvm::sort(Sections, [](const Section *LHS, const Section *RHS) { + if (llvm::empty(LHS->symbols()) && llvm::empty(RHS->symbols())) + return false; + if (llvm::empty(LHS->symbols())) + return false; + if (llvm::empty(RHS->symbols())) + return true; + SectionRange LHSRange(*LHS); + SectionRange RHSRange(*RHS); + return LHSRange.getStart() < RHSRange.getStart(); + }); for (auto *S : Sections) { OS << S->getName() << " content:"; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits