1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

[llvm] Use llvm::sort (NFC)

This commit is contained in:
Kazu Hirata 2021-01-17 10:39:45 -08:00
parent 7f65ef970c
commit 4d55c50aec
15 changed files with 60 additions and 69 deletions

View File

@ -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,

View File

@ -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;
});

View File

@ -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();

View File

@ -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();

View File

@ -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]);

View File

@ -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());

View File

@ -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;

View File

@ -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();
}

View File

@ -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";

View File

@ -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;

View File

@ -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) {

View File

@ -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));
}
}

View File

@ -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.

View File

@ -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();

View File

@ -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:";