Skip to content

Commit bdf03fc

Browse files
authored
Revert "[llvm][NFC] Use llvm::sort()" (#140668)
1 parent e264cff commit bdf03fc

File tree

18 files changed

+62
-56
lines changed

18 files changed

+62
-56
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,11 @@ 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-
llvm::sort(Seeds, [&SE](Instruction *I0, Instruction *I1) {
144+
auto Cmp = [&SE](Instruction *I0, Instruction *I1) {
145145
return Utils::atLowerAddress(cast<LoadOrStoreT>(I0),
146146
cast<LoadOrStoreT>(I1), SE);
147-
});
147+
};
148+
std::sort(Seeds.begin(), Seeds.end(), Cmp);
148149
}
149150
explicit MemSeedBundle(LoadOrStoreT *MemI) : SeedBundle(MemI) {
150151
static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,10 +2333,11 @@ 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-
llvm::sort(Frags, [](const DebugVariable &Next, const DebugVariable &Elmt) {
2337-
return Elmt.getFragmentOrDefault().SizeInBits >
2338-
Next.getFragmentOrDefault().SizeInBits;
2339-
});
2336+
std::sort(Frags.begin(), Frags.end(),
2337+
[](const DebugVariable &Next, const DebugVariable &Elmt) {
2338+
return Elmt.getFragmentOrDefault().SizeInBits >
2339+
Next.getFragmentOrDefault().SizeInBits;
2340+
});
23402341
// Check for duplicates.
23412342
assert(std::adjacent_find(Frags.begin(), Frags.end()) == Frags.end());
23422343
}

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-
llvm::sort(LRPosInfo, [](LRStartEndInfo A, LRStartEndInfo B) {
1060-
return A.Begin < B.Begin;
1061-
});
1059+
std::sort(
1060+
LRPosInfo.begin(), LRPosInfo.end(),
1061+
[](LRStartEndInfo A, LRStartEndInfo B) { return A.Begin < B.Begin; });
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-
llvm::sort(SortedItems, Comparator);
85+
std::sort(SortedItems.begin(), SortedItems.end(), Comparator);
8686

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

llvm/lib/ExecutionEngine/Orc/Core.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,9 +1142,8 @@ 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-
llvm::sort(SymbolsSorted, [](const auto &L, const auto &R) {
1146-
return *L.first < *R.first;
1147-
});
1145+
std::sort(SymbolsSorted.begin(), SymbolsSorted.end(),
1146+
[](const auto &L, const auto &R) { return *L.first < *R.first; });
11481147

11491148
for (auto &KV : SymbolsSorted) {
11501149
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-
llvm::sort(SecBlocks, [](Block *LHS, Block *RHS) {
52+
std::sort(SecBlocks.begin(), SecBlocks.end(), [](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
@@ -488,7 +488,7 @@ RawInstrProfReader<IntPtrT>::getTemporalProfTraces(
488488
return TemporalProfTraces;
489489
}
490490
// Sort functions by their timestamps to build the trace.
491-
llvm::sort(TemporalProfTimestamps);
491+
std::sort(TemporalProfTimestamps.begin(), TemporalProfTimestamps.end());
492492
TemporalProfTraceTy Trace;
493493
if (Weight)
494494
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-
llvm::sort(ReadyList, llvm::less_second());
592+
std::sort(ReadyList.begin(), ReadyList.end(), 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-
llvm::sort(ImplicitArgLoads, less_second());
227+
std::sort(ImplicitArgLoads.begin(), ImplicitArgLoads.end(), 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-
llvm::sort(Instrs,
6848-
[](SUnit *A, SUnit *B) { return A->NodeNum > B->NodeNum; });
6847+
std::sort(Instrs.begin(), Instrs.end(),
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
@@ -106,7 +106,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
106106
std::set<SPIRV::Extension::Extension> &Vals) {
107107
SmallVector<StringRef, 10> Tokens;
108108
ArgValue.split(Tokens, ",", -1, false);
109-
llvm::sort(Tokens);
109+
std::sort(Tokens.begin(), Tokens.end());
110110

111111
std::set<SPIRV::Extension::Extension> EnabledExtensions;
112112

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-
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-
});
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+
});
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-
llvm::sort(Order, [&](const auto &LHS, const auto &RHS) {
665+
std::sort(Order.begin(), Order.end(), [&](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-
llvm::sort(EnabledExtensionsInfo,
231-
[](const ExtensionInfo &Lhs, const ExtensionInfo &Rhs) {
232-
return Lhs.ArchFeatureName < Rhs.ArchFeatureName;
233-
});
230+
std::sort(EnabledExtensionsInfo.begin(), EnabledExtensionsInfo.end(),
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-
llvm::sort(SortedIds);
2948+
std::sort(SortedIds.begin(), SortedIds.end());
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-
llvm::sort(SortedIds);
2980+
std::sort(SortedIds.begin(), SortedIds.end());
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-
llvm::sort(SortedIds);
3015+
std::sort(SortedIds.begin(), SortedIds.end());
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-
llvm::sort(SortedIds);
3214+
std::sort(SortedIds.begin(), SortedIds.end());
32153215
for (auto Id : SortedIds)
32163216
IdString += (" " + Twine(Id)).str();
32173217
} else {

llvm/lib/Transforms/Utils/CodeLayout.cpp

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

988988
// Sorting chains by density in the decreasing order.
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-
});
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+
});
998999

9991000
// Collect the nodes in the order specified by their chains.
10001001
std::vector<uint64_t> Order;
@@ -1354,12 +1355,14 @@ class CDSortImpl {
13541355
}
13551356

13561357
// Sort chains by density in the decreasing order.
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-
});
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+
});
13631366

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

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

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

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

14661467
return Error::success();
14671468
}

llvm/utils/TableGen/ExegesisEmitter.cpp

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

0 commit comments

Comments
 (0)