llvm.org GIT mirror llvm / a736b96
Use llvm::stable_sort. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358897 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 3 months ago
7 changed file(s) with 18 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
955955 for (unsigned i = 0, e = Stats.CodeFreq.size(); i != e; ++i)
956956 if (unsigned Freq = Stats.CodeFreq[i].NumInstances)
957957 FreqPairs.push_back(std::make_pair(Freq, i));
958 std::stable_sort(FreqPairs.begin(), FreqPairs.end());
958 llvm::stable_sort(FreqPairs);
959959 std::reverse(FreqPairs.begin(), FreqPairs.end());
960960
961961 outs() << "\tRecord Histogram:\n";
188188
189189 // We need the expansions and instantiations sorted so we can go through them
190190 // while we iterate lines.
191 std::stable_sort(ExpansionSubViews.begin(), ExpansionSubViews.end());
192 std::stable_sort(InstantiationSubViews.begin(), InstantiationSubViews.end());
191 llvm::stable_sort(ExpansionSubViews);
192 llvm::stable_sort(InstantiationSubViews);
193193 auto NextESV = ExpansionSubViews.begin();
194194 auto EndESV = ExpansionSubViews.end();
195195 auto NextISV = InstantiationSubViews.begin();
14671467 void Object::sortSections() {
14681468 // Put all sections in offset order. Maintain the ordering as closely as
14691469 // possible while meeting that demand however.
1470 auto CompareSections = [](const SecPtr &A, const SecPtr &B) {
1470 llvm::stable_sort(Sections, [](const SecPtr &A, const SecPtr &B) {
14711471 return A->OriginalOffset < B->OriginalOffset;
1472 };
1473 std::stable_sort(std::begin(this->Sections), std::end(this->Sections),
1474 CompareSections);
1472 });
14751473 }
14761474
14771475 static uint64_t alignToAddr(uint64_t Offset, uint64_t Addr, uint64_t Align) {
14891487
14901488 // Orders segments such that if x = y->ParentSegment then y comes before x.
14911489 static void orderSegments(std::vector &Segments) {
1492 std::stable_sort(std::begin(Segments), std::end(Segments),
1493 compareSegmentsByOffset);
1490 llvm::stable_sort(Segments, compareSegmentsByOffset);
14941491 }
14951492
14961493 // This function finds a consistent layout for a list of segments starting from
17451742 for (Segment *Seg : OrderedSegments)
17461743 Seg->PAddr = Seg->VAddr;
17471744
1748 std::stable_sort(std::begin(OrderedSegments), std::end(OrderedSegments),
1749 compareSegmentsByPAddr);
1745 llvm::stable_sort(OrderedSegments, compareSegmentsByPAddr);
17501746
17511747 // Because we add a ParentSegment for each section we might have duplicate
17521748 // segments in OrderedSegments. If there were duplicates then LayoutSegments
316316 std::vector
317317 StatCollection::getStatsSortedBySize() const {
318318 std::vector SortedStats(Individual.begin(), Individual.end());
319 std::stable_sort(SortedStats.begin(), SortedStats.end(),
320 [](const KindAndStat &LHS, const KindAndStat &RHS) {
321 return LHS.second.Size > RHS.second.Size;
322 });
319 llvm::stable_sort(SortedStats,
320 [](const KindAndStat &LHS, const KindAndStat &RHS) {
321 return LHS.second.Size > RHS.second.Size;
322 });
323323 return SortedStats;
324324 }
325325
888888 std::vector NamespacedStatsSorted;
889889 for (const auto &Stat : NamespacedStats)
890890 NamespacedStatsSorted.push_back({Stat.getKey(), Stat.second});
891 std::stable_sort(NamespacedStatsSorted.begin(), NamespacedStatsSorted.end(),
892 [](const StrAndStat &L, const StrAndStat &R) {
893 return L.Stat.Size > R.Stat.Size;
894 });
891 llvm::stable_sort(NamespacedStatsSorted,
892 [](const StrAndStat &L, const StrAndStat &R) {
893 return L.Stat.Size > R.Stat.Size;
894 });
895895 for (const auto &Stat : NamespacedStatsSorted) {
896896 std::string Label = formatv("namespace '{0}'", Stat.Key);
897897 P.formatLine("{0} | {1:N} {2:N}",
15921592 Libs.push_back(Name);
15931593 }
15941594
1595 std::stable_sort(Libs.begin(), Libs.end());
1595 llvm::stable_sort(Libs);
15961596
15971597 for (const auto &L : Libs) {
15981598 outs() << " " << L << "\n";
18761876 if (Entry.d_tag == ELF::DT_NEEDED)
18771877 Libs.push_back(getDynamicString(Entry.d_un.d_val));
18781878
1879 std::stable_sort(Libs.begin(), Libs.end());
1879 llvm::stable_sort(Libs);
18801880
18811881 for (const auto &L : Libs)
18821882 W.startLine() << L << "\n";
693693 }
694694 }
695695
696 std::stable_sort(Libs.begin(), Libs.end());
696 llvm::stable_sort(Libs);
697697
698698 for (const auto &L : Libs) {
699699 outs() << " " << L << "\n";