8000 [llvm][NFC] Use `llvm::sort()` (#140335) · llvm/llvm-project@061a769 · GitHub
[go: up one dir, main page]

Skip to content

Commit 061a769

Browse files
authored
[llvm][NFC] Use llvm::sort() (#140335)
1 parent aaaae99 commit 061a769

File tree

18 files changed

+56
-62
lines changed

18 files changed

+56
-62
lines changed

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SeedCollector.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,10 @@ template <typename LoadOrStoreT> class MemSeedBundle : public SeedBundle {
141141
"Expected LoadInst or StoreInst!");
142142
assert(all_of(Seeds, [](auto *S) { return isa<LoadOrStoreT>(S); }) &&
143143
"Expected Load or Store instructions!");
144-
auto Cmp = [&SE](Instruction *I0, Instruction *I1) {
144+
llvm::sort(Seeds, [&SE](Instruction *I0, Instruction *I1) {
145145
return Utils::atLowerAddress(cast<LoadOrStoreT>(I0),
146146
cast<LoadOrStoreT>(I1), SE);
147-
};
148-
std::sort(Seeds.begin(), Seeds.end(), Cmp);
147+
});
149148
}
150149
explicit MemSeedBundle(LoadOrStoreT *MemI) : SeedBundle(MemI) {
151150
static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,11 +2333,10 @@ static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares(
23332333
// order of fragment size - there should be no duplicates.
23342334
for (auto &Pair : FragmentMap) {
23352335
SmallVector<DebugVariable, 8> &Frags = Pair.second;
2336-
std::sort(Frags.begin(), Frags.end(),
2337-
[](const DebugVariable &Next, const DebugVariable &Elmt) {
2338-
return Elmt.getFragmentOrDefault().SizeInBits >
2339-
Next.getFragmentOrDefault().SizeInBits;
2340-
});
2336+
llvm::sort(Frags, [](const DebugVariable &Next, const DebugVariable &Elmt) {
2337+
return Elmt.getFragmentOrDefault().SizeInBits >
2338+
Next.getFragmentOrDefault().SizeInBits;
2339+
});
23412340
// Check for duplicates.
23422341
assert(std::adjacent_find(Frags.begin(), Frags.end()) == Frags.end());
23432342
}

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,9 @@ void llvm::extractInstructionFeatures(
10561056
// frequency vector, mapping each instruction to its associated MBB.
10571057

10581058
// Start off by sorting the segments based on the beginning slot index.
1059-
std::sort(
1060-
LRPosInfo.begin(), LRPosInfo.end(),
1061-
[](LRStartEndInfo A, LRStartEndInfo B) { return A.Begin < B.Begin; });
1059+
llvm::sort(LRPosInfo, [](LRStartEndInfo A, LRStartEndInfo B) {
1060+
return A.Begin < B.Begin;
1061+
});
10621062
size_t InstructionIndex = 0;
10631063
size_t CurrentSegmentIndex = 0;
10641064
SlotIndex CurrentIndex = LRPosInfo[0].Begin;

llvm/lib/DWARFLinker/Parallel/ArrayList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ template <typename T, size_t ItemsGroupSize = 512> class ArrayList {
8282
forEach([&](T &Item) { SortedItems.push_back(Item); });
8383

8484
if (SortedItems.size()) {
85-
std::sort(SortedItems.begin(), SortedItems.end(), Comparator);
85+
llvm::sort(SortedItems, Comparator);
8686

8787
size_t SortedItemIdx = 0;
8888
forEach([&](T &Item) { Item = SortedItems[SortedItemIdx++]; });

llvm/lib/ExecutionEngine/Orc/Core.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,9 @@ void JITDylib::dump(raw_ostream &OS) {
11421142
std::vector<std::pair<SymbolStringPtr, SymbolTableEntry *>> SymbolsSorted;
11431143
for (auto &KV : Symbols)
11441144
SymbolsSorted.emplace_back(KV.first, &KV.second);
1145-
std::sort(SymbolsSorted.begin(), SymbolsSorted.end(),
1146-
[](const auto &L, const auto &R) { return *L.first < *R.first; });
1145+
llvm::sort(SymbolsSorted, [](const auto &L, const auto &R) {
1146+
return *L.first < *R.first;
1147+
});
11471148

11481149
for (auto &KV : SymbolsSorted) {
11491150
OS << " \"" << *KV.first << "\": ";

llvm/lib/ExecutionEngine/Orc/Debugging/DebugInfoSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void preserveDWARFSection(LinkGraph &G, Section &Sec) {
4949
static SmallVector<char, 0> getSectionData(Section &Sec) {
5050
SmallVector<char, 0> SecData;
5151
SmallVector<Block *, 8> SecBlocks(Sec.blocks().begin(), Sec.blocks().end());
52-
std::sort(SecBlocks.begin(), SecBlocks.end(), [](Block *LHS, Block *RHS) {
52+
llvm::sort(SecBlocks, [](Block *LHS, Block *RHS) {
5353
return LHS->getAddress() < RHS->getAddress();
5454
});
5555
// Convert back to what object file would have, one blob of section content

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ RawInstrProfReader<IntPtrT>::getTemporalProfTraces(
487487
return TemporalProfTraces;
488488
}
489489
// Sort functions by their timestamps to build the trace.
490-
std::sort(TemporalProfTimestamps.begin(), TemporalProfTimestamps.end());
490+
llvm::sort(TemporalProfTimestamps);
491491
TemporalProfTraceTy Trace;
492492
if (Weight)
493493
Trace.Weight = *Weight;

llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ void PipelineSolver::populateReadyList(
589589
}
590590

591591
if (UseCostHeur)
592-
std::sort(ReadyList.begin(), ReadyList.end(), llvm::less_second());
592+
llvm::sort(ReadyList, llvm::less_second());
593593

594594
assert(ReadyList.size() == CurrSU.second.size());
595595
}

llvm/lib/Target/AMDGPU/AMDGPUPreloadKernelArguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class PreloadKernelArgInfo {
224224

225225
// Allocate loads in order of offset. We need to be sure that the implicit
226226
// argument can actually be preloaded.
227-
std::sort(ImplicitArgLoads.begin(), ImplicitArgLoads.end(), less_second());
227+
llvm::sort(ImplicitArgLoads, less_second());
228228

229229
// If we fail to preload any implicit argument we know we don't have SGPRs
230230
// to preload any subsequent ones with larger offsets. Find the first

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6844,8 +6844,8 @@ bool ARMPipelinerLoopInfo::tooMuchRegisterPressure(SwingSchedulerDAG &SSD,
68446844
++Stage) {
68456845
std::deque<SUnit *> Instrs =
68466846
SMS.getInstructions(Cycle + Stage * SMS.getInitiationInterval());
6847-
std::sort(Instrs.begin(), Instrs.end(),
6848-
[](SUnit *A, SUnit *B) { return A->NodeNum > B->NodeNum; });
6847+
llvm::sort(Instrs,
6848+
[](SUnit *A, SUnit *B) { return A->NodeNum > B->NodeNum; });
68496849
llvm::append_range(ProposedSchedule, Instrs);
68506850
}
68516851

llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
104104
std::set<SPIRV::Extension::Extension> &Vals) {
105105
SmallVector<StringRef, 10> Tokens;
106106
ArgValue.split(Tokens, ",", -1, false);
107-
std::sort(Tokens.begin(), Tokens.end());
107+
llvm::sort(Tokens);
108108

109109
std::set<SPIRV::Extension::Extension> EnabledExtensions;
110110

llvm/lib/Target/SPIRV/SPIRVStructurizer.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,14 @@ class SPIRVStructurizer : public FunctionPass {
660660
Instruction *InsertionPoint = *MergeInstructions.begin();
661661

662662
PartialOrderingVisitor Visitor(F);
663-
std::sort(MergeInstructions.begin(), MergeInstructions.end(),
664-
[&Visitor](Instruction *Left, Instruction *Right) {
665-
if (Left == Right)
666-
return false;
667-
BasicBlock *RightMerge = getDesignatedMergeBlock(Right);
668-
BasicBlock *LeftMerge = getDesignatedMergeBlock(Left);
669-
return !Visitor.compare(RightMerge, LeftMerge);
670-
});
663+
llvm::sort(MergeInstructions,
664+
[&Visitor](Instruction *Left, Instruction *Right) {
665+
if (Left == Right)
666+
return false;
667+
BasicBlock *RightMerge = getDesignatedMergeBlock(Right);
668+
BasicBlock *LeftMerge = getDesignatedMergeBlock(Left);
669+
return !Visitor.compare(RightMerge, LeftMerge);
670+
});
671671

672672
for (Instruction *I : MergeInstructions) {
673673
I->moveBefore(InsertionPoint->getIterator());

llvm/lib/Target/SPIRV/SPIRVUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ PartialOrderingVisitor::PartialOrderingVisitor(Function &F) {
662662
for (auto &[BB, Info] : BlockToOrder)
663663
Order.emplace_back(BB);
664664

665-
std::sort(Order.begin(), Order.end(), [&](const auto &LHS, const auto &RHS) {
665+
llvm::sort(Order, [&](const auto &LHS, const auto &RHS) {
666666
return compare(LHS, RHS);
667667
});
668668
}

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ AArch64::printEnabledExtensions(const std::set<StringRef> &EnabledFeatureNames)
227227
EnabledExtensionsInfo.push_back(*ExtInfo);
228228
}
229229

230-
std::sort(EnabledExtensionsInfo.begin(), EnabledExtensionsInfo.end(),
231-
[](const ExtensionInfo &Lhs, const ExtensionInfo &Rhs) {
232-
return Lhs.ArchFeatureName < Rhs.ArchFeatureName;
233-
});
230+
llvm::sort(EnabledExtensionsInfo,
231+
[](const ExtensionInfo &Lhs, const ExtensionInfo &Rhs) {
232+
return Lhs.ArchFeatureName < Rhs.ArchFeatureName;
233+
});
234234

235235
for (const auto &Ext : EnabledExtensionsInfo) {
236236
outs() << " "

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode::print(
29452945
// Make a copy of the computed context ids that we can sort for stability.
29462946
auto ContextIds = getContextIds();
29472947
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
2948-
std::sort(SortedIds.begin(), SortedIds.end());
2948+
llvm::sort(SortedIds);
29492949
for (auto Id : SortedIds)
29502950
OS << " " << Id;
29512951
OS << "\n";
@@ -2977,7 +2977,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextEdge::print(
29772977
<< " AllocTypes: " << getAllocTypeString(AllocTypes);
29782978
OS << " ContextIds:";
29792979
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
2980-
std::sort(SortedIds.begin(), SortedIds.end());
2980+
llvm::sort(SortedIds);
29812981
for (auto Id : SortedIds)
29822982
OS << " " << Id;
29832983
}
@@ -3012,7 +3012,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::printTotalSizes(
30123012
DenseSet<uint32_t> ContextIds = Node->getContextIds();
30133013
auto AllocTypeFromCall = getAllocationCallType(Node->Call);
30143014
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
3015-
std::sort(SortedIds.begin(), SortedIds.end());
3015+
llvm::sort(SortedIds);
30163016
for (auto Id : SortedIds) {
30173017
auto TypeI = ContextIdToAllocationType.find(Id);
30183018
assert(TypeI != ContextIdToAllocationType.end());
@@ -3211,7 +3211,7 @@ struct DOTGraphTraits<const CallsiteContextGraph<DerivedCCG, FuncTy, CallTy> *>
32113211
std::string IdString = "ContextIds:";
32123212
if (ContextIds.size() < 100) {
32133213
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
3214-
std::sort(SortedIds.begin(), SortedIds.end());
3214+
llvm::sort(SortedIds);
32153215
for (auto Id : SortedIds)
32163216
IdString += (" " + Twine(Id)).str();
32173217
} else {

llvm/lib/Transforms/Utils/CodeLayout.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -986,16 +986,15 @@ class ExtTSPImpl {
986986
}
987987

988988
// Sorting chains by density in the decreasing order.
989-
std::sort(SortedChains.begin(), SortedChains.end(),
990-
[&](const ChainT *L, const ChainT *R) {
991-
// Place the entry point at the beginning of the order.
992-
if (L->isEntry() != R->isEntry())
993-
return L->isEntry();
994-
995-
// Compare by density and break ties by chain identifiers.
996-
return std::make_tuple(-L->density(), L->Id) <
997-
std::make_tuple(-R->density(), R->Id);
998-
});
989+
llvm::sort(SortedChains, [&](const ChainT *L, const ChainT *R) {
990+
// Place the entry point at the beginning of the order.
991+
if (L->isEntry() != R->isEntry())
992+
return L->isEntry();
993+
994+
// Compare by density and break ties by chain identifiers.
995+
return std::make_tuple(-L->density(), L->Id) <
996+
std::make_tuple(-R->density(), R->Id);
997+
});
999998

1000999
// Collect the nodes in the order specified by their chains.
10011000
std::vector<uint64_t> Order;
@@ -1355,14 +1354,12 @@ class CDSortImpl {
13551354
}
13561355

13571356
// Sort chains by density in the decreasing order.
1358-
std::sort(SortedChains.begin(), SortedChains.end(),
1359-
[&](const ChainT *L, const ChainT *R) {
1360-
const double DL = ChainDensity[L];
1361-
const double DR = ChainDensity[R];
1362-
// Compare by density and break ties by chain identifiers.
1363-
return std::make_tuple(-DL, L->Id) <
1364-
std::make_tuple(-DR, R->Id);
1365-
});
1357+
llvm::sort(SortedChains, [&](const ChainT *L, const ChainT *R) {
1358+
const double DL = ChainDensity[L];
1359+
const double DR = ChainDensity[R];
1360+
// Compare by density and break ties by chain identifiers.
1361+
return std::make_tuple(-DL, L->Id) < std::make_tuple(-DR, R->Id);
1362+
});
13661363

13671364
// Collect the nodes in the order specified by their chains.
13681365
std::vector<uint64_t> Order;

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,10 +1459,9 @@ Error Session::FileInfo::registerMultiStubEntry(
14591459
Sym.getTargetFlags());
14601460

14611461
// Let's keep stubs ordered by ascending address.
1462-
std::sort(Entry.begin(), Entry.end(),
1463-
[](const MemoryRegionInfo &L, const MemoryRegionInfo &R) {
1464-
return L.getTargetAddress() < R.getTargetAddress();
1465-
});
1462+
llvm::sort(Entry, [](const MemoryRegionInfo &L, const MemoryRegionInfo &R) {
1463+
return L.getTargetAddress() < R.getTargetAddress();
1464+
});
14661465

14671466
return Error::success();
14681467
}

llvm/utils/TableGen/ExegesisEmitter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ void ExegesisEmitter::emitPfmCountersInfo(const Record &Def,
141141
ValidationCounter->getValueAsDef("EventType")->getName(),
142142
getPfmCounterId(ValidationCounter->getValueAsString("Counter"))});
143143
}
144-
std::sort(ValidationCounters.begin(), ValidationCounters.end(),
145-
EventNumberLess);
144+
llvm::sort(ValidationCounters, EventNumberLess);
146145
OS << "\nstatic const std::pair<ValidationEvent, const char*> " << Target
147146
<< Def.getName() << "ValidationCounters[] = {\n";
148147
for (const ValidationCounterInfo &VCI : ValidationCounters) {

0 commit comments

Comments
 (0)
0