llvm.org GIT mirror llvm / 3b35e17
llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...) Summary: The convenience wrapper in STLExtras is available since rL342102. Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits Differential Revision: https://reviews.llvm.org/D52573 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343163 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 11 months ago
124 changed file(s) with 397 addition(s) and 445 deletion(s). Raw diff Collapse all Expand all
639639
640640 template
641641 bool compareVectors(std::vector &BB1, std::vector &BB2) {
642 llvm::sort(BB1.begin(), BB1.end());
643 llvm::sort(BB2.begin(), BB2.end());
642 llvm::sort(BB1);
643 llvm::sort(BB2);
644644 return BB1 == BB2;
645645 }
646646
675675 idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
676676
677677 renumberIndexes(newItr);
678 llvm::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
678 llvm::sort(idx2MBBMap, Idx2MBBCompare());
679679 }
680680
681681 /// Free the resources that were required to maintain a SlotIndex.
543543 void InstrProfSymtab::finalizeSymtab() {
544544 if (Sorted)
545545 return;
546 llvm::sort(MD5NameMap.begin(), MD5NameMap.end(), less_first());
547 llvm::sort(MD5FuncMap.begin(), MD5FuncMap.end(), less_first());
548 llvm::sort(AddrToMD5Map.begin(), AddrToMD5Map.end(), less_first());
546 llvm::sort(MD5NameMap, less_first());
547 llvm::sort(MD5FuncMap, less_first());
548 llvm::sort(AddrToMD5Map, less_first());
549549 AddrToMD5Map.erase(std::unique(AddrToMD5Map.begin(), AddrToMD5Map.end()),
550550 AddrToMD5Map.end());
551551 Sorted = true;
104104 Operations[{U.getTo(), U.getFrom()}] = int(i);
105105 }
106106
107 llvm::sort(Result.begin(), Result.end(),
107 llvm::sort(Result,
108108 [&Operations](const Update &A, const Update &B) {
109109 return Operations[{A.getFrom(), A.getTo()}] >
110110 Operations[{B.getFrom(), B.getTo()}];
13851385 // Make a copy and sort it such that it is possible to check if there are
13861386 // no gaps between DFS numbers of adjacent children.
13871387 SmallVector Children(Node->begin(), Node->end());
1388 llvm::sort(Children.begin(), Children.end(),
1389 [](const TreeNodePtr Ch1, const TreeNodePtr Ch2) {
1390 return Ch1->getDFSNumIn() < Ch2->getDFSNumIn();
1391 });
1388 llvm::sort(Children, [](const TreeNodePtr Ch1, const TreeNodePtr Ch2) {
1389 return Ch1->getDFSNumIn() < Ch2->getDFSNumIn();
1390 });
13921391
13931392 auto PrintChildrenError = [Node, &Children, PrintNodeAndDFSNums](
13941393 const TreeNodePtr FirstCh, const TreeNodePtr SecondCh) {
137137 }
138138 }
139139
140 llvm::sort(SetFlags.begin(), SetFlags.end(), &flagName);
140 llvm::sort(SetFlags, &flagName);
141141
142142 startLine() << Label << " [ (" << hex(Value) << ")\n";
143143 for (const auto &Flag : SetFlags) {
155155
156156 static void combineWeightsBySorting(WeightList &Weights) {
157157 // Sort so edges to the same node are adjacent.
158 llvm::sort(Weights.begin(), Weights.end(),
159 [](const Weight &L,
160 const Weight &R) { return L.TargetNode < R.TargetNode; });
158 llvm::sort(Weights, [](const Weight &L, const Weight &R) {
159 return L.TargetNode < R.TargetNode;
160 });
161161
162162 // Combine adjacent edges.
163163 WeightList::iterator O = Weights.begin();
706706 "Expected irreducible CFG; -loop-info is likely invalid");
707707 if (Headers.size() == InSCC.size()) {
708708 // Every block is a header.
709 llvm::sort(Headers.begin(), Headers.end());
709 llvm::sort(Headers);
710710 return;
711711 }
712712
741741 Others.push_back(Irr.Node);
742742 LLVM_DEBUG(dbgs() << " => other = " << BFI.getBlockName(Irr.Node) << "\n");
743743 }
744 llvm::sort(Headers.begin(), Headers.end());
745 llvm::sort(Others.begin(), Others.end());
744 llvm::sort(Headers);
745 llvm::sort(Others);
746746 }
747747
748748 static void createIrreducibleLoop(
394394 }
395395
396396 // Sort AliasList for faster lookup
397 llvm::sort(AliasList.begin(), AliasList.end());
397 llvm::sort(AliasList);
398398 }
399399 }
400400
478478 }
479479
480480 // Remove duplicates in ExtRelations
481 llvm::sort(ExtRelations.begin(), ExtRelations.end());
481 llvm::sort(ExtRelations);
482482 ExtRelations.erase(std::unique(ExtRelations.begin(), ExtRelations.end()),
483483 ExtRelations.end());
484484 }
9696 for (const auto &I : *this)
9797 Nodes.push_back(I.second.get());
9898
99 llvm::sort(Nodes.begin(), Nodes.end(),
100 [](CallGraphNode *LHS, CallGraphNode *RHS) {
99 llvm::sort(Nodes, [](CallGraphNode *LHS, CallGraphNode *RHS) {
101100 if (Function *LF = LHS->getFunction())
102101 if (Function *RF = RHS->getFunction())
103102 return LF->getName() < RF->getName();
806806 DirtyBlocks.push_back(Entry.getBB());
807807
808808 // Sort the cache so that we can do fast binary search lookups below.
809 llvm::sort(Cache.begin(), Cache.end());
809 llvm::sort(Cache);
810810
811811 ++NumCacheDirtyNonLocal;
812812 // cerr << "CACHED CASE: " << DirtyBlocks.size() << " dirty: "
10691069 break;
10701070 default:
10711071 // Added many values, do a full scale sort.
1072 llvm::sort(Cache.begin(), Cache.end());
1072 llvm::sort(Cache);
10731073 break;
10741074 }
10751075 }
16611661
16621662 // Re-sort the NonLocalDepInfo. Changing the dirty entry to its
16631663 // subsequent value may invalidate the sortedness.
1664 llvm::sort(NLPDI.begin(), NLPDI.end());
1664 llvm::sort(NLPDI);
16651665 }
16661666
16671667 ReverseNonLocalPtrDeps.erase(ReversePtrDepIt);
1106311063 Terms.erase(std::unique(Terms.begin(), Terms.end()), Terms.end());
1106411064
1106511065 // Put larger terms first.
11066 llvm::sort(Terms.begin(), Terms.end(), [](const SCEV *LHS, const SCEV *RHS) {
11066 llvm::sort(Terms, [](const SCEV *LHS, const SCEV *RHS) {
1106711067 return numberOfTerms(LHS) > numberOfTerms(RHS);
1106811068 });
1106911069
18661866 Phis.push_back(&PN);
18671867
18681868 if (TTI)
1869 llvm::sort(Phis.begin(), Phis.end(), [](Value *LHS, Value *RHS) {
1869 llvm::sort(Phis, [](Value *LHS, Value *RHS) {
18701870 // Put pointers at the back and make sure pointer < pointer = false.
18711871 if (!LHS->getType()->isIntegerTy() || !RHS->getType()->isIntegerTy())
18721872 return RHS->getType()->isIntegerTy() && !LHS->getType()->isIntegerTy();
13981398
13991399 void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef Fns) {
14001400 VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
1401 llvm::sort(VectorDescs.begin(), VectorDescs.end(), compareByScalarFnName);
1401 llvm::sort(VectorDescs, compareByScalarFnName);
14021402
14031403 ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
1404 llvm::sort(ScalarDescs.begin(), ScalarDescs.end(), compareByVectorFnName);
1404 llvm::sort(ScalarDescs, compareByVectorFnName);
14051405 }
14061406
14071407 void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
143143 void BitcodeReaderValueList::resolveConstantForwardRefs() {
144144 // Sort the values by-pointer so that they are efficient to look up with a
145145 // binary search.
146 llvm::sort(ResolveConstants.begin(), ResolveConstants.end());
146 llvm::sort(ResolveConstants);
147147
148148 SmallVector NewOps;
149149
183183 return;
184184
185185 bool IsGlobalValue = OM.isGlobalValue(ID);
186 llvm::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) {
186 llvm::sort(List, [&](const Entry &L, const Entry &R) {
187187 const Use *LU = L.first;
188188 const Use *RU = R.first;
189189 if (LU == RU)
744744 // and then sort by the original/current ID. Since the IDs are guaranteed to
745745 // be unique, the result of std::sort will be deterministic. There's no need
746746 // for std::stable_sort.
747 llvm::sort(Order.begin(), Order.end(), [this](MDIndex LHS, MDIndex RHS) {
747 llvm::sort(Order, [this](MDIndex LHS, MDIndex RHS) {
748748 return std::make_tuple(LHS.F, getMetadataTypeOrder(LHS.get(MDs)), LHS.ID) <
749749 std::make_tuple(RHS.F, getMetadataTypeOrder(RHS.get(MDs)), RHS.ID);
750750 });
23522352 for (const LocalVariable &L : Locals)
23532353 if (L.DIVar->isParameter())
23542354 Params.push_back(&L);
2355 llvm::sort(Params.begin(), Params.end(),
2356 [](const LocalVariable *L, const LocalVariable *R) {
2357 return L->DIVar->getArg() < R->DIVar->getArg();
2358 });
2355 llvm::sort(Params, [](const LocalVariable *L, const LocalVariable *R) {
2356 return L->DIVar->getArg() < R->DIVar->getArg();
2357 });
23592358 for (const LocalVariable *L : Params)
23602359 emitLocalVariable(*L);
23612360
138138 // Sort the pieces by offset.
139139 // Remove any duplicate entries by dropping all but the first.
140140 void sortUniqueValues() {
141 llvm::sort(Values.begin(), Values.end());
141 llvm::sort(Values);
142142 Values.erase(
143143 std::unique(
144144 Values.begin(), Values.end(), [](const Value &A, const Value &B) {
240240 return A.Expr->isFragment();
241241 }) &&
242242 "multiple FI expressions without DW_OP_LLVM_fragment");
243 llvm::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(),
243 llvm::sort(FrameIndexExprs,
244244 [](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool {
245245 return A.Expr->getFragmentInfo()->OffsetInBits <
246246 B.Expr->getFragmentInfo()->OffsetInBits;
611611 /// Sort and unique GVEs by comparing their fragment offset.
612612 static SmallVectorImpl &
613613 sortGlobalExprs(SmallVectorImpl &GVEs) {
614 llvm::sort(GVEs.begin(), GVEs.end(),
615 [](DwarfCompileUnit::GlobalExpr A,
616 DwarfCompileUnit::GlobalExpr B) {
617 // Sort order: first null exprs, then exprs without fragment
618 // info, then sort by fragment offset in bits.
619 // FIXME: Come up with a more comprehensive comparator so
620 // the sorting isn't non-deterministic, and so the following
621 // std::unique call works correctly.
622 if (!A.Expr || !B.Expr)
623 return !!B.Expr;
624 auto FragmentA = A.Expr->getFragmentInfo();
625 auto FragmentB = B.Expr->getFragmentInfo();
626 if (!FragmentA || !FragmentB)
627 return !!FragmentB;
628 return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
629 });
614 llvm::sort(
615 GVEs, [](DwarfCompileUnit::GlobalExpr A, DwarfCompileUnit::GlobalExpr B) {
616 // Sort order: first null exprs, then exprs without fragment
617 // info, then sort by fragment offset in bits.
618 // FIXME: Come up with a more comprehensive comparator so
619 // the sorting isn't non-deterministic, and so the following
620 // std::unique call works correctly.
621 if (!A.Expr || !B.Expr)
622 return !!B.Expr;
623 auto FragmentA = A.Expr->getFragmentInfo();
624 auto FragmentB = B.Expr->getFragmentInfo();
625 if (!FragmentA || !FragmentB)
626 return !!FragmentB;
627 return FragmentA->OffsetInBits < FragmentB->OffsetInBits;
628 });
630629 GVEs.erase(std::unique(GVEs.begin(), GVEs.end(),
631630 [](DwarfCompileUnit::GlobalExpr A,
632631 DwarfCompileUnit::GlobalExpr B) {
19991998 }
20001999
20012000 // Sort the CU list (again, to ensure consistent output order).
2002 llvm::sort(CUs.begin(), CUs.end(),
2003 [](const DwarfCompileUnit *A, const DwarfCompileUnit *B) {
2004 return A->getUniqueID() < B->getUniqueID();
2005 });
2001 llvm::sort(CUs, [](const DwarfCompileUnit *A, const DwarfCompileUnit *B) {
2002 return A->getUniqueID() < B->getUniqueID();
2003 });
20062004
20072005 // Emit an arange table for each CU we used.
20082006 for (DwarfCompileUnit *CU : CUs) {
358358 LandingPads.push_back(&PadInfos[i]);
359359
360360 // Order landing pads lexicographically by type id.
361 llvm::sort(LandingPads.begin(), LandingPads.end(),
362 [](const LandingPadInfo *L,
363 const LandingPadInfo *R) { return L->TypeIds < R->TypeIds; });
361 llvm::sort(LandingPads, [](const LandingPadInfo *L, const LandingPadInfo *R) {
362 return L->TypeIds < R->TypeIds;
363 });
364364
365365 // Compute the actions table and gather the first action index for each
366366 // landing pad site.
49884988 return LargeOffsetGEPID[LHS.first] < LargeOffsetGEPID[RHS.first];
49894989 };
49904990 // Sorting all the GEPs of the same data structures based on the offsets.
4991 llvm::sort(LargeOffsetGEPs.begin(), LargeOffsetGEPs.end(),
4992 compareGEPOffset);
4991 llvm::sort(LargeOffsetGEPs, compareGEPOffset);
49934992 LargeOffsetGEPs.erase(
49944993 std::unique(LargeOffsetGEPs.begin(), LargeOffsetGEPs.end()),
49954994 LargeOffsetGEPs.end());
218218 Opcode, TypeIdx, ElementSize,
219219 moreToWiderTypesAndLessToWidest(NumElementsActions));
220220 }
221 llvm::sort(ElementSizesSeen.begin(), ElementSizesSeen.end());
221 llvm::sort(ElementSizesSeen);
222222 SizeChangeStrategy VectorElementSizeChangeStrategy =
223223 &unsupportedForDifferentSizes;
224224 if (TypeIdx < VectorElementSizeChangeStrategies[OpcodeIdx].size() &&
327327
328328 // Sort the frame references by local offset.
329329 // Use frame index as a tie-breaker in case MI's have the same offset.
330 llvm::sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end());
330 llvm::sort(FrameReferenceInsns);
331331
332332 MachineBasicBlock *Entry = &Fn.front();
333333
133133 StringInstrMap.push_back({(i == std::string::npos) ? S : S.substr(i), II});
134134 }
135135
136 llvm::sort(StringInstrMap.begin(), StringInstrMap.end(),
137 [](const StringInstrPair &a, const StringInstrPair &b) -> bool {
138 return (a.first < b.first);
139 });
136 llvm::sort(StringInstrMap,
137 [](const StringInstrPair &a, const StringInstrPair &b) -> bool {
138 return (a.first < b.first);
139 });
140140
141141 for (auto &II : StringInstrMap) {
142142
460460 }
461461
462462 void MachineBasicBlock::sortUniqueLiveIns() {
463 llvm::sort(LiveIns.begin(), LiveIns.end(),
463 llvm::sort(LiveIns,
464464 [](const RegisterMaskPair &LI0, const RegisterMaskPair &LI1) {
465465 return LI0.PhysReg < LI1.PhysReg;
466466 });
18601860 RecRPTracker.closeBottom();
18611861
18621862 std::vector SUnits(NS.begin(), NS.end());
1863 llvm::sort(SUnits.begin(), SUnits.end(),
1864 [](const SUnit *A, const SUnit *B) {
1863 llvm::sort(SUnits, [](const SUnit *A, const SUnit *B) {
18651864 return A->NodeNum > B->NodeNum;
18661865 });
18671866
39803979 };
39813980
39823981 // sort, so that we can perform a binary search
3983 llvm::sort(Indices.begin(), Indices.end(), CompareKey);
3982 llvm::sort(Indices, CompareKey);
39843983
39853984 bool Valid = true;
39863985 (void)Valid;
15531553 if (MemOpRecords.size() < 2)
15541554 return;
15551555
1556 llvm::sort(MemOpRecords.begin(), MemOpRecords.end());
1556 llvm::sort(MemOpRecords);
15571557 unsigned ClusterLength = 1;
15581558 for (unsigned Idx = 0, End = MemOpRecords.size(); Idx < (End - 1); ++Idx) {
15591559 SUnit *SUa = MemOpRecords[Idx].SU;
156156 // Sorting all reaching defs found for a ceartin reg unit in a given BB.
157157 for (MBBDefsInfo &MBBDefs : MBBReachingDefs) {
158158 for (MBBRegUnitDefs &RegUnitDefs : MBBDefs)
159 llvm::sort(RegUnitDefs.begin(), RegUnitDefs.end());
159 llvm::sort(RegUnitDefs);
160160 }
161161
162162 return false;
995995 for (auto &I : loads)
996996 for (auto *SU : I.second)
997997 NodeNums.push_back(SU->NodeNum);
998 llvm::sort(NodeNums.begin(), NodeNums.end());
998 llvm::sort(NodeNums);
999999
10001000 // The N last elements in NodeNums will be removed, and the SU with
10011001 // the lowest NodeNum of them will become the new BarrierChain to
1324913249
1325013250 // Sort the slices so that elements that are likely to be next to each
1325113251 // other in memory are next to each other in the list.
13252 llvm::sort(LoadedSlices.begin(), LoadedSlices.end(),
13253 [](const LoadedSlice &LHS, const LoadedSlice &RHS) {
13252 llvm::sort(LoadedSlices, [](const LoadedSlice &LHS, const LoadedSlice &RHS) {
1325413253 assert(LHS.Origin == RHS.Origin && "Different bases not implemented.");
1325513254 return LHS.getOffsetFromBase() < RHS.getOffsetFromBase();
1325613255 });
1424614245
1424714246 // Sort the memory operands according to their distance from the
1424814247 // base pointer.
14249 llvm::sort(StoreNodes.begin(), StoreNodes.end(),
14250 [](MemOpLink LHS, MemOpLink RHS) {
14251 return LHS.OffsetFromBase < RHS.OffsetFromBase;
14252 });
14248 llvm::sort(StoreNodes, [](MemOpLink LHS, MemOpLink RHS) {
14249 return LHS.OffsetFromBase < RHS.OffsetFromBase;
14250 });
1425314251
1425414252 // Store Merge attempts to merge the lowest stores. This generally
1425514253 // works out as if successful, as the remaining stores are checked
241241 return;
242242
243243 // Sort them in increasing order.
244 llvm::sort(Offsets.begin(), Offsets.end());
244 llvm::sort(Offsets);
245245
246246 // Check if the loads are close enough.
247247 SmallVector Loads;
80158015 }
80168016
80178017 // Sort the uses, so that all the uses from a given User are together.
8018 llvm::sort(Uses.begin(), Uses.end());
8018 llvm::sort(Uses);
80198019
80208020 for (unsigned UseIndex = 0, UseIndexEnd = Uses.size();
80218021 UseIndex != UseIndexEnd; ) {
25792579 assert(CC.Low == CC.High && "Input clusters must be single-case");
25802580 #endif
25812581
2582 llvm::sort(Clusters.begin(), Clusters.end(),
2583 [](const CaseCluster &a, const CaseCluster &b) {
2582 llvm::sort(Clusters, [](const CaseCluster &a, const CaseCluster &b) {
25842583 return a.Low->getValue().slt(b.Low->getValue());
25852584 });
25862585
62516250 GA->getGlobal(), getCurSDLoc(),
62526251 Val.getValueType(), GA->getOffset())});
62536252 }
6254 llvm::sort(Targets.begin(), Targets.end(),
6253 llvm::sort(Targets,
62556254 [](const BranchFunnelTarget &T1, const BranchFunnelTarget &T2) {
62566255 return T1.Offset < T2.Offset;
62576256 });
96699668 }
96709669
96719670 BitTestInfo BTI;
9672 llvm::sort(CBV.begin(), CBV.end(), [](const CaseBits &a, const CaseBits &b) {
9671 llvm::sort(CBV, [](const CaseBits &a, const CaseBits &b) {
96739672 // Sort by probability first, number of bits second, bit mask third.
96749673 if (a.ExtraProb != b.ExtraProb)
96759674 return a.ExtraProb > b.ExtraProb;
9494 }
9595
9696 // Sort the Idx2MBBMap
97 llvm::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
97 llvm::sort(idx2MBBMap, Idx2MBBCompare());
9898
9999 LLVM_DEBUG(mf->print(dbgs(), this));
100100
12301230 });
12311231
12321232 for (auto &s : LiveStarts)
1233 llvm::sort(s.begin(), s.end());
1233 llvm::sort(s);
12341234
12351235 bool Changed = true;
12361236 while (Changed) {
267267 // in the list. Merge entries that refer to the same dwarf register and use
268268 // the maximum size that needs to be spilled.
269269
270 llvm::sort(LiveOuts.begin(), LiveOuts.end(),
271 [](const LiveOutReg &LHS, const LiveOutReg &RHS) {
272 // Only sort by the dwarf register number.
273 return LHS.DwarfRegNum < RHS.DwarfRegNum;
274 });
270 llvm::sort(LiveOuts, [](const LiveOutReg &LHS, const LiveOutReg &RHS) {
271 // Only sort by the dwarf register number.
272 return LHS.DwarfRegNum < RHS.DwarfRegNum;
273 });
275274
276275 for (auto I = LiveOuts.begin(), E = LiveOuts.end(); I != E; ++I) {
277276 for (auto II = std::next(I); II != E; ++II) {
213213 Intervals.reserve(LS->getNumIntervals());
214214 for (auto &I : *LS)
215215 Intervals.push_back(&I);
216 llvm::sort(Intervals.begin(), Intervals.end(),
216 llvm::sort(Intervals,
217217 [](Pair *LHS, Pair *RHS) { return LHS->first < RHS->first; });
218218
219219 // Gather all spill slots into a list.
7878 for (const auto &M : Mappings)
7979 Ids.push_back(&M);
8080
81 llvm::sort(Ids.begin(), Ids.end(), [this](const T &L1, const T &L2) {
81 llvm::sort(Ids, [this](const T &L1, const T &L2) {
8282 return Strings.getIdForString(L1->getKey()) <
8383 Strings.getIdForString(L2->getKey());
8484 });
9090 Result.reserve(IdToString.size());
9191 for (const auto &Entry : IdToString)
9292 Result.push_back(Entry.first);
93 llvm::sort(Result.begin(), Result.end());
93 llvm::sort(Result);
9494 return Result;
9595 }
9696
105105 // Sort the contributions so that any invalid ones are placed at
106106 // the start of the contributions vector. This way they are reported
107107 // first.
108 llvm::sort(Contributions.begin(), Contributions.end(),
108 llvm::sort(Contributions,
109109 [](const Optional &L,
110110 const Optional &R) {
111 if (L && R) return L->Base < R->Base;
111 if (L && R)
112 return L->Base < R->Base;
112113 return R.hasValue();
113114 });
114115
7979 void DWARFDebugAranges::construct() {
8080 std::multiset ValidCUs; // Maintain the set of CUs describing
8181 // a current address range.
82 llvm::sort(Endpoints.begin(), Endpoints.end());
82 llvm::sort(Endpoints);
8383 uint64_t PrevAddress = -1ULL;
8484 for (const auto &E : Endpoints) {
8585 if (PrevAddress < E.Address && !ValidCUs.empty()) {
838838
839839 // Sort all sequences so that address lookup will work faster.
840840 if (!Sequences.empty()) {
841 llvm::sort(Sequences.begin(), Sequences.end(), Sequence::orderByLowPC);
841 llvm::sort(Sequences, Sequence::orderByLowPC);
842842 // Note: actually, instruction address ranges of sequences should not
843843 // overlap (in shared objects and executables). If they do, the address
844844 // lookup would still work, though, but result would be ambiguous.
143143 // can properly early-out when it detects the record won't be found. The
144144 // algorithm used here corredsponds to the function
145145 // caseInsensitiveComparePchPchCchCch in the reference implementation.
146 llvm::sort(Bucket.begin(), Bucket.end(),
147 [](const std::pair &Left,
148 const std::pair &Right) {
149 return gsiRecordLess(Left.first, Right.first);
150 });
146 llvm::sort(Bucket, [](const std::pair &Left,
147 const std::pair &Right) {
148 return gsiRecordLess(Left.first, Right.first);
149 });
151150
152151 for (const auto &Entry : Bucket)
153152 HashRecords.push_back(Entry.second);
198198 !isa(V) && !isa(V) && !isa(V);
199199 if (auto *BA = dyn_cast(V))
200200 ID = OM.lookup(BA->getBasicBlock()).first;
201 llvm::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) {
201 llvm::sort(List, [&](const Entry &L, const Entry &R) {
202202 const Use *LU = L.first;
203203 const Use *RU = R.first;
204204 if (LU == RU)
657657 FoldingSetNodeID ID;
658658
659659 SmallVector SortedAttrs(Attrs.begin(), Attrs.end());
660 llvm::sort(SortedAttrs.begin(), SortedAttrs.end());
660 llvm::sort(SortedAttrs);
661661
662662 for (const auto Attr : SortedAttrs)
663663 Attr.Profile(ID);
236236 // Copy out uses since UseMap will get touched below.
237237 using UseTy = std::pair>;
238238 SmallVector Uses(UseMap.begin(), UseMap.end());
239 llvm::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) {
239 llvm::sort(Uses, [](const UseTy &L, const UseTy &R) {
240240 return L.second.second < R.second.second;
241241 });
242242 for (const auto &Pair : Uses) {
289289 // Copy out uses since UseMap could get touched below.
290290 using UseTy = std::pair>;
291291 SmallVector Uses(UseMap.begin(), UseMap.end());
292 llvm::sort(Uses.begin(), Uses.end(), [](const UseTy &L, const UseTy &R) {
292 llvm::sort(Uses, [](const UseTy &L, const UseTy &R) {
293293 return L.second.second < R.second.second;
294294 });
295295 UseMap.clear();
22992299 if (isa(BB.front())) {
23002300 SmallVector Preds(pred_begin(&BB), pred_end(&BB));
23012301 SmallVector, 8> Values;
2302 llvm::sort(Preds.begin(), Preds.end());
2302 llvm::sort(Preds);
23032303 for (const PHINode &PN : BB.phis()) {
23042304 // Ensure that PHI nodes have at least one entry!
23052305 Assert(PN.getNumIncomingValues() != 0,
23172317 for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
23182318 Values.push_back(
23192319 std::make_pair(PN.getIncomingBlock(i), PN.getIncomingValue(i)));
2320 llvm::sort(Values.begin(), Values.end());
2320 llvm::sort(Values);
23212321
23222322 for (unsigned i = 0, e = Values.size(); i != e; ++i) {
23232323 // Check to make sure that if there is more than one entry for a
967967 std::vector ModulesOrdering;
968968 ModulesOrdering.resize(Modules.size());
969969 std::iota(ModulesOrdering.begin(), ModulesOrdering.end(), 0);
970 llvm::sort(ModulesOrdering.begin(), ModulesOrdering.end(),
971 [&](int LeftIndex, int RightIndex) {
972 auto LSize = Modules[LeftIndex].getBuffer().size();
973 auto RSize = Modules[RightIndex].getBuffer().size();
974 return LSize > RSize;
975 });
970 llvm::sort(ModulesOrdering, [&](int LeftIndex, int RightIndex) {
971 auto LSize = Modules[LeftIndex].getBuffer().size();
972 auto RSize = Modules[RightIndex].getBuffer().size();
973 return LSize > RSize;
974 });
976975
977976 // Parallel optimizer + codegen
978977 {
596596 }
597597
598598 // External and undefined symbols are required to be in lexicographic order.
599 llvm::sort(ExternalSymbolData.begin(), ExternalSymbolData.end());
600 llvm::sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end());
599 llvm::sort(ExternalSymbolData);
600 llvm::sort(UndefinedSymbolData);
601601
602602 // Set the symbol indices.
603603 Index = 0;
557557 std::vector Arr;
558558 for (auto &Section : Sections)
559559 Arr.push_back(Section.get());
560 llvm::sort(Arr.begin(), Arr.end(),
561 [](const COFFSection *A, const COFFSection *B) {
562 return A->Number < B->Number;
563 });
560 llvm::sort(Arr, [](const COFFSection *A, const COFFSection *B) {
561 return A->Number < B->Number;
562 });
564563
565564 for (auto &Section : Arr) {
566565 if (Section->Number == -1)
8282 return Counter::getZero();
8383
8484 // Group the terms by counter ID.
85 llvm::sort(Terms.begin(), Terms.end(), [](const Term &LHS, const Term &RHS) {
85 llvm::sort(Terms, [](const Term &LHS, const Term &RHS) {
8686 return LHS.CounterID < RHS.CounterID;
8787 });
8888
462462
463463 /// Sort a nested sequence of regions from a single file.
464464 static void sortNestedRegions(MutableArrayRef Regions) {
465 llvm::sort(Regions.begin(), Regions.end(), [](const CountedRegion &LHS,
466 const CountedRegion &RHS) {
465 llvm::sort(Regions, [](const CountedRegion &LHS, const CountedRegion &RHS) {
467466 if (LHS.startLoc() != RHS.startLoc())
468467 return LHS.startLoc() < RHS.startLoc();
469468 if (LHS.endLoc() != RHS.endLoc())
560559 for (const auto &Function : getCoveredFunctions())
561560 Filenames.insert(Filenames.end(), Function.Filenames.begin(),
562561 Function.Filenames.end());
563 llvm::sort(Filenames.begin(), Filenames.end());
562 llvm::sort(Filenames);
564563 auto Last = std::unique(Filenames.begin(), Filenames.end());
565564 Filenames.erase(Last, Filenames.end());
566565 return Filenames;
711711 SmallVector Filenames;
712712 for (const auto &LI : LineInfo)
713713 Filenames.push_back(LI.first());
714 llvm::sort(Filenames.begin(), Filenames.end());
714 llvm::sort(Filenames);
715715
716716 for (StringRef Filename : Filenames) {
717717 auto AllLines = LineConsumer(Filename);
5757 void ProfileSummaryBuilder::computeDetailedSummary() {
5858 if (DetailedSummaryCutoffs.empty())
5959 return;
60 llvm::sort(DetailedSummaryCutoffs.begin(), DetailedSummaryCutoffs.end());
60 llvm::sort(DetailedSummaryCutoffs);
6161 auto Iter = CountFrequencies.begin();
6262 const auto End = CountFrequencies.end();
6363
516516 std::vector Elements;
517517 for (const auto &E : O)
518518 Elements.push_back(&E);
519 llvm::sort(Elements.begin(), Elements.end(),
519 llvm::sort(Elements,
520520 [](const Object::value_type *L, const Object::value_type *R) {
521521 return L->first < R->first;
522522 });
268268 : SM(&sm), Loc(L), Filename(FN), LineNo(Line), ColumnNo(Col), Kind(Kind),
269269 Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()),
270270 FixIts(Hints.begin(), Hints.end()) {
271 llvm::sort(FixIts.begin(), FixIts.end());
271 llvm::sort(FixIts);
272272 }
273273
274274 static void buildFixItLine(std::string &CaretLine, std::string &FixItLine,
294294
295295 void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
296296 // Sort the timers in descending order by amount of time taken.
297 llvm::sort(TimersToPrint.begin(), TimersToPrint.end());
297 llvm::sort(TimersToPrint);
298298
299299 TimeRecord Total;
300300 for (const PrintRecord &Record : TimersToPrint)
157157
158158 SmallVector Classes(UnsortedClasses.begin(),
159159 UnsortedClasses.end());
160 llvm::sort(Classes.begin(), Classes.end(),
161 [](Record *LHS, Record *RHS) {
162 return LHS->getNameInitAsString() < RHS->getNameInitAsString();
163 });
160 llvm::sort(Classes, [](Record *LHS, Record *RHS) {
161 return LHS->getNameInitAsString() < RHS->getNameInitAsString();
162 });
164163
165164 FoldingSetNodeID ID;
166165 ProfileRecordRecTy(ID, Classes);
376376
377377 // Now we have a set of sets, order them by start address so
378378 // we can iterate over them sequentially.
379 llvm::sort(V.begin(), V.end(),
380 [](const std::vector &A,
381 const std::vector &B) {
382 return A.front()->startsBefore(B.front());
383 });
379 llvm::sort(V,
380 [](const std::vector &A, const std::vector &B) {
381 return A.front()->startsBefore(B.front());
382 });
384383
385384 // As we only have two colors, we can track the global (BB-level) balance of
386385 // odds versus evens. We aim to keep this near zero to keep both execution
452451 // change them to!
453452 // Final tie-break with instruction order so pass output is stable (i.e. not
454453 // dependent on malloc'd pointer values).
455 llvm::sort(GV.begin(), GV.end(), [](const Chain *G1, const Chain *G2) {
456 if (G1->size() != G2->size())
457 return G1->size() > G2->size();
458 if (G1->requiresFixup() != G2->requiresFixup())
459 return G1->requiresFixup() > G2->requiresFixup();
460 // Make sure startsBefore() produces a stable final order.
461 assert((G1 == G2 || (G1->startsBefore(G2) ^ G2->startsBefore(G1))) &&
462 "Starts before not total order!");
463 return G1->startsBefore(G2);
464 });
454 llvm::sort(GV, [](const Chain *G1, const Chain *G2) {
455 if (G1->size() != G2->size())
456 return G1->size() > G2->size();
457 if (G1->requiresFixup() != G2->requiresFixup())
458 return G1->requiresFixup() > G2->requiresFixup();
459 // Make sure startsBefore() produces a stable final order.
460 assert((G1 == G2 || (G1->startsBefore(G2) ^ G2->startsBefore(G1))) &&
461 "Starts before not total order!");
462 return G1->startsBefore(G2);
463 });
465464
466465 Color PreferredColor = Parity < 0 ? Color::Even : Color::Odd;
467466 while (Chain *G = getAndEraseNext(PreferredColor, GV)) {
433433 // Sort recorded regions by pressure - highest at the front
434434 void GCNIterativeScheduler::sortRegionsByPressure(unsigned TargetOcc) {
435435 const auto &ST = MF.getSubtarget();
436 llvm::sort(Regions.begin(), Regions.end(),
437 [&ST, TargetOcc](const Region *R1, const Region *R2) {
436 llvm::sort(Regions, [&ST, TargetOcc](const Region *R1, const Region *R2) {
438437 return R2->MaxPressure.less(ST, R1->MaxPressure, TargetOcc);
439438 });
440439 }
167167 CoveringSubregs.push_back(Idx);
168168 }
169169
170 llvm::sort(CoveringSubregs.begin(), CoveringSubregs.end(),
171 [this](unsigned A, unsigned B) {
172 LaneBitmask MaskA = TRI->getSubRegIndexLaneMask(A);
173 LaneBitmask MaskB = TRI->getSubRegIndexLaneMask(B);
174 unsigned NA = MaskA.getNumLanes();
175 unsigned NB = MaskB.getNumLanes();
176 if (NA != NB)
177 return NA > NB;
178 return MaskA.getHighestLane() > MaskB.getHighestLane();
179 });
170 llvm::sort(CoveringSubregs, [this](unsigned A, unsigned B) {
171 LaneBitmask MaskA = TRI->getSubRegIndexLaneMask(A);
172 LaneBitmask MaskB = TRI->getSubRegIndexLaneMask(B);
173 unsigned NA = MaskA.getNumLanes();
174 unsigned NB = MaskB.getNumLanes();
175 if (NA != NB)
176 return NA > NB;
177 return MaskA.getHighestLane() > MaskB.getHighestLane();
178 });
180179
181180 for (unsigned Idx : CoveringSubregs) {
182181 LaneBitmask SubRegMask = TRI->getSubRegIndexLaneMask(Idx);
14431443 SmallVector ScratchRegs;
14441444 for(unsigned I = 5; I < MI->getNumOperands(); ++I)
14451445 ScratchRegs.push_back(MI->getOperand(I).getReg());
1446 llvm::sort(ScratchRegs.begin(), ScratchRegs.end(),
1447 [&TRI](const unsigned &Reg1,
1448 const unsigned &Reg2) -> bool {
1446 llvm::sort(ScratchRegs,
1447 [&TRI](const unsigned &Reg1, const unsigned &Reg2) -> bool {
14491448 return TRI.getEncodingValue(Reg1) <
14501449 TRI.getEncodingValue(Reg2);
14511450 });
10071007 if (Regs.empty())
10081008 continue;
10091009
1010 llvm::sort(Regs.begin(), Regs.end(), [&](const RegAndKill &LHS,
1011 const RegAndKill &RHS) {
1010 llvm::sort(Regs, [&](const RegAndKill &LHS, const RegAndKill &RHS) {
10121011 return TRI.getEncodingValue(LHS.first) < TRI.getEncodingValue(RHS.first);
10131012 });
10141013
11041103 if (Regs.empty())
11051104 continue;
11061105
1107 llvm::sort(Regs.begin(), Regs.end(), [&](unsigned LHS, unsigned RHS) {
1106 llvm::sort(Regs, [&](unsigned LHS, unsigned RHS) {
11081107 return TRI.getEncodingValue(LHS) < TRI.getEncodingValue(RHS);
11091108 });
11101109
18471847 auto LessThan = [](const MergeCandidate* M0, const MergeCandidate *M1) {
18481848 return M0->InsertPos < M1->InsertPos;
18491849 };
1850 llvm::sort(Candidates.begin(), Candidates.end(), LessThan);
1850 llvm::sort(Candidates, LessThan);
18511851
18521852 // Go through list of candidates and merge.
18531853 bool Changed = false;
21852185 bool RetVal = false;
21862186
21872187 // Sort by offset (in reverse order).
2188 llvm::sort(Ops.begin(), Ops.end(),
2189 [](const MachineInstr *LHS, const MachineInstr *RHS) {
2190 int LOffset = getMemoryOpOffset(*LHS);
2191 int ROffset = getMemoryOpOffset(*RHS);
2192 assert(LHS == RHS || LOffset != ROffset);
2193 return LOffset > ROffset;
2194 });
2188 llvm::sort(Ops, [](const MachineInstr *LHS, const MachineInstr *RHS) {
2189 int LOffset = getMemoryOpOffset(*LHS);
2190 int ROffset = getMemoryOpOffset(*RHS);
2191 assert(LHS == RHS || LOffset != ROffset);
2192 return LOffset > ROffset;
2193 });
21952194
21962195 // The loads / stores of the same base are in order. Scan them from first to
21972196 // last and check for the following:
10711071 if (Contents.empty())
10721072 return;
10731073
1074 llvm::sort(Contents.begin(), Contents.end(), AttributeItem::LessTag);
1074 llvm::sort(Contents, AttributeItem::LessTag);
10751075
10761076 ARMELFStreamer &Streamer = getStreamer();
10771077
19461946 AssignmentMap IMap;
19471947
19481948 collect(MF);
1949 llvm::sort(Extenders.begin(), Extenders.end(),
1950 [](const ExtDesc &A, const ExtDesc &B) {
1951 return ExtValue(A) < ExtValue(B);
1952 });
1949 llvm::sort(Extenders, [](const ExtDesc &A, const ExtDesc &B) {
1950 return ExtValue(A) < ExtValue(B);
1951 });
19531952
19541953 bool Changed = false;
19551954 LLVM_DEBUG(dbgs() << "Collected " << Extenders.size() << " extenders\n");
631631 SortableVectorType VRs;
632632 for (RegisterOrdering::iterator I = RB.begin(), E = RB.end(); I != E; ++I)
633633 VRs.push_back(I->first);
634 llvm::sort(VRs.begin(), VRs.end(), LexCmp);
634 llvm::sort(VRs, LexCmp);
635635 // Transfer the results to the outgoing register ordering.
636636 for (unsigned i = 0, n = VRs.size(); i < n; ++i)
637637 RO.insert(std::make_pair(VRs[i], i));
577577 };
578578 for (auto &G : SGs) {
579579 assert(G.size() > 1 && "Store group with fewer than 2 elements");
580 llvm::sort(G.begin(), G.end(), Less);
580 llvm::sort(G, Less);
581581
582582 Changed |= processStoreGroup(G);
583583 }
213213 return false;
214214 return A.Id < B.Id;
215215 };
216 llvm::sort(DRNs.begin(), DRNs.end(), UsesFirst);
216 llvm::sort(DRNs, UsesFirst);
217217
218218 if (trace())
219219 dbgs() << "Removing dead ref nodes:\n";
14701470 // and add a def for each S in the closure.
14711471
14721472 // Sort the refs so that the phis will be created in a deterministic order.
1473 llvm::sort(MaxRefs.begin(), MaxRefs.end());
1473 llvm::sort(MaxRefs);
14741474 // Remove duplicates.
14751475 auto NewEnd = std::unique(MaxRefs.begin(), MaxRefs.end());
14761476 MaxRefs.erase(NewEnd, MaxRefs.end());
206206 };
207207
208208 std::vector Tmp(Owners.begin(), Owners.end());
209 llvm::sort(Tmp.begin(), Tmp.end(), Less);
209 llvm::sort(Tmp, Less);
210210
211211 // The vector is a list of instructions, so that defs coming from
212212 // the same instruction don't need to be artificially ordered.
812812 std::vector LV;
813813 for (auto I = B.livein_begin(), E = B.livein_end(); I != E; ++I)
814814 LV.push_back(RegisterRef(I->PhysReg, I->LaneMask));
815 llvm::sort(LV.begin(), LV.end());
815 llvm::sort(LV);
816816 dbgs() << printMBBReference(B) << "\t rec = {";
817817 for (auto I : LV)
818818 dbgs() << ' ' << Print(I, DFG);
823823 const RegisterAggr &LG = LiveMap[&B];
824824 for (auto I = LG.rr_begin(), E = LG.rr_end(); I != E; ++I)
825825 LV.push_back(*I);
826 llvm::sort(LV.begin(), LV.end());
826 llvm::sort(LV);
827827 dbgs() << "\tcomp = {";
828828 for (auto I : LV)
829829 dbgs() << ' ' << Print(I, DFG);
452452 return;
453453
454454 // Sort relocations by the address they are applied to.
455 llvm::sort(Relocs.begin(), Relocs.end(),
455 llvm::sort(Relocs,
456456 [](const ELFRelocationEntry &A, const ELFRelocationEntry &B) {
457457 return A.Offset < B.Offset;
458458 });
14001400 for (auto &I : ValueRots) {
14011401 ValueRotsVec.push_back(I.second);
14021402 }
1403 llvm::sort(ValueRotsVec.begin(), ValueRotsVec.end());
1403 llvm::sort(ValueRotsVec);
14041404 }
14051405
14061406 // In 64-bit mode, rlwinm and friends have a rotation operator that
117117 // registers), by weight next, and then by position.
118118 // TODO: Investigate more intelligent sorting heuristics. For starters, we
119119 // should try to coalesce adjacent live intervals before non-adjacent ones.
120 llvm::sort(SortedIntervals.begin(), SortedIntervals.end(),
121 [MRI](LiveInterval *LHS, LiveInterval *RHS) {
122 if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg))
123 return MRI->isLiveIn(LHS->reg);
124 if (LHS->weight != RHS->weight)
125 return LHS->weight > RHS->weight;
126 if (LHS->empty() || RHS->empty())
127 return !LHS->empty() && RHS->empty();
128 return *LHS < *RHS;
129 });
120 llvm::sort(SortedIntervals, [MRI](LiveInterval *LHS, LiveInterval *RHS) {
121 if (MRI->isLiveIn(LHS->reg) != MRI->isLiveIn(RHS->reg))
122 return MRI->isLiveIn(LHS->reg);
123 if (LHS->weight != RHS->weight)
124 return LHS->weight > RHS->weight;
125 if (LHS->empty() || RHS->empty())
126 return !LHS->empty() && RHS->empty();
127 return *LHS < *RHS;
128 });
130129
131130 LLVM_DEBUG(dbgs() << "Coloring register intervals:\n");
132131 SmallVector SlotMapping(SortedIntervals.size(), -1u);
827827 "split above!");
828828
829829 // Sort and unique the codes to minimize them.
830 llvm::sort(UncondCodeSeq.begin(), UncondCodeSeq.end());
830 llvm::sort(UncondCodeSeq);
831831 UncondCodeSeq.erase(std::unique(UncondCodeSeq.begin(), UncondCodeSeq.end()),
832832 UncondCodeSeq.end());
833833
150150 Offset,
151151 FramePtr));
152152 }
153 llvm::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset);
153 llvm::sort(SpillList, CompareSSIOffset);
154154 }
155155
156156 /// Creates an ordered list of EH info register 'spills'.
169169 SpillList.push_back(
170170 StackSlotInfo(EHSlot[0], MFI.getObjectOffset(EHSlot[1]),
171171 TL->getExceptionSelectorRegister(PersonalityFn)));
172 llvm::sort(SpillList.begin(), SpillList.end(), CompareSSIOffset);
172 llvm::sort(SpillList, CompareSSIOffset);
173173 }
174174
175175 static MachineMemOperand *getFrameIndexMMO(MachineBasicBlock &MBB,
128128 static bool replaceConstantExprOp(ConstantExpr *CE, Pass *P) {
129129 do {
130130 SmallVector WUsers(CE->user_begin(), CE->user_end());
131 llvm::sort(WUsers.begin(), WUsers.end());
131 llvm::sort(WUsers);
132132 WUsers.erase(std::unique(WUsers.begin(), WUsers.end()), WUsers.end());
133133 while (!WUsers.empty())
134134 if (WeakTrackingVH WU = WUsers.pop_back_val()) {
4848 BlockToIndexMapping(Function &F) {
4949 for (BasicBlock &BB : F)
5050 V.push_back(&BB);
51 llvm::sort(V.begin(), V.end());
51 llvm::sort(V);
5252 }
5353
5454 size_t blockToIndex(BasicBlock *BB) const {
19961996 }
19971997 Sets.emplace_back(I, MaxUniqueId);
19981998 }
1999 llvm::sort(Sets.begin(), Sets.end(),
1999 llvm::sort(Sets,
20002000 [](const std::pair &S1,
20012001 const std::pair &S2) {
20022002 return S1.second < S2.second;
20212021
20222022 // Order type identifiers by unique ID for determinism. This ordering is
20232023 // stable as there is a one-to-one mapping between metadata and unique IDs.
2024 llvm::sort(TypeIds.begin(), TypeIds.end(), [&](Metadata *M1, Metadata *M2) {
2024 llvm::sort(TypeIds, [&](Metadata *M1, Metadata *M2) {
20252025 return TypeIdInfo[M1].UniqueId < TypeIdInfo[M2].UniqueId;
20262026 });
20272027
20282028 // Same for the branch funnels.
2029 llvm::sort(ICallBranchFunnels.begin(), ICallBranchFunnels.end(),
2029 llvm::sort(ICallBranchFunnels,
20302030 [&](ICallBranchFunnel *F1, ICallBranchFunnel *F2) {
20312031 return F1->UniqueId < F2->UniqueId;
20322032 });
680680 Sum += NameFS.second.getEntrySamples();
681681 R.push_back(&NameFS.second);
682682 }
683 llvm::sort(R.begin(), R.end(),
684 [](const FunctionSamples *L, const FunctionSamples *R) {
685 if (L->getEntrySamples() != R->getEntrySamples())
686 return L->getEntrySamples() > R->getEntrySamples();
687 return FunctionSamples::getGUID(L->getName()) <
688 FunctionSamples::getGUID(R->getName());
689 });
683 llvm::sort(R, [](const FunctionSamples *L, const FunctionSamples *R) {
684 if (L->getEntrySamples() != R->getEntrySamples())
685 return L->getEntrySamples() > R->getEntrySamples();
686 return FunctionSamples::getGUID(L->getName()) <
687 FunctionSamples::getGUID(R->getName());
688 });
690689 }
691690 return R;
692691 }
11731172 SmallVector R;
11741173 for (auto I = M.begin(); I != M.end(); ++I)
11751174 R.push_back({FunctionSamples::getGUID(I->getKey()), I->getValue()});
1176 llvm::sort(R.begin(), R.end(),
1177 [](const InstrProfValueData &L, const InstrProfValueData &R) {
1178 if (L.Count == R.Count)
1179 return L.Value > R.Value;
1180 else
1181 return L.Count > R.Count;
1182 });
1175 llvm::sort(R, [](const InstrProfValueData &L, const InstrProfValueData &R) {
1176 if (L.Count == R.Count)
1177 return L.Value > R.Value;
1178 else
1179 return L.Count > R.Count;
1180 });
11831181 return R;
11841182 }
11851183
747747 // TODO: Remove fully-redundant expressions.
748748 // Get instruction from the Map, assume that all the Instructions
749749 // with same VNs have same rank (this is an approximation).
750 llvm::sort(Ranks.begin(), Ranks.end(),
751 [this, &Map](const VNType &r1, const VNType &r2) {
752 return (rank(*Map.lookup(r1).begin()) <
753 rank(*Map.lookup(r2).begin()));
754 });
750 llvm::sort(Ranks, [this, &Map](const VNType &r1, const VNType &r2) {
751 return (rank(*Map.lookup(r1).begin()) < rank(*Map.lookup(r2).begin()));
752 });
755753
756754 // - Sort VNs according to their rank, and start with lowest ranked VN
757755 // - Take a VN and for each instruction with same VN
238238 SmallVector, 4> Ops;
239239 for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I)
240240 Ops.push_back({PN->getIncomingBlock(I), PN->getIncomingValue(I)});
241 llvm::sort(Ops.begin(), Ops.end());
241 llvm::sort(Ops);
242242 for (auto &P : Ops) {
243243 Blocks.push_back(P.first);
244244 Values.push_back(P.second);
761761 }
762762 if (Preds.size() < 2)
763763 return 0;
764 llvm::sort(Preds.begin(), Preds.end());
764 llvm::sort(Preds);
765765
766766 unsigned NumOrigPreds = Preds.size();
767767 // We can only sink instructions through unconditional branches.
697697 // CurrentChecks.size() will typically be 3 here, but so far there has been
698698 // no need to hard-code that fact.
699699
700 llvm::sort(CurrentChecks.begin(), CurrentChecks.end(),
701 [&](const GuardWideningImpl::RangeCheck &LHS,
702 const GuardWideningImpl::RangeCheck &RHS) {
700 llvm::sort(CurrentChecks, [&](const GuardWideningImpl::RangeCheck &LHS,
701 const GuardWideningImpl::RangeCheck &RHS) {
703702 return LHS.getOffsetValue().slt(RHS.getOffsetValue());
704703 });
705704
207207 SmallVector SortedBBsToSinkInto;
208208 SortedBBsToSinkInto.insert(SortedBBsToSinkInto.begin(), BBsToSinkInto.begin(),
209209 BBsToSinkInto.end());
210 llvm::sort(SortedBBsToSinkInto.begin(), SortedBBsToSinkInto.end(),
211 [&](BasicBlock *A, BasicBlock *B) {
212 return LoopBlockNumber.find(A)->second <
213 LoopBlockNumber.find(B)->second;
214 });
210 llvm::sort(SortedBBsToSinkInto, [&](BasicBlock *A, BasicBlock *B) {
211 return LoopBlockNumber.find(A)->second < LoopBlockNumber.find(B)->second;
212 });
215213
216214 BasicBlock *MoveBB = *SortedBBsToSinkInto.begin();
217215 // FIXME: Optimize the efficiency for cloned value replacement. The current
14861486 SmallVector Key = F.BaseRegs;
14871487 if (F.ScaledReg) Key.push_back(F.ScaledReg);
14881488 // Unstable sort by host order ok, because this is only used for uniquifying.
1489 llvm::sort(Key.begin(), Key.end());
1489 llvm::sort(Key);
14901490 return Uniquifier.count(Key);
14911491 }
14921492
15101510 SmallVector Key = F.BaseRegs;
15111511 if (F.ScaledReg) Key.push_back(F.ScaledReg);
15121512 // Unstable sort by host order ok, because this is only used for uniquifying.
1513 llvm::sort(Key.begin(), Key.end());
1513 llvm::sort(Key);
15141514
15151515 if (!Uniquifier.insert(Key).second)
15161516 return false;
42374237 Key.push_back(F.ScaledReg);
42384238 // Unstable sort by host order ok, because this is only used for
42394239 // uniquifying.
4240 llvm::sort(Key.begin(), Key.end());
4240 llvm::sort(Key);
42414241
42424242 std::pair P =
42434243 BestFormulae.insert(std::make_pair(Key, FIdx));
464464 #endif // MERGEICMPS_DOT_ON
465465 // Reorder blocks by LHS. We can do that without changing the
466466 // semantics because we are only accessing dereferencable memory.
467 llvm::sort(Comparisons_.begin(), Comparisons_.end(),
468 [](const BCECmpBlock &a, const BCECmpBlock &b) {
469 return a.Lhs() < b.Lhs();
470 });
467 llvm::sort(Comparisons_, [](const BCECmpBlock &a, const BCECmpBlock &b) {
468 return a.Lhs() < b.Lhs();
469 });
471470 #ifdef MERGEICMPS_DOT_ON
472471 errs() << "AFTER REORDERING:\n\n";
473472 dump();
958958 // order. The BlockInstRange numbers are generated in an RPO walk of the basic
959959 // blocks.
960960 void NewGVN::sortPHIOps(MutableArrayRef Ops) const {
961 llvm::sort(Ops.begin(), Ops.end(),
962 [&](const ValPair &P1, const ValPair &P2) {
961 llvm::sort(Ops, [&](const ValPair &P1, const ValPair &P2) {
963962 return BlockInstRange.lookup(P1.second).first <
964963 BlockInstRange.lookup(P2.second).first;
965964 });
39543953 convertClassToDFSOrdered(*CC, DFSOrderedSet, UseCounts, ProbablyDead);
39553954
39563955 // Sort the whole thing.
3957 llvm::sort(DFSOrderedSet.begin(), DFSOrderedSet.end());
3956 llvm::sort(DFSOrderedSet);
39583957 for (auto &VD : DFSOrderedSet) {
39593958 int MemberDFSIn = VD.DFSIn;
39603959 int MemberDFSOut = VD.DFSOut;
41174116 // If we have possible dead stores to look at, try to eliminate them.
41184117 if (CC->getStoreCount() > 0) {
41194118 convertClassToLoadsAndStores(*CC, PossibleDeadStores);
4120 llvm::sort(PossibleDeadStores.begin(), PossibleDeadStores.end());
4119 llvm::sort(PossibleDeadStores);
41214120 ValueDFSStack EliminationStack;
41224121 for (auto &VD : PossibleDeadStores) {
41234122 int MemberDFSIn = VD.DFSIn;
523523 };
524524 // We need the order of list to be stable so that naming ends up stable
525525 // when we split edges. This makes test cases much easier to write.
526 llvm::sort(PollLocations.begin(), PollLocations.end(), OrderByBBName);
526 llvm::sort(PollLocations, OrderByBBName);
527527
528528 // We can sometimes end up with duplicate poll locations. This happens if
529529 // a single loop is visited more than once. The fact this happens seems
18241824 }
18251825 }
18261826
1827 llvm::sort(Uses.begin(), Uses.end());
1827 llvm::sort(Uses);
18281828 auto Last = std::unique(Uses.begin(), Uses.end());
18291829 Uses.erase(Last, Uses.end());
18301830
10591059
10601060 // Sort the uses. This arranges for the offsets to be in ascending order,
10611061 // and the sizes to be in descending order.
1062 llvm::sort(Slices.begin(), Slices.end());
1062 llvm::sort(Slices);
10631063 }
10641064
10651065 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
19051905 "All non-integer types eliminated!");
19061906 return RHSTy->getNumElements() < LHSTy->getNumElements();
19071907 };
1908 llvm::sort(CandidateTys.begin(), CandidateTys.end(), RankVectorTypes);
1908 llvm::sort(CandidateTys, RankVectorTypes);
19091909 CandidateTys.erase(
19101910 std::unique(CandidateTys.begin(), CandidateTys.end(), RankVectorTypes),
19111911 CandidateTys.end());
42204220 }
42214221
42224222 if (!IsSorted)
4223 llvm::sort(AS.begin(), AS.end());
4223 llvm::sort(AS);
42244224
42254225 /// Describes the allocas introduced by rewritePartition in order to migrate
42264226 /// the debug info.
12641264 // matter as we're just trying to build up the map from inside-out; we use
12651265 // the map in a more stably ordered way below.
12661266 auto OrderedClonedExitsInLoops = ClonedExitsInLoops;
1267 llvm::sort(OrderedClonedExitsInLoops.begin(), OrderedClonedExitsInLoops.end(),
1268 [&](BasicBlock *LHS, BasicBlock *RHS) {
1269 return ExitLoopMap.lookup(LHS)->getLoopDepth() <
1270 ExitLoopMap.lookup(RHS)->getLoopDepth();
1271 });
1267 llvm::sort(OrderedClonedExitsInLoops, [&](BasicBlock *LHS, BasicBlock *RHS) {
1268 return ExitLoopMap.lookup(LHS)->getLoopDepth() <
1269 ExitLoopMap.lookup(RHS)->getLoopDepth();
1270 });
12721271
12731272 // Populate the existing ExitLoopMap with everything reachable from each
12741273 // exit, starting from the inner most exit.
160160
161161 void ImportedFunctionsInliningStatistics::calculateRealInlines() {
162162 // Removing duplicated Callers.
163 llvm::sort(NonImportedCallers.begin(), NonImportedCallers.end());
163 llvm::sort(NonImportedCallers);
164164 NonImportedCallers.erase(
165165 std::unique(NonImportedCallers.begin(), NonImportedCallers.end()),
166166 NonImportedCallers.end());
371371 Cases.push_back(CaseRange(Case.getCaseValue(), Case.getCaseValue(),
372372 Case.getCaseSuccessor()));
373373
374 llvm::sort(Cases.begin(), Cases.end(), CaseCmp());
374 llvm::sort(Cases, CaseCmp());
375375
376376 // Merge case into clusters
377377 if (Cases.size() >= 2) {
568568 auto Comparator = [&](const Value *A, const Value *B) {
569569 return valueComesBefore(OI, A, B);
570570 };
571 llvm::sort(OpsToRename.begin(), OpsToRename.end(), Comparator);
571 llvm::sort(OpsToRename, Comparator);
572572 ValueDFS_Compare Compare(OI);
573573 // Compute liveness, and rename in O(uses) per Op.
574574 for (auto *Op : OpsToRename) {
476476
477477 // Sort the stores by their index, making it efficient to do a lookup with a
478478 // binary search.
479 llvm::sort(StoresByIndex.begin(), StoresByIndex.end(), less_first());
479 llvm::sort(StoresByIndex, less_first());
480480
481481 // Walk all of the loads from this alloca, replacing them with the nearest
482482 // store above them, if any.
637637 SmallVector PHIBlocks;
638638 IDF.calculate(PHIBlocks);
639639 if (PHIBlocks.size() > 1)
640 llvm::sort(PHIBlocks.begin(), PHIBlocks.end(),
641 [this](BasicBlock *A, BasicBlock *B) {
642 return BBNumbers.lookup(A) < BBNumbers.lookup(B);
643 });
640 llvm::sort(PHIBlocks, [this](BasicBlock *A, BasicBlock *B) {
641 return BBNumbers.lookup(A) < BBNumbers.lookup(B);
642 });
644643
645644 unsigned CurrentVersion = 0;
646645 for (BasicBlock *BB : PHIBlocks)
751750 // Ok, now we know that all of the PHI nodes are missing entries for some
752751 // basic blocks. Start by sorting the incoming predecessors for efficient
753752 // access.
754 llvm::sort(Preds.begin(), Preds.end());
753 llvm::sort(Preds);
755754
756755 // Now we loop through all BB's which have entries in SomePHI and remove
757756 // them from the Preds list.
55205520 SmallVector Values;
55215521 for (auto &C : SI->cases())
55225522 Values.push_back(C.getCaseValue()->getValue().getSExtValue());
5523 llvm::sort(Values.begin(), Values.end());
5523 llvm::sort(Values);
55245524
55255525 // If the switch is already dense, there's nothing useful to do here.
55265526 if (isSwitchDense(Values))
180180 std::make_pair(std::distance(GVtoClusterMap.member_begin(I),
181181 GVtoClusterMap.member_end()), I));
182182
183 llvm::sort(Sets.begin(), Sets.end(),
184 [](const SortType &a, const SortType &b) {
185 if (a.first == b.first)
186 return a.second->getData()->getName() >
187 b.second->getData()->getName();
188 else
189 return a.first > b.first;
190 });
183 llvm::sort(Sets, [](const SortType &a, const SortType &b) {
184 if (a.first == b.first)
185 return a.second->getData()->getName() > b.second->getData()->getName();
186 else
187 return a.first > b.first;
188 });
191189
192190 for (auto &I : Sets) {
193191 unsigned CurrentClusterID = BalancinQueue.top().first;
483483 // the file, this allows us to just keep an index in the relocation
484484 // array that we advance during our walk, rather than resorting to
485485 // some associative container. See DwarfLinker::NextValidReloc.
486 llvm::sort(ValidRelocs.begin(), ValidRelocs.end());
486 llvm::sort(ValidRelocs);
487487 return true;
488488 }
489489
319319
320320 // The object addresses where sorted, but again, the linked
321321 // addresses might end up in a different order.
322 llvm::sort(Ranges.begin(), Ranges.end());
322 llvm::sort(Ranges);
323323
324324 if (!Ranges.empty()) {
325325 MS->SwitchSection(MC->getObjectFileInfo()->getDwarfARangesSection());
522522 if (DyLibExists && !sys::fs::exists(path)) {
523523 Components =
524524 GetAllDyLibComponents(IsInDevelopmentTree, true, DirSep);
525 llvm::sort(Components.begin(), Components.end());
525 llvm::sort(Components);
526526 break;
527527 }
528528 }
357357 getDies(DICtx, DICtx.getAppleNamespaces(), Name, Dies);
358358 getDies(DICtx, DICtx.getDebugNames(), Name, Dies);
359359 }
360 llvm::sort(Dies.begin(), Dies.end());
360 llvm::sort(Dies);
361361 Dies.erase(std::unique(Dies.begin(), Dies.end()), Dies.end());
362362
363363 for (DWARFDie Die : Dies)
667667 llvm::SmallVector &DensePressure) {
668668 // Find the number of subunits with minimal pressure (they are at the
669669 // front).
670 llvm::sort(Subunits.begin(), Subunits.end(),
671 [&DensePressure](const uint16_t A, const uint16_t B) {
672 return DensePressure[A] < DensePressure[B];
673 });
670 llvm::sort(Subunits, [&DensePressure](const uint16_t A, const uint16_t B) {
671 return DensePressure[A] < DensePressure[B];
672 });
674673 const auto getPressureForSubunit = [&DensePressure,
675674 &Subunits](size_t I) -> float & {
676675 return DensePressure[Subunits[I]];
717716 llvm::SmallVector WPRS) {
718717 // DensePressure[I] is the port pressure for Proc Resource I.
719718 llvm::SmallVector DensePressure(SM.getNumProcResourceKinds());
720 llvm::sort(WPRS.begin(), WPRS.end(),
721 [](const llvm::MCWriteProcResEntry &A,
722 const llvm::MCWriteProcResEntry &B) {
723 return A.ProcResourceIdx < B.ProcResourceIdx;
724 });
719 llvm::sort(WPRS, [](const llvm::MCWriteProcResEntry &A,
720 const llvm::MCWriteProcResEntry &B) {
721 return A.ProcResourceIdx < B.ProcResourceIdx;
722 });
725723 for (const llvm::MCWriteProcResEntry &WPR : WPRS) {
726724 // Get units for the entry.
727725 const llvm::MCProcResourceDesc *const ProcResDesc =
259259 }
260260
261261 // Remove duplicate entries and resize the input vector.
262 llvm::sort(Writes.begin(), Writes.end(),
263 [](const WriteRef &Lhs, const WriteRef &Rhs) {
264 return Lhs.getWriteState() < Rhs.getWriteState();
265 });
262 llvm::sort(Writes, [](const WriteRef &Lhs, const WriteRef &Rhs) {
263 return Lhs.getWriteState() < Rhs.getWriteState();
264 });
266265 auto It = std::unique(Writes.begin(), Writes.end());
267266 Writes.resize(std::distance(Writes.begin(), It));
268267
6363
6464 // Sort elements by mask popcount, so that we prioritize resource units over
6565 // resource groups, and smaller groups over larger groups.
66 llvm::sort(Worklist.begin(), Worklist.end(),
66 llvm::sort(Worklist,
6767 [](const ResourcePlusCycles &A, const ResourcePlusCycles &B) {
6868 unsigned popcntA = countPopulation(A.first);
6969 unsigned popcntB = countPopulation(B.first);
708708
709709 if (ReverseSort)
710710 Cmp = [=](const NMSymbol &A, const NMSymbol &B) { return Cmp(B, A); };
711 llvm::sort(SymbolList.begin(), SymbolList.end(), Cmp);
711 llvm::sort(SymbolList, Cmp);
712712 }
713713
714714 if (!PrintFileName) {
453453 Rels.push_back(Reloc);
454454
455455 // Sort relocations by address.
456 llvm::sort(Rels.begin(), Rels.end(), RelocAddressLess);
456 llvm::sort(Rels, RelocAddressLess);
457457
458458 ArrayRef Contents;
459459 error(Obj->getSectionContents(Pdata, Contents));
69216921 BaseSegmentAddress);
69226922
69236923 // Sort the symbols by address, just in case they didn't come in that way.
6924 llvm::sort(Symbols.begin(), Symbols.end(), SymbolSorter());
6924 llvm::sort(Symbols, SymbolSorter());
69256925
69266926 // Build a data in code table that is sorted on by the address of each entry.
69276927 uint64_t BaseAddress = 0;
14461446 }
14471447 }
14481448
1449 llvm::sort(DataMappingSymsAddr.begin(), DataMappingSymsAddr.end());
1450 llvm::sort(TextMappingSymsAddr.begin(), TextMappingSymsAddr.end());
1449 llvm::sort(DataMappingSymsAddr);
1450 llvm::sort(TextMappingSymsAddr);
14511451
14521452 if (Obj->isELF() && Obj->getArch() == Triple::amdgcn) {
14531453 // AMDGPU disassembler uses symbolizer for printing labels
14721472 }
14731473
14741474 // Sort relocations by address.
1475 llvm::sort(Rels.begin(), Rels.end(), RelocAddressLess);
1475 llvm::sort(Rels, RelocAddressLess);
14761476
14771477 StringRef SegmentName = "";
14781478 if (const MachOObjectFile *MachO = dyn_cast(Obj)) {
11171117
11181118 std::vector SortedIDs(IS->name_ids().begin(),
11191119 IS->name_ids().end());
1120 llvm::sort(SortedIDs.begin(), SortedIDs.end());
1120 llvm::sort(SortedIDs);
11211121 for (uint32_t I : SortedIDs) {
11221122 auto ES = IS->getStringForID(I);
11231123 llvm::SmallString<32> Str;
129129 }
130130
131131 if (Comp)
132 llvm::sort(Filtered.begin(), Filtered.end(), Comp);
132 llvm::sort(Filtered, Comp);
133133 return Filtered;
134134 }
135135
12151215 std::vector> Funcs;
12161216 while (auto Func = Functions->getNext())
12171217 Funcs.push_back(std::move(Func));
1218 llvm::sort(Funcs.begin(), Funcs.end(),
1219 opts::pretty::compareFunctionSymbols);
1218 llvm::sort(Funcs, opts::pretty::compareFunctionSymbols);
12201219 for (const auto &Func : Funcs) {
12211220 Printer.NewLine();
12221221 Dumper.start(*Func, FunctionDumper::PointerType::None);
12341233 std::vector> Datas;
12351234 while (auto Var = Vars->getNext())
12361235 Datas.push_back(std::move(Var));
1237 llvm::sort(Datas.begin(), Datas.end(),
1238 opts::pretty::compareDataSymbols);
1236 llvm::sort(Datas, opts::pretty::compareDataSymbols);
12391237 for (const auto &Var : Datas)
12401238 Dumper.start(*Var);
12411239 }
612612 RelocMap[Section].push_back(Reloc);
613613
614614 // Sort relocations by address.
615 llvm::sort(RelocMap[Section].begin(), RelocMap[Section].end(),
616 relocAddressLess);
615 llvm::sort(RelocMap[Section], relocAddressLess);
617616 }
618617 }
619618
281281 // Sort the data according to user-provided flags.
282282 switch (AccountSortOutput) {
283283 case SortField::FUNCID:
284 llvm::sort(Results.begin(), Results.end(),
285 [](const TupleType &L, const TupleType &R) {
286 if (AccountSortOrder == SortDirection::ASCENDING)
287 return std::get<0>(L) < std::get<0>(R);
288 if (AccountSortOrder == SortDirection::DESCENDING)
289 return std::get<0>(L) > std::get<0>(R);
290 llvm_unreachable("Unknown sort direction");
291 });
284 llvm::sort(Results, [](const TupleType &L, const TupleType &R) {
285 if (AccountSortOrder == SortDirection::ASCENDING)
286 return std::get<0>(L) < std::get<0>(R);
287 if (AccountSortOrder == SortDirection::DESCENDING)
288 return std::get<0>(L) > std::get<0>(R);
289 llvm_unreachable("Unknown sort direction");
290 });
292291 break;
293292 case SortField::COUNT:
294 llvm::sort(Results.begin(), Results.end(),
295 [](const TupleType &L, const TupleType &R) {
296 if (AccountSortOrder == SortDirection::ASCENDING)
297 return std::get<1>(L) < std::get<1>(R);
298 if (AccountSortOrder == SortDirection::DESCENDING)
299 return std::get<1>(L) > std::get<1>(R);
300 llvm_unreachable("Unknown sort direction");
301 });
293 llvm::sort(Results, [](const TupleType &L, const TupleType &R) {
294 if (AccountSortOrder == SortDirection::ASCENDING)
295 return std::get<1>(L) < std::get<1>(R);
296 if (AccountSortOrder == SortDirection::DESCENDING)
297 return std::get<1>(L) > std::get<1>(R);
298 llvm_unreachable("Unknown sort direction");
299 });
302300 break;
303301 default:
304302 // Here we need to look into the ResultRow for the rest of the data that
305303 // we want to sort by.
306 llvm::sort(Results.begin(), Results.end(),
307 [&](const TupleType &L, const TupleType &R) {
308 auto &LR = std::get<2>(L);
309 auto &RR = std::get<2>(R);
310 switch (AccountSortOutput) {
311 case SortField::COUNT:
312 if (AccountSortOrder == SortDirection::ASCENDING)
313 return LR.Count < RR.Count;
314 if (AccountSortOrder == SortDirection::DESCENDING)
315 return LR.Count > RR.Count;
316 llvm_unreachable("Unknown sort direction");
317 case SortField::MIN:
318 if (AccountSortOrder == SortDirection::ASCENDING)
319 return LR.Min < RR.Min;
320 if (AccountSortOrder == SortDirection::DESCENDING)
321 return LR.Min > RR.Min;
322 llvm_unreachable("Unknown sort direction");
323 case SortField::MED:
324 if (AccountSortOrder == SortDirection::ASCENDING)
325 return LR.Median < RR.Median;
326 if (AccountSortOrder == SortDirection::DESCENDING)
327 return LR.Median > RR.Median;
328 llvm_unreachable("Unknown sort direction");
329 case SortField::PCT90:
330 if (AccountSortOrder == SortDirection::ASCENDING)
331 return LR.Pct90 < RR.Pct90;
332 if (AccountSortOrder == SortDirection::DESCENDING)
333 return LR.Pct90 > RR.Pct90;
334 llvm_unreachable("Unknown sort direction");
335 case SortField::PCT99:
336 if (AccountSortOrder == SortDirection::ASCENDING)
337 return LR.Pct99 < RR.Pct99;
338 if (AccountSortOrder == SortDirection::DESCENDING)
339 return LR.Pct99 > RR.Pct99;
340 llvm_unreachable("Unknown sort direction");
341 case SortField::MAX:
342 if (AccountSortOrder == SortDirection::ASCENDING)
343 return LR.Max < RR.Max;
344 if (AccountSortOrder == SortDirection::DESCENDING)
345 return LR.Max > RR.Max;
346 llvm_unreachable("Unknown sort direction");
347 case SortField::SUM:
348 if (AccountSortOrder == SortDirection::ASCENDING)
349 return LR.Sum < RR.Sum;
350 if (AccountSortOrder == SortDirection::DESCENDING)
351 return LR.Sum > RR.Sum;
352 llvm_unreachable("Unknown sort direction");
353 default:
354 llvm_unreachable("Unsupported sort order");
355 }
356 });
304 llvm::sort(Results, [&](const TupleType &L, const TupleType &R) {
305 auto &LR = std::get<2>(L);
306 auto &RR = std::get<2>(R);
307 switch (AccountSortOutput) {
308 case SortField::COUNT:
309 if (AccountSortOrder == SortDirection::ASCENDING)
310 return LR.Count < RR.Count;
311 if (AccountSortOrder == SortDirection::DESCENDING)
312 return LR.Count > RR.Count;
313 llvm_unreachable("Unknown sort direction");
314 case SortField::MIN:
315 if (AccountSortOrder == SortDirection::ASCENDING)
316 return LR.Min < RR.Min;
317 if (AccountSortOrder == SortDirection::DESCENDING)
318 return LR.Min > RR.Min;
319 llvm_unreachable("Unknown sort direction");
320 case SortField::MED:
321 if (AccountSortOrder == SortDirection::ASCENDING)
322 return LR.Median < RR.Median;
323 if (AccountSortOrder == SortDirection::DESCENDING)
324 return LR.Median > RR.Median;
325 llvm_unreachable("Unknown sort direction");
326 case SortField::PCT90:
327 if (AccountSortOrder == SortDirection::ASCENDING)
328 return LR.Pct90 < RR.Pct90;
329 if (AccountSortOrder == SortDirection::DESCENDING)
330 return LR.Pct90 > RR.Pct90;
331 llvm_unreachable("Unknown sort direction");
332 case SortField::PCT99:
333 if (AccountSortOrder == SortDirection::ASCENDING)
334 return LR.Pct99 < RR.Pct99;
335 if (AccountSortOrder == SortDirection::DESCENDING)
336 return LR.Pct99 > RR.Pct99;
337 llvm_unreachable("Unknown sort direction");
338 case SortField::MAX:
339 if (AccountSortOrder == SortDirection::ASCENDING)
340 return LR.Max < RR.Max;
341 if (AccountSortOrder == SortDirection::DESCENDING)
342 return LR.Max > RR.Max;
343 llvm_unreachable("Unknown sort direction");
344 case SortField::SUM:
345 if (AccountSortOrder == SortDirection::ASCENDING)
346 return LR.Sum < RR.Sum;
347 if (AccountSortOrder == SortDirection::DESCENDING)
348 return LR.Sum > RR.Sum;
349 llvm_unreachable("Unknown sort direction");
350 default:
351 llvm_unreachable("Unsupported sort order");
352 }
353 });
357354 break;
358355 }
359356
416416 }
417417 }
418418
419 llvm::sort(WriteQueue.begin(), WriteQueue.end(),
420 [](const writeOperation &a, const writeOperation &b) {
421 return a.first < b.first;
422 });
419 llvm::sort(WriteQueue, [](const writeOperation &a, const writeOperation &b) {
420 return a.first < b.first;
421 });
423422
424423 for (auto writeOp : WriteQueue) {
425424 ZeroToOffset(OS, writeOp.first);
278278 Map["D"] = 3;
279279
280280 auto Keys = to_vector<4>(Map.keys());
281 llvm::sort(Keys.begin(), Keys.end());
281 llvm::sort(Keys);
282282
283283 SmallVector Expected = {"A", "B", "C", "D"};
284284 EXPECT_EQ(Expected, Keys);
292292 Set.insert("D");
293293
294294 auto Keys = to_vector<4>(Set.keys());
295 llvm::sort(Keys.begin(), Keys.end());
295 llvm::sort(Keys);
296296
297297 SmallVector Expected = {"A", "B", "C", "D"};
298298 EXPECT_EQ(Expected, Keys);
263263
264264 for (LazyCallGraph::Edge &E : A1.populate())
265265 Nodes.push_back(E.getFunction().getName());
266 llvm::sort(Nodes.begin(), Nodes.end());
266 llvm::sort(Nodes);
267267 EXPECT_EQ("a2", Nodes[0]);
268268 EXPECT_EQ("b2", Nodes[1]);
269269 EXPECT_EQ("c3", Nodes[2]);
278278
279279 for (LazyCallGraph::Edge &E : B1.populate())
280280 Nodes.push_back(E.getFunction().getName());
281 llvm::sort(Nodes.begin(), Nodes.end());
281 llvm::sort(Nodes);
282282 EXPECT_EQ("b2", Nodes[0]);
283283 EXPECT_EQ("d3", Nodes[1]);
284284 Nodes.clear();
292292
293293 for (LazyCallGraph::Edge &E : C1.populate())
294294 Nodes.push_back(E.getFunction().getName());
295 llvm::sort(Nodes.begin(), Nodes.end());
295 llvm::sort(Nodes);
296296 EXPECT_EQ("c2", Nodes[0]);
297297 EXPECT_EQ("d2", Nodes[1]);
298298 Nodes.clear();
322322 ASSERT_EQ(1, D.size());
323323 for (LazyCallGraph::Node &N : *D.begin())
324324 Nodes.push_back(N.getFunction().getName());
325 llvm::sort(Nodes.begin(), Nodes.end());
325 llvm::sort(Nodes);
326326 EXPECT_EQ(3u, Nodes.size());
327327 EXPECT_EQ("d1", Nodes[0]);
328328 EXPECT_EQ("d2", Nodes[1]);
338338 ASSERT_EQ(1, C.size());
339339 for (LazyCallGraph::Node &N : *C.begin())
340340 Nodes.push_back(N.getFunction().getName());
341 llvm::sort(Nodes.begin(), Nodes.end());
341 llvm::sort(Nodes);
342342 EXPECT_EQ(3u, Nodes.size());
343343 EXPECT_EQ("c1", Nodes[0]);
344344 EXPECT_EQ("c2", Nodes[1]);
354354 ASSERT_EQ(1, B.size());
355355 for (LazyCallGraph::Node &N : *B.begin())
356356 Nodes.push_back(N.getFunction().getName());
357 llvm::sort(Nodes.begin(), Nodes.end());
357 llvm::sort(Nodes);
358358 EXPECT_EQ(3u, Nodes.size());
359359 EXPECT_EQ("b1", Nodes[0]);
360360 EXPECT_EQ("b2", Nodes[1]);
372372 ASSERT_EQ(1, A.size());
373373 for (LazyCallGraph::Node &N : *A.begin())
374374 Nodes.push_back(N.getFunction().getName());
375 llvm::sort(Nodes.begin(), Nodes.end());
375 llvm::sort(Nodes);
376376 EXPECT_EQ(3u, Nodes.size());
377377 EXPECT_EQ("a1", Nodes[0]);
378378 EXPECT_EQ("a2", Nodes[1]);
476476 LazyCallGraph::SCC &D = *J++;
477477 for (LazyCallGraph::Node &N : D)
478478 Nodes.push_back(N.getFunction().getName());
479 llvm::sort(Nodes.begin(), Nodes.end());
479 llvm::sort(Nodes);
480480 EXPECT_EQ(3u, Nodes.size());
481481 EXPECT_EQ("d1", Nodes[0]);
482482 EXPECT_EQ("d2", Nodes[1]);
486486 LazyCallGraph::SCC &B = *J++;
487487 for (LazyCallGraph::Node &N : B)
488488 Nodes.push_back(N.getFunction().getName());
489 llvm::sort(Nodes.begin(), Nodes.end());
489 llvm::sort(Nodes);
490490 EXPECT_EQ(3u, Nodes.size());
491491 EXPECT_EQ("b1", Nodes[0]);
492492 EXPECT_EQ("b2", Nodes[1]);
496496 LazyCallGraph::SCC &C = *J++;
497497 for (LazyCallGraph::Node &N : C)
498498 Nodes.push_back(N.getFunction().getName());
499 llvm::sort(Nodes.begin(), Nodes.end());
499 llvm::sort(Nodes);
500500 EXPECT_EQ(3u, Nodes.size());
501501 EXPECT_EQ("c1", Nodes[0]);
502502 EXPECT_EQ("c2", Nodes[1]);
506506 LazyCallGraph::SCC &A = *J++;
507507 for (LazyCallGraph::Node &N : A)
508508 Nodes.push_back(N.getFunction().getName());
509 llvm::sort(Nodes.begin(), Nodes.end());
509 llvm::sort(Nodes);
510510 EXPECT_EQ(3u, Nodes.size());
511511 EXPECT_EQ("a1", Nodes[0]);
512512 EXPECT_EQ("a2", Nodes[1]);
13621362 ASSERT_LT(StoreBAccess->getID(), StoreA2Access->getID());
13631363
13641364 auto SortVecByID = [](std::vector &Defs) {
1365 llvm::sort(Defs.begin(), Defs.end(),
1366 [](const MemoryDef *LHS, const MemoryDef *RHS) {
1367 return LHS->getID() < RHS->getID();
1368 });
1365 llvm::sort(Defs, [](const MemoryDef *LHS, const MemoryDef *RHS) {
1366 return LHS->getID() < RHS->getID();
1367 });
13691368 };
13701369
13711370 auto SortedUserList = [&](const MemoryDef *MD) {
894894 ASSERT_NO_ERROR(ec);
895895 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
896896 }
897 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
898 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
897 llvm::sort(VisitedNonBrokenSymlinks);
898 llvm::sort(VisitedBrokenSymlinks);
899899 v_t ExpectedNonBrokenSymlinks = {"b", "d"};
900900 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
901901 ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
921921 ASSERT_NO_ERROR(ec);
922922 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
923923 }
924 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
925 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
924 llvm::sort(VisitedNonBrokenSymlinks);
925 llvm::sort(VisitedBrokenSymlinks);
926926 ExpectedNonBrokenSymlinks = {"b", "bb", "d", "da", "dd", "ddd", "ddd"};
927927 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
928928 ASSERT_TRUE(std::equal(VisitedNonBrokenSymlinks.begin(),
948948 ASSERT_NO_ERROR(ec);
949949 VisitedNonBrokenSymlinks.push_back(path::filename(i->path()));
950950 }
951 llvm::sort(VisitedNonBrokenSymlinks.begin(), VisitedNonBrokenSymlinks.end());
952 llvm::sort(VisitedBrokenSymlinks.begin(), VisitedBrokenSymlinks.end());
951 llvm::sort(VisitedNonBrokenSymlinks);
952 llvm::sort(VisitedBrokenSymlinks);
953953 ExpectedNonBrokenSymlinks = {"a", "b", "ba", "bb", "bc", "c", "d", "da", "dd",
954954 "ddd", "e"};
955955 ASSERT_EQ(ExpectedNonBrokenSymlinks.size(), VisitedNonBrokenSymlinks.size());
7272 for (const auto &D : Defs)
7373 Tags.push_back(Tag(D.first, locate(D.second.get())));
7474 // Emit tags.
75 llvm::sort(Tags.begin(), Tags.end());
75 llvm::sort(Tags);
7676 OS << "!_TAG_FILE_FORMAT\t1\t/original ctags format/\n";
7777 OS << "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/\n";
7878 for (const Tag &T : Tags)
13171317 SmallVector PredList;
13181318 for (const Predicate &P : Predicates)
13191319 PredList.push_back(&P);
1320 llvm::sort(PredList.begin(), PredList.end(), deref());
1320 llvm::sort(PredList, deref());
13211321
13221322 std::string Check;
13231323 for (unsigned i = 0, e = PredList.size(); i != e; ++i) {
37413741 }
37423742
37433743 // Sort so that different orders get canonicalized to the same string.
3744 llvm::sort(Preds.begin(), Preds.end());
3744 llvm::sort(Preds);
37453745 return Preds;
37463746 }
37473747
724724 //===----------------------------------------------------------------------===//
725725
726726 static void sortAndUniqueRegisters(CodeGenRegister::Vec &M) {
727 llvm::sort(M.begin(), M.end(), deref());
727 llvm::sort(M, deref());
728728 M.erase(std::unique(M.begin(), M.end(), deref()), M.end());
729729 }
730730
996996 for (auto &RC : RegClasses)
997997 if (SuperRegRCsBV[RC.EnumValue])
998998 SuperRegRCs.emplace_back(&RC);
999 llvm::sort(SuperRegRCs.begin(), SuperRegRCs.end(), SizeOrder);
999 llvm::sort(SuperRegRCs, SizeOrder);
10001000 assert(SuperRegRCs.front() == BiggestSuperRegRC && "Biggest class wasn't first");
10011001
10021002 // Find all the subreg classes and order them by size too.
10071007 if (SuperRegClassesBV.any())
10081008 SuperRegClasses.push_back(std::make_pair(&RC, SuperRegClassesBV));
10091009 }
1010 llvm::sort(SuperRegClasses.begin(), SuperRegClasses.end(),
1010 llvm::sort(SuperRegClasses,
10111011 [&](const std::pair &A,
10121012 const std::pair &B) {
10131013 return SizeOrder(A.first, B.first);
10721072 if (!RU.Artificial)
10731073 TmpUnits.push_back(*UnitI);
10741074 }
1075 llvm::sort(TmpUnits.begin(), TmpUnits.end());
1075 llvm::sort(TmpUnits);
10761076 std::unique_copy(TmpUnits.begin(), TmpUnits.end(),
10771077 std::back_inserter(RegUnits));
10781078 }
10921092 // Read in the user-defined (named) sub-register indices.
10931093 // More indices will be synthesized later.
10941094 std::vector SRIs = Records.getAllDerivedDefinitions("SubRegIndex");
1095 llvm::sort(SRIs.begin(), SRIs.end(), LessRecord());
1095 llvm::sort(SRIs, LessRecord());
10961096 for (unsigned i = 0, e = SRIs.size(); i != e; ++i)
10971097 getSubRegIdx(SRIs[i]);
10981098 // Build composite maps from ComposedOf fields.
11011101
11021102 // Read in the register definitions.
11031103 std::vector Regs = Records.getAllDerivedDefinitions("Register");
1104 llvm::sort(Regs.begin(), Regs.end(), LessRecordRegister());
1104 llvm::sort(Regs, LessRecordRegister());
11051105 // Assign the enumeration values.
11061106 for (unsigned i = 0, e = Regs.size(); i != e; ++i)
11071107 getReg(Regs[i]);
11121112
11131113 for (Record *R : Tups) {
11141114 std::vector TupRegs = *Sets.expand(R);
1115 llvm::sort(TupRegs.begin(), TupRegs.end(), LessRecordRegister());
1115 llvm::sort(TupRegs, LessRecordRegister());
11161116 for (Record *RC : TupRegs)
11171117 getReg(RC);
11181118 }
364364
365365 // Sort OpcodeMappings elements based on their CPU and predicate masks.
366366 // As a last resort, order elements by opcode identifier.
367 llvm::sort(OpcodeMappings.begin(), OpcodeMappings.end(),
367 llvm::sort(OpcodeMappings,
368368 [&](const OpcodeMapPair &Lhs, const OpcodeMapPair &Rhs) {
369369 unsigned LhsIdx = Opcode2Index[Lhs.first];
370370 unsigned RhsIdx = Opcode2Index[Rhs.first];
495495 /// Gather all processor models.
496496 void CodeGenSchedModels::collectProcModels() {
497497 RecVec ProcRecords = Records.getAllDerivedDefinitions("Processor");
498 llvm::sort(ProcRecords.begin(), ProcRecords.end(), LessRecordFieldName());
498 llvm::sort(ProcRecords, LessRecordFieldName());
499499
500500 // Reserve space because we can. Reallocation would be ok.
501501 ProcModels.reserve(ProcRecords.size()+1);
614614 // Find all ReadWrites referenced by SchedAlias. AliasDefs needs to be sorted
615615 // for the loop below that initializes Alias vectors.
616616 RecVec AliasDefs = Records.getAllDerivedDefinitions("SchedAlias");
617 llvm::sort(AliasDefs.begin(), AliasDefs.end(), LessRecord());
617 llvm::sort(AliasDefs, LessRecord());
618618 for (Record *ADef : AliasDefs) {
619619 Record *MatchDef = ADef->getValueAsDef("MatchRW");
620620 Record *AliasDef = ADef->getValueAsDef("AliasRW");
632632 }
633633 // Sort and add the SchedReadWrites directly referenced by instructions or
634634 // itinerary resources. Index reads and writes in separate domains.
635 llvm::sort(SWDefs.begin(), SWDefs.end(), LessRecord());
635 llvm::sort(SWDefs, LessRecord());
636636 for (Record *SWDef : SWDefs) {
637637 assert(!getSchedRWIdx(SWDef, /*IsRead=*/false) && "duplicate SchedWrite");
638638 SchedWrites.emplace_back(SchedWrites.size(), SWDef);
639639 }
640 llvm::sort(SRDefs.begin(), SRDefs.end(), LessRecord());
640 llvm::sort(SRDefs, LessRecord());
641641 for (Record *SRDef : SRDefs) {
642642 assert(!getSchedRWIdx(SRDef, /*IsRead-*/true) && "duplicate SchedWrite");
643643 SchedReads.emplace_back(SchedReads.size(), SRDef);
857857 }
858858 // Create classes for InstRW defs.
859859 RecVec InstRWDefs = Records.getAllDerivedDefinitions("InstRW");
860 llvm::sort(InstRWDefs.begin(), InstRWDefs.end(), LessRecord());
860 llvm::sort(InstRWDefs, LessRecord());
861861 LLVM_DEBUG(dbgs() << "\n+++ SCHED CLASSES (createInstRWClass) +++\n");
862862 for (Record *RWDef : InstRWDefs)
863863 createInstRWClass(RWDef);
11611161 // Gather the read/write types for each itinerary class.
11621162 void CodeGenSchedModels::collectProcItinRW() {
11631163 RecVec ItinRWDefs = Records.getAllDerivedDefinitions("ItinRW");
1164 llvm::sort(ItinRWDefs.begin(), ItinRWDefs.end(), LessRecord());
1164 llvm::sort(ItinRWDefs, LessRecord());
11651165 for (Record *RWDef : ItinRWDefs) {
11661166 if (!RWDef->getValueInit("SchedModel")->isComplete())
11671167 PrintFatalError(RWDef->getLoc(), "SchedModel is undefined");
277277
278278 void CodeGenTarget::ReadRegAltNameIndices() const {
279279 RegAltNameIndices = Records.getAllDerivedDefinitions("RegAltNameIndex");
280 llvm::sort(RegAltNameIndices.begin(), RegAltNameIndices.end(), LessRecord());
280 llvm::sort(RegAltNameIndices, LessRecord());
281281 }
282282
283283 /// getRegisterByName - If there is a register with the specific AsmName,
302302 }
303303
304304 // Remove duplicates.
305 llvm::sort(Result.begin(), Result.end());
305 llvm::sort(Result);
306306 Result.erase(std::unique(Result.begin(), Result.end()), Result.end());
307307 return Result;
308308 }
313313 LegalValueTypes.insert(LegalValueTypes.end(), RC.VTs.begin(), RC.VTs.end());
314314
315315 // Remove duplicates.
316 llvm::sort(LegalValueTypes.begin(), LegalValueTypes.end());
316 llvm::sort(LegalValueTypes);
317317 LegalValueTypes.erase(std::unique(LegalValueTypes.begin(),
318318 LegalValueTypes.end()),
319319 LegalValueTypes.end());
512512 if (isTarget == TargetOnly)
513513 Intrinsics.push_back(CodeGenIntrinsic(Defs[I]));
514514 }
515 llvm::sort(Intrinsics.begin(), Intrinsics.end(),
515 llvm::sort(Intrinsics,
516516 [](const CodeGenIntrinsic &LHS, const CodeGenIntrinsic &RHS) {
517517 return std::tie(LHS.TargetPrefix, LHS.Name) <
518518 std::tie(RHS.TargetPrefix, RHS.Name);
708708 Properties = parseSDPatternOperatorProperties(R);
709709
710710 // Sort the argument attributes for later benefit.
711 llvm::sort(ArgumentAttributes.begin(), ArgumentAttributes.end());
712 }
713
711 llvm::sort(ArgumentAttributes);
712 }
713
26122612 std::vector MergeInsnIDs;
26132613 for (const auto &IDMatcherPair : Rule.defined_insn_vars())
26142614 MergeInsnIDs.push_back(IDMatcherPair.second);
2615 llvm::sort(MergeInsnIDs.begin(), MergeInsnIDs.end());
2615 llvm::sort(MergeInsnIDs);
26162616 for (const auto &MergeInsnID : MergeInsnIDs)
26172617 Table << MatchTable::IntValue(MergeInsnID);
26182618 Table << MatchTable::NamedValue("GIU_MergeMemOperands_EndOfList")
28112811
28122812 InsnIDs.push_back(Pair.second);
28132813 }
2814 llvm::sort(InsnIDs.begin(), InsnIDs.end());
2814 llvm::sort(InsnIDs);
28152815
28162816 for (const auto &InsnID : InsnIDs) {
28172817 // Reject the difficult cases until we have a more accurate check.
42874287
42884288 std::vector ComplexPredicates =
42894289 RK.getAllDerivedDefinitions("GIComplexOperandMatcher");
4290 llvm::sort(ComplexPredicates.begin(), ComplexPredicates.end(), orderByName);
4290 llvm::sort(ComplexPredicates, orderByName);
42914291
42924292 std::vector CustomRendererFns =
42934293 RK.getAllDerivedDefinitions("GICustomOperandRenderer");
4294 llvm::sort(CustomRendererFns.begin(), CustomRendererFns.end(), orderByName);
4294 llvm::sort(CustomRendererFns, orderByName);
42954295
42964296 unsigned MaxTemporaries = 0;
42974297 for (const auto &Rule : Rules)
43704370 std::vector TypeObjects;
43714371 for (const auto &Ty : KnownTypes)
43724372 TypeObjects.push_back(Ty);
4373 llvm::sort(TypeObjects.begin(), TypeObjects.end());
4373 llvm::sort(TypeObjects);
43744374 OS << "// LLT Objects.\n"
43754375 << "enum {\n";
43764376 for (const auto &TypeObject : TypeObjects) {
8383 std::vector Pairs;
8484 for (const auto &P : Map)
8585 Pairs.push_back(&P);
86 llvm::sort(Pairs.begin(), Pairs.end(), deref>());
86 llvm::sort(Pairs, deref>());
8787
8888 OS << '{';
8989 for (unsigned i = 0, e = Pairs.size(); i != e; ++i) {
175175 std::vector Pairs;
176176 for (const auto &P : Map)
177177 Pairs.push_back(&P);
178 llvm::sort(Pairs.begin(), Pairs.end(), deref>());
178 llvm::sort(Pairs, deref>());
179179
180180 OS << '{';
181181 for (unsigned i = 0, e = Pairs.size(); i != e; ++i) {
139139 // Get all records of class and sort
140140 std::vector DefList =
141141 Records.getAllDerivedDefinitions("SubtargetFeature");
142 llvm::sort(DefList.begin(), DefList.end(), LessRecord());
142 llvm::sort(DefList, LessRecord());
143143
144144 unsigned N = DefList.size();
145145 if (N == 0)
178178 if (FeatureList.empty())
179179 return 0;
180180
181 llvm::sort(FeatureList.begin(), FeatureList.end(), LessRecordFieldName());
181 llvm::sort(FeatureList, LessRecordFieldName());
182182
183183 // Begin feature table
184184 OS << "// Sorted (by key) array of values for CPU features.\n"
228228 // Gather and sort processor information
229229 std::vector ProcessorList =
230230 Records.getAllDerivedDefinitions("Processor");
231 llvm::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName());
231 llvm::sort(ProcessorList, LessRecordFieldName());
232232
233233 // Begin processor table
234234 OS << "// Sorted (by key) array of values for CPU subtype.\n"
11811181 WriteIDs.push_back(SchedModels.getSchedRWIdx(VW, /*IsRead=*/false));
11821182 }
11831183 }
1184 llvm::sort(WriteIDs.begin(), WriteIDs.end());
1184 llvm::sort(WriteIDs);
11851185 for(unsigned W : WriteIDs) {
11861186 MCReadAdvanceEntry RAEntry;
11871187 RAEntry.UseIdx = UseIdx;
11991199 // compression.
12001200 //
12011201 // WritePrecRes entries are sorted by ProcResIdx.
1202 llvm::sort(WriteProcResources.begin(), WriteProcResources.end(),
1203 LessWriteProcResources());
1202 llvm::sort(WriteProcResources, LessWriteProcResources());
12041203
12051204 SCDesc.NumWriteProcResEntries = WriteProcResources.size();
12061205 std::vector::iterator WPRPos =
14121411 // Gather and sort processor information
14131412 std::vector ProcessorList =
14141413 Records.getAllDerivedDefinitions("Processor");
1415 llvm::sort(ProcessorList.begin(), ProcessorList.end(), LessRecordFieldName());
1414 llvm::sort(ProcessorList, LessRecordFieldName());
14161415
14171416 // Begin processor table
14181417 OS << "\n";
14781477 // stream.
14791478 std::vector Prologs =
14801479 Records.getAllDerivedDefinitions("PredicateProlog");
1481 llvm::sort(Prologs.begin(), Prologs.end(), LessRecord());
1480 llvm::sort(Prologs, LessRecord());
14821481 for (Record *P : Prologs)
14831482 Stream << P->getValueAsString("Code") << '\n';
14841483
17161715 unsigned NumProcs) {
17171716 std::vector Features =
17181717 Records.getAllDerivedDefinitions("SubtargetFeature");
1719 llvm::sort(Features.begin(), Features.end(), LessRecord());
1718 llvm::sort(Features, LessRecord());
17201719
17211720 OS << "// ParseSubtargetFeatures - Parses features string setting specified\n"
17221721 << "// subtarget options.\n"