[llvm] r343426 - Use the container form llvm::sort(C, ...)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 30 15:31:29 PDT 2018
Author: maskray
Date: Sun Sep 30 15:31:29 2018
New Revision: 343426
URL: http://llvm.org/viewvc/llvm-project?rev=343426&view=rev
Log:
Use the container form llvm::sort(C, ...)
There are a few leftovers in rL343163 which span two lines. This commit
changes these llvm::sort(C.begin(), C.end, ...) to llvm::sort(C, ...)
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
llvm/trunk/lib/CodeGen/RegisterUsageInfo.cpp
llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
llvm/trunk/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp
llvm/trunk/lib/XRay/Trace.cpp
llvm/trunk/tools/dsymutil/DebugMap.cpp
llvm/trunk/tools/dsymutil/NonRelocatableStringpool.cpp
llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
llvm/trunk/utils/TableGen/FastISelEmitter.cpp
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp Sun Sep 30 15:31:29 2018
@@ -90,11 +90,10 @@ void DwarfStringPool::emit(AsmPrinter &A
for (const auto &E : Pool)
Entries.push_back(&E);
- llvm::sort(
- Entries.begin(), Entries.end(),
- [](const StringMapEntry<EntryTy> *A, const StringMapEntry<EntryTy> *B) {
- return A->getValue().Offset < B->getValue().Offset;
- });
+ llvm::sort(Entries, [](const StringMapEntry<EntryTy> *A,
+ const StringMapEntry<EntryTy> *B) {
+ return A->getValue().Offset < B->getValue().Offset;
+ });
for (const auto &Entry : Entries) {
assert(ShouldCreateSymbols == static_cast<bool>(Entry->getValue().Symbol) &&
Modified: llvm/trunk/lib/CodeGen/RegisterUsageInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterUsageInfo.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterUsageInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterUsageInfo.cpp Sun Sep 30 15:31:29 2018
@@ -81,7 +81,7 @@ void PhysicalRegisterUsageInfo::print(ra
// sort the vector to print analysis in alphabatic order of function name.
llvm::sort(
- FPRMPairVector.begin(), FPRMPairVector.end(),
+ FPRMPairVector,
[](const FuncPtrRegMaskPair *A, const FuncPtrRegMaskPair *B) -> bool {
return A->first->getName() < B->first->getName();
});
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Sun Sep 30 15:31:29 2018
@@ -275,11 +275,10 @@ namespace {
write(Len);
write(Number);
- llvm::sort(
- SortedLinesByFile.begin(), SortedLinesByFile.end(),
- [](StringMapEntry<GCOVLines> *LHS, StringMapEntry<GCOVLines> *RHS) {
- return LHS->getKey() < RHS->getKey();
- });
+ llvm::sort(SortedLinesByFile, [](StringMapEntry<GCOVLines> *LHS,
+ StringMapEntry<GCOVLines> *RHS) {
+ return LHS->getKey() < RHS->getKey();
+ });
for (auto &I : SortedLinesByFile)
I->getValue().writeOut();
write(0);
Modified: llvm/trunk/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ImportedFunctionsInliningStatistics.cpp Sun Sep 30 15:31:29 2018
@@ -190,17 +190,14 @@ ImportedFunctionsInliningStatistics::get
for (const NodesMapTy::value_type& Node : NodesMap)
SortedNodes.push_back(&Node);
- llvm::sort(
- SortedNodes.begin(), SortedNodes.end(),
- [&](const SortedNodesTy::value_type &Lhs,
- const SortedNodesTy::value_type &Rhs) {
- if (Lhs->second->NumberOfInlines != Rhs->second->NumberOfInlines)
- return Lhs->second->NumberOfInlines > Rhs->second->NumberOfInlines;
- if (Lhs->second->NumberOfRealInlines !=
- Rhs->second->NumberOfRealInlines)
- return Lhs->second->NumberOfRealInlines >
- Rhs->second->NumberOfRealInlines;
- return Lhs->first() < Rhs->first();
- });
+ llvm::sort(SortedNodes, [&](const SortedNodesTy::value_type &Lhs,
+ const SortedNodesTy::value_type &Rhs) {
+ if (Lhs->second->NumberOfInlines != Rhs->second->NumberOfInlines)
+ return Lhs->second->NumberOfInlines > Rhs->second->NumberOfInlines;
+ if (Lhs->second->NumberOfRealInlines != Rhs->second->NumberOfRealInlines)
+ return Lhs->second->NumberOfRealInlines >
+ Rhs->second->NumberOfRealInlines;
+ return Lhs->first() < Rhs->first();
+ });
return SortedNodes;
}
Modified: llvm/trunk/lib/XRay/Trace.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/XRay/Trace.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/lib/XRay/Trace.cpp (original)
+++ llvm/trunk/lib/XRay/Trace.cpp Sun Sep 30 15:31:29 2018
@@ -311,7 +311,7 @@ Error loadFDRLog(StringRef Data, bool Is
for (auto &PTB : Index) {
auto &Blocks = PTB.second;
llvm::sort(
- Blocks.begin(), Blocks.end(),
+ Blocks,
[](const BlockIndexer::Block &L, const BlockIndexer::Block &R) {
return (L.WallclockTime->seconds() < R.WallclockTime->seconds() &&
L.WallclockTime->nanos() < R.WallclockTime->nanos());
Modified: llvm/trunk/tools/dsymutil/DebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DebugMap.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DebugMap.cpp (original)
+++ llvm/trunk/tools/dsymutil/DebugMap.cpp Sun Sep 30 15:31:29 2018
@@ -63,9 +63,9 @@ void DebugMapObject::print(raw_ostream &
Entries.reserve(Symbols.getNumItems());
for (const auto &Sym : make_range(Symbols.begin(), Symbols.end()))
Entries.push_back(std::make_pair(Sym.getKey(), Sym.getValue()));
- llvm::sort(
- Entries.begin(), Entries.end(),
- [](const Entry &LHS, const Entry &RHS) { return LHS.first < RHS.first; });
+ llvm::sort(Entries, [](const Entry &LHS, const Entry &RHS) {
+ return LHS.first < RHS.first;
+ });
for (const auto &Sym : Entries) {
if (Sym.second.ObjectAddress)
OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
Modified: llvm/trunk/tools/dsymutil/NonRelocatableStringpool.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/NonRelocatableStringpool.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/NonRelocatableStringpool.cpp (original)
+++ llvm/trunk/tools/dsymutil/NonRelocatableStringpool.cpp Sun Sep 30 15:31:29 2018
@@ -40,11 +40,10 @@ NonRelocatableStringpool::getEntriesForE
for (const auto &E : Strings)
if (E.getValue().isIndexed())
Result.emplace_back(E, true);
- llvm::sort(
- Result.begin(), Result.end(),
- [](const DwarfStringPoolEntryRef A, const DwarfStringPoolEntryRef B) {
- return A.getIndex() < B.getIndex();
- });
+ llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
+ const DwarfStringPoolEntryRef B) {
+ return A.getIndex() < B.getIndex();
+ });
return Result;
}
Modified: llvm/trunk/utils/TableGen/CodeGenSchedule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenSchedule.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenSchedule.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenSchedule.cpp Sun Sep 30 15:31:29 2018
@@ -1868,12 +1868,9 @@ void CodeGenSchedModels::collectProcReso
}
// Finalize each ProcModel by sorting the record arrays.
for (CodeGenProcModel &PM : ProcModels) {
- llvm::sort(PM.WriteResDefs.begin(), PM.WriteResDefs.end(),
- LessRecord());
- llvm::sort(PM.ReadAdvanceDefs.begin(), PM.ReadAdvanceDefs.end(),
- LessRecord());
- llvm::sort(PM.ProcResourceDefs.begin(), PM.ProcResourceDefs.end(),
- LessRecord());
+ llvm::sort(PM.WriteResDefs, LessRecord());
+ llvm::sort(PM.ReadAdvanceDefs, LessRecord());
+ llvm::sort(PM.ProcResourceDefs, LessRecord());
LLVM_DEBUG(
PM.dump();
dbgs() << "WriteResDefs: "; for (RecIter RI = PM.WriteResDefs.begin(),
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Sun Sep 30 15:31:29 2018
@@ -829,7 +829,7 @@ void FastISelMap::printFunctionDefinitio
= SignaturesWithConstantForms.find(Operands);
if (MI != SignaturesWithConstantForms.end()) {
// Unique any duplicates out of the list.
- llvm::sort(MI->second.begin(), MI->second.end());
+ llvm::sort(MI->second);
MI->second.erase(std::unique(MI->second.begin(), MI->second.end()),
MI->second.end());
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=343426&r1=343425&r2=343426&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Sun Sep 30 15:31:29 2018
@@ -4394,21 +4394,20 @@ void GlobalISelEmitter::run(raw_ostream
std::vector<std::vector<Record *>> FeatureBitsets;
for (auto &Rule : Rules)
FeatureBitsets.push_back(Rule.getRequiredFeatures());
- llvm::sort(
- FeatureBitsets.begin(), FeatureBitsets.end(),
- [&](const std::vector<Record *> &A, const std::vector<Record *> &B) {
- if (A.size() < B.size())
- return true;
- if (A.size() > B.size())
- return false;
- for (const auto &Pair : zip(A, B)) {
- if (std::get<0>(Pair)->getName() < std::get<1>(Pair)->getName())
- return true;
- if (std::get<0>(Pair)->getName() > std::get<1>(Pair)->getName())
- return false;
- }
+ llvm::sort(FeatureBitsets, [&](const std::vector<Record *> &A,
+ const std::vector<Record *> &B) {
+ if (A.size() < B.size())
+ return true;
+ if (A.size() > B.size())
+ return false;
+ for (const auto &Pair : zip(A, B)) {
+ if (std::get<0>(Pair)->getName() < std::get<1>(Pair)->getName())
+ return true;
+ if (std::get<0>(Pair)->getName() > std::get<1>(Pair)->getName())
return false;
- });
+ }
+ return false;
+ });
FeatureBitsets.erase(
std::unique(FeatureBitsets.begin(), FeatureBitsets.end()),
FeatureBitsets.end());
@@ -4577,13 +4576,11 @@ void RuleMatcher::optimize() {
}
InsnMatcher.optimize();
}
- llvm::sort(
- EpilogueMatchers.begin(), EpilogueMatchers.end(),
- [](const std::unique_ptr<PredicateMatcher> &L,
- const std::unique_ptr<PredicateMatcher> &R) {
- return std::make_tuple(L->getKind(), L->getInsnVarID(), L->getOpIdx()) <
- std::make_tuple(R->getKind(), R->getInsnVarID(), R->getOpIdx());
- });
+ llvm::sort(EpilogueMatchers, [](const std::unique_ptr<PredicateMatcher> &L,
+ const std::unique_ptr<PredicateMatcher> &R) {
+ return std::make_tuple(L->getKind(), L->getInsnVarID(), L->getOpIdx()) <
+ std::make_tuple(R->getKind(), R->getInsnVarID(), R->getOpIdx());
+ });
}
bool RuleMatcher::hasFirstCondition() const {
More information about the llvm-commits
mailing list