Skip to content

Commit 0ef5525

Browse files
kazutakahirataAlexisPerry
authored andcommitted
[llvm] Use llvm::sort (NFC) (llvm#96434)
1 parent 6352b98 commit 0ef5525

File tree

15 files changed

+41
-49
lines changed

15 files changed

+41
-49
lines changed

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,11 +2231,10 @@ static AssignmentTrackingLowering::OverlapMap buildOverlapMapAndRecordDeclares(
22312231
// order of fragment size - there should be no duplicates.
22322232
for (auto &Pair : FragmentMap) {
22332233
SmallVector<DebugVariable, 8> &Frags = Pair.second;
2234-
std::sort(Frags.begin(), Frags.end(),
2235-
[](const DebugVariable &Next, const DebugVariable &Elmt) {
2236-
return Elmt.getFragmentOrDefault().SizeInBits >
2237-
Next.getFragmentOrDefault().SizeInBits;
2238-
});
2234+
llvm::sort(Frags, [](const DebugVariable &Next, const DebugVariable &Elmt) {
2235+
return Elmt.getFragmentOrDefault().SizeInBits >
2236+
Next.getFragmentOrDefault().SizeInBits;
2237+
});
22392238
// Check for duplicates.
22402239
assert(std::adjacent_find(Frags.begin(), Frags.end()) == Frags.end());
22412240
}

llvm/lib/CodeGen/MLRegAllocEvictAdvisor.cpp

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

965965
// Start off by sorting the segments based on the beginning slot index.
966-
std::sort(
967-
LRPosInfo.begin(), LRPosInfo.end(),
968-
[](LRStartEndInfo A, LRStartEndInfo B) { return A.Begin < B.Begin; });
966+
llvm::sort(LRPosInfo, [](LRStartEndInfo A, LRStartEndInfo B) {
967+
return A.Begin < B.Begin;
968+
});
969969
size_t InstructionIndex = 0;
970970
size_t CurrentSegmentIndex = 0;
971971
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
@@ -1155,8 +1155,9 @@ void JITDylib::dump(raw_ostream &OS) {
11551155
std::vector<std::pair<SymbolStringPtr, SymbolTableEntry *>> SymbolsSorted;
11561156
for (auto &KV : Symbols)
11571157
SymbolsSorted.emplace_back(KV.first, &KV.second);
1158-
std::sort(SymbolsSorted.begin(), SymbolsSorted.end(),
1159-
[](const auto &L, const auto &R) { return *L.first < *R.first; });
1158+
llvm::sort(SymbolsSorted, [](const auto &L, const auto &R) {
1159+
return *L.first < *R.first;
1160+
});
11601161

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void preserveDWARFSection(LinkGraph &G, Section &Sec) {
5050
static SmallVector<char, 0> getSectionData(Section &Sec) {
5151
SmallVector<char, 0> SecData;
5252
SmallVector<Block *, 8> SecBlocks(Sec.blocks().begin(), Sec.blocks().end());
53-
std::sort(SecBlocks.begin(), SecBlocks.end(), [](Block *LHS, Block *RHS) {
53+
llvm::sort(SecBlocks, [](Block *LHS, Block *RHS) {
5454
return LHS->getAddress() < RHS->getAddress();
5555
});
5656
// 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
@@ -476,7 +476,7 @@ RawInstrProfReader<IntPtrT>::getTemporalProfTraces(
476476
return TemporalProfTraces;
477477
}
478478
// Sort functions by their timestamps to build the trace.
479-
std::sort(TemporalProfTimestamps.begin(), TemporalProfTimestamps.end());
479+
llvm::sort(TemporalProfTimestamps);
480480
TemporalProfTraceTy Trace;
481481
if (Weight)
482482
Trace.Weight = *Weight;

llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,7 @@ void PipelineSolver::populateReadyList(
612612
}
613613

614614
if (UseCostHeur) {
615-
std::sort(ReadyList.begin(), ReadyList.end(),
616-
[](std::pair<int, int> A, std::pair<int, int> B) {
617-
return A.second < B.second;
618-
});
615+
llvm::sort(ReadyList, llvm::less_second());
619616
}
620617

621618
assert(ReadyList.size() == CurrSU.second.size());

llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6886,8 +6886,8 @@ bool ARMPipelinerLoopInfo::tooMuchRegisterPressure(SwingSchedulerDAG &SSD,
68866886
++Stage) {
68876887
std::deque<SUnit *> Instrs =
68886888
SMS.getInstructions(Cycle + Stage * SMS.getInitiationInterval());
6889-
std::sort(Instrs.begin(), Instrs.end(),
6890-
[](SUnit *A, SUnit *B) { return A->NodeNum > B->NodeNum; });
6889+
llvm::sort(Instrs,
6890+
[](SUnit *A, SUnit *B) { return A->NodeNum > B->NodeNum; });
68916891
for (SUnit *SU : Instrs)
68926892
ProposedSchedule.push_back(SU);
68936893
}

llvm/lib/Target/NVPTX/NVVMReflect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ static bool runNVVMReflect(Function &F, unsigned SmVersion) {
208208

209209
// Removing via isInstructionTriviallyDead may add duplicates to the ToRemove
210210
// array. Filter out the duplicates before starting to erase from parent.
211-
std::sort(ToRemove.begin(), ToRemove.end());
211+
llvm::sort(ToRemove);
212212
auto NewLastIter = llvm::unique(ToRemove);
213213
ToRemove.erase(NewLastIter, ToRemove.end());
214214

llvm/lib/Target/PowerPC/PPCMergeStringPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ bool PPCMergeStringPool::mergeModuleStringPool(Module &M) {
244244
return false;
245245

246246
// Sort the global constants to make access more efficient.
247-
std::sort(MergeableStrings.begin(), MergeableStrings.end(), CompareConstants);
247+
llvm::sort(MergeableStrings, CompareConstants);
248248

249249
SmallVector<Constant *> ConstantsInStruct;
250250
for (GlobalVariable *GV : MergeableStrings)

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextNode::print(
22032203
// Make a copy of the computed context ids that we can sort for stability.
22042204
auto ContextIds = getContextIds();
22052205
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
2206-
std::sort(SortedIds.begin(), SortedIds.end());
2206+
llvm::sort(SortedIds);
22072207
for (auto Id : SortedIds)
22082208
OS << " " << Id;
22092209
OS << "\n";
@@ -2238,7 +2238,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::ContextEdge::print(
22382238
<< " AllocTypes: " << getAllocTypeString(AllocTypes);
22392239
OS << " ContextIds:";
22402240
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
2241-
std::sort(SortedIds.begin(), SortedIds.end());
2241+
llvm::sort(SortedIds);
22422242
for (auto Id : SortedIds)
22432243
OS << " " << Id;
22442244
}
@@ -2380,7 +2380,7 @@ struct DOTGraphTraits<const CallsiteContextGraph<DerivedCCG, FuncTy, CallTy> *>
23802380
std::string IdString = "ContextIds:";
23812381
if (ContextIds.size() < 100) {
23822382
std::vector<uint32_t> SortedIds(ContextIds.begin(), ContextIds.end());
2383-
std::sort(SortedIds.begin(), SortedIds.end());
2383+
llvm::sort(SortedIds);
23842384
for (auto Id : SortedIds)
23852385
IdString += (" " + Twine(Id)).str();
23862386
} 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
@@ -1259,10 +1259,9 @@ Error Session::FileInfo::registerMultiStubEntry(
12591259
Sym.getTargetFlags());
12601260

12611261
// Let's keep stubs ordered by ascending address.
1262-
std::sort(Entry.begin(), Entry.end(),
1263-
[](const MemoryRegionInfo &L, const MemoryRegionInfo &R) {
1264-
return L.getTargetAddress() < R.getTargetAddress();
1265-
});
1262+
llvm::sort(Entry, [](const MemoryRegionInfo &L, const MemoryRegionInfo &R) {
1263+
return L.getTargetAddress() < R.getTargetAddress();
1264+
});
12661265

12671266
return Error::success();
12681267
}

llvm/utils/TableGen/ARMTargetDefEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void EmitARMTargetDef(RecordKeeper &RK, raw_ostream &OS) {
4545
const auto MarchB = B->getValueAsString("MArchName");
4646
return MarchA.compare(MarchB) < 0; // A lexographically less than B
4747
};
48-
std::sort(SortedExtensions.begin(), SortedExtensions.end(), Alphabetical);
48+
llvm::sort(SortedExtensions, Alphabetical);
4949

5050
// The ARMProcFamilyEnum values are initialised by SubtargetFeature defs
5151
// which set the ARMProcFamily field. We can generate the enum from these defs

llvm/utils/TableGen/ExegesisEmitter.cpp

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

0 commit comments

Comments
 (0)